brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [43/72] [abbrv] incubator-brooklyn git commit: BROOKLYN-162 - jclouds last few package prefixes needed, and tidy in core and elsewhere related (or observed in the process)
Date Wed, 19 Aug 2015 11:10:01 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/brooklyn/policy/os/AdvertiseWinrmLoginPolicyTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/policy/os/AdvertiseWinrmLoginPolicyTest.java b/locations/jclouds/src/test/java/brooklyn/policy/os/AdvertiseWinrmLoginPolicyTest.java
deleted file mode 100644
index 9646825..0000000
--- a/locations/jclouds/src/test/java/brooklyn/policy/os/AdvertiseWinrmLoginPolicyTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.policy.os;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.basic.WinRmMachineLocation;
-
-import com.google.common.collect.ImmutableList;
-
-public class AdvertiseWinrmLoginPolicyTest extends BrooklynAppUnitTestSupport {
-
-    @Test
-    public void testAdvertisesMachineLoginDetails() throws Exception {
-        TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
-                .policy(PolicySpec.create(AdvertiseWinrmLoginPolicy.class)));
-        
-        WinRmMachineLocation machine = mgmt.getLocationManager().createLocation(LocationSpec.create(WinRmMachineLocation.class)
-                .configure("address", "1.2.3.4")
-                .configure("user", "myuser")
-                .configure("port", 5678)
-                .configure("password", "mypassword"));
-        app.start(ImmutableList.of(machine));
-        
-        String expected = "myuser : mypassword @ 1.2.3.4:5678";
-
-        EntityTestUtils.assertAttributeEqualsEventually(entity, AdvertiseWinrmLoginPolicy.VM_USER_CREDENTIALS, expected);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyLiveTest.java b/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyLiveTest.java
deleted file mode 100644
index ff15871..0000000
--- a/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyLiveTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.policy.os;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.core.internal.ssh.SshTool;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-public class CreateUserPolicyLiveTest extends BrooklynAppLiveTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(CreateUserPolicyLiveTest.class);
-
-    // TODO Fails on OS X
-    @Test(groups={"Integration", "WIP"})
-    public void testIntegrationCreatesUser() throws Exception {
-        LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
-        runTestCreatesUser(loc);
-    }
-    
-    @Test(groups="Live")
-    @SuppressWarnings("unchecked")
-    public void testLiveCreatesUser() throws Exception {
-        String locSpec = "jclouds:softlayer:ams01";
-        ImmutableMap<String, String> locArgs = ImmutableMap.of("imageId", "CENTOS_6_64");
-        Location loc = mgmt.getLocationRegistry().resolve(locSpec, locArgs);
-        runTestCreatesUser((MachineProvisioningLocation<SshMachineLocation>) loc);
-    }
-    
-    public void runTestCreatesUser(MachineProvisioningLocation<SshMachineLocation> loc) throws Exception {
-        String newUsername = Identifiers.makeRandomId(16);
-        SshMachineLocation machine = loc.obtain(ImmutableMap.of());
-        
-        try {
-            app.createAndManageChild(EntitySpec.create(TestEntity.class)
-                    .policy(PolicySpec.create(CreateUserPolicy.class)
-                            .configure(CreateUserPolicy.GRANT_SUDO, true)
-                            .configure(CreateUserPolicy.VM_USERNAME, newUsername)));
-            TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
-
-            app.start(ImmutableList.of(machine));
-            
-            String creds = EntityTestUtils.assertAttributeEventuallyNonNull(entity, CreateUserPolicy.VM_USER_CREDENTIALS);
-            Pattern pattern = Pattern.compile("(.*) : (.*) @ (.*):(.*)");
-            Matcher matcher = pattern.matcher(creds);
-            assertTrue(matcher.matches());
-            String username = matcher.group(1).trim();
-            String password = matcher.group(2).trim();
-            String hostname = matcher.group(3).trim();
-            String port = matcher.group(4).trim();
-            
-            assertEquals(newUsername, username);
-            assertEquals(hostname, machine.getAddress().getHostName());
-            assertEquals(port, ""+machine.getPort());
-    
-            SshMachineLocation machine2 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                    .configure(SshTool.PROP_USER, newUsername)
-                    .configure(SshMachineLocation.PASSWORD, password)
-                    .configure("address", hostname)
-                    .configure(SshMachineLocation.SSH_PORT, Integer.parseInt(port)));
-            
-            LOG.info("Checking ssh'able for auto-generated user: machine="+machine+"; creds="+creds);
-            assertTrue(machine2.isSshable(), "machine="+machine+"; creds="+creds);
-            
-        } catch (Exception e) {
-            throw e;
-        } finally {
-            LOG.info("Deleting auto-generated user "+newUsername);
-            machine.execScript("delete-user-"+newUsername, ImmutableList.of("sudo userdel -f "+newUsername));
-            
-            loc.release(machine);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyTest.java b/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyTest.java
deleted file mode 100644
index 9e876c4..0000000
--- a/locations/jclouds/src/test/java/brooklyn/policy/os/CreateUserPolicyTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.policy.os;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.core.internal.ssh.SshTool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-public class CreateUserPolicyTest extends BrooklynAppUnitTestSupport {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(CreateUserPolicyTest.class);
-
-    public static class RecordingSshMachineLocation extends SshMachineLocation {
-        private static final long serialVersionUID = 1641930081769106380L;
-        
-        public static List<List<String>> execScriptCalls = Lists.newArrayList();
-
-        @Override 
-        public int execScript(String summary, List<String> cmds) {
-            execScriptCalls.add(cmds);
-            return 0;
-        }
-        @Override 
-        public int execScript(Map<String,?> props, String summaryForLogging, List<String> cmds) {
-            execScriptCalls.add(cmds);
-            return 0;
-        }
-        @Override 
-        public int execScript(String summaryForLogging, List<String> cmds, Map<String,?> env) {
-            execScriptCalls.add(cmds);
-            return 0;
-        }
-        @Override 
-        public int execScript(Map<String,?> props, String summaryForLogging, List<String> cmds, Map<String,?> env) {
-            execScriptCalls.add(cmds);
-            return 0;
-        }
-    }
-
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        RecordingSshMachineLocation.execScriptCalls.clear();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    @Override
-    public void tearDown() throws Exception {
-        try {
-            super.tearDown();
-        } finally {
-            RecordingSshMachineLocation.execScriptCalls.clear();
-        }
-    }
-    
-    @Test
-    public void testCallsCreateUser() throws Exception {
-        SshMachineLocation machine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class)
-                .configure(SshTool.PROP_USER, "myuser")
-                .configure(SshTool.PROP_PASSWORD, "mypassword")
-                .configure("address", "1.2.3.4")
-                .configure(SshTool.PROP_PORT, 1234));
-    
-        String newUsername = "mynewuser";
-        
-        app.createAndManageChild(EntitySpec.create(TestEntity.class)
-                .policy(PolicySpec.create(CreateUserPolicy.class)
-                        .configure(CreateUserPolicy.GRANT_SUDO, true)
-                        .configure(CreateUserPolicy.VM_USERNAME, newUsername)));
-        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
-        app.start(ImmutableList.of(machine));
-        
-        String creds = EntityTestUtils.assertAttributeEventuallyNonNull(entity, CreateUserPolicy.VM_USER_CREDENTIALS);
-        Pattern pattern = Pattern.compile("(.*) : (.*) @ (.*):(.*)");
-        Matcher matcher = pattern.matcher(creds);
-        assertTrue(matcher.matches());
-        String username2 = matcher.group(1).trim();
-        String password = matcher.group(2).trim();
-        String hostname = matcher.group(3).trim();
-        String port = matcher.group(4).trim();
-        
-        assertEquals(newUsername, username2);
-        assertEquals(hostname, "1.2.3.4");
-        assertEquals(password.length(), 12);
-        assertEquals(port, "1234");
-
-        boolean found = false;
-        for (List<String> cmds : RecordingSshMachineLocation.execScriptCalls) {
-            if (cmds.toString().contains("useradd")) {
-                found = true;
-                break;
-            }
-        }
-        assertTrue(found, "useradd not found in: "+RecordingSshMachineLocation.execScriptCalls);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreCleaner.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreCleaner.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreCleaner.java
new file mode 100644
index 0000000..8a75382
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreCleaner.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.PageSet;
+import org.jclouds.blobstore.domain.StorageMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.location.cloud.CloudLocationConfig;
+import org.apache.brooklyn.location.core.LocationConfigKeys;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+
+/** Utility for cleaning up after test leaks. Most should not leak of course, but if they do... */
+public class BlobStoreCleaner {
+
+    private static String locationSpec = BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC;
+
+    private static final Logger log = LoggerFactory.getLogger(BlobStoreCleaner.class);
+    
+    public static void main(String[] args) {
+        LocalManagementContextForTests mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault()); 
+        JcloudsLocation location = (JcloudsLocation) mgmt.getLocationRegistry().resolve(locationSpec);
+            
+        String identity = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_IDENTITY), "identity must not be null");
+        String credential = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_CREDENTIAL), "credential must not be null");
+        String provider = checkNotNull(location.getConfig(LocationConfigKeys.CLOUD_PROVIDER), "provider must not be null");
+        String endpoint = location.getConfig(CloudLocationConfig.CLOUD_ENDPOINT);
+
+        BlobStoreContext context = ContextBuilder.newBuilder(provider)
+                .credentials(identity, credential)
+                .endpoint(endpoint)
+                .buildView(BlobStoreContext.class);
+        
+        PageSet<? extends StorageMetadata> containers = context.getBlobStore().list();
+        for (StorageMetadata container: containers) {
+            if (container.getName().matches("brooklyn.*-test.*")
+                // to kill all containers here
+//                || container.getName().matches(".*")
+                ) {
+                log.info("killing - "+container.getName());
+                context.getBlobStore().deleteContainer(container.getName());
+            } else {
+                log.info("KEEPING - "+container.getName());
+            }
+        }
+        context.close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreExpiryTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreExpiryTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreExpiryTest.java
new file mode 100644
index 0000000..d86fc74
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreExpiryTest.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.openstack.reference.AuthHeaders.URL_SUFFIX;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.core.http.HttpTool;
+import org.apache.brooklyn.util.core.http.HttpToolResponse;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.apache.brooklyn.util.time.Duration;
+import org.apache.brooklyn.util.time.Time;
+import org.apache.http.client.HttpClient;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.PageSet;
+import org.jclouds.blobstore.domain.StorageMetadata;
+import org.jclouds.domain.Credentials;
+import org.jclouds.openstack.domain.AuthenticationResponse;
+import org.jclouds.openstack.reference.AuthHeaders;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.location.cloud.CloudLocationConfig;
+import org.apache.brooklyn.location.core.LocationConfigKeys;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+import org.apache.brooklyn.location.jclouds.JcloudsUtil;
+
+import com.google.common.base.Preconditions;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.inject.Inject;
+
+@Test(groups={"Live", "Live-sanity"})
+public class BlobStoreExpiryTest {
+
+    private static final Logger log = LoggerFactory.getLogger(BlobStoreExpiryTest.class);
+    
+    /**
+     * Live tests as written require a location defined as follows:
+     * 
+     * <code>
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1==jclouds:swift:https://ams01.objectstorage.softlayer.net/auth/v1.0
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1.identity=IBMOS1234-5:yourname
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1.credential=0123abcd.......
+     * </code>
+     */
+    
+    public static final String PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC = BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC;
+    public static final String CONTAINER_PREFIX = "brooklyn-persistence-test";
+    private String locationSpec = PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC;
+    
+    private JcloudsLocation location;
+    private BlobStoreContext context;
+
+    private ManagementContext mgmt;
+    private String testContainerName;
+
+    private String identity;
+    private String credential;
+    private String provider;
+    private String endpoint;
+
+    public synchronized BlobStoreContext getSwiftBlobStoreContext() {
+        if (context==null) {
+            if (location==null) {
+                Preconditions.checkNotNull(locationSpec, "locationSpec required for remote object store when location is null");
+                Preconditions.checkNotNull(mgmt, "mgmt required for remote object store when location is null");
+                location = (JcloudsLocation) mgmt.getLocationRegistry().resolve(locationSpec);
+            }
+            
+            identity = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_IDENTITY), "identity must not be null");
+            credential = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_CREDENTIAL), "credential must not be null");
+            provider = checkNotNull(location.getConfig(LocationConfigKeys.CLOUD_PROVIDER), "provider must not be null");
+            endpoint = location.getConfig(CloudLocationConfig.CLOUD_ENDPOINT);
+
+            context = JcloudsUtil.newBlobstoreContext(provider, endpoint, identity, credential);
+        }
+        return context;
+    }
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setup() {
+        testContainerName = CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(8);
+        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void teardown() {
+        Entities.destroyAll(mgmt);
+        if (context!=null) context.close();
+        context = null;
+    }
+
+    public void testRenewAuthSucceedsInSwiftObjectStore() throws Exception {
+        doTestRenewAuth();
+    }
+    
+    protected void doTestRenewAuth() throws Exception {
+        getSwiftBlobStoreContext();
+        
+        injectShortLivedTokenForSwiftAuth();
+        
+        context.getBlobStore().createContainerInLocation(null, testContainerName);
+        
+        assertContainerFound();
+        
+        log.info("created container, now sleeping for expiration");
+        
+        Time.sleep(Duration.TEN_SECONDS);
+        
+        assertContainerFound();
+
+        context.getBlobStore().deleteContainer(testContainerName);
+    }
+
+    private void assertContainerFound() {
+        PageSet<? extends StorageMetadata> ps = context.getBlobStore().list();
+        BlobStoreTest.assertHasItemNamed(ps, testContainerName);
+    }
+
+    private void injectShortLivedTokenForSwiftAuth() throws Exception {
+        URL endpointUrl = new URL(endpoint);
+
+        HttpToolResponse tokenHttpResponse1 = requestTokenWithExplicitLifetime(endpointUrl,
+            identity, credential, Duration.FIVE_SECONDS);
+        
+        Builder<String, URI> servicesMapBuilder = ImmutableMap.builder();
+        for (Entry<String, List<String>> entry : tokenHttpResponse1.getHeaderLists().entrySet()) {
+            if (entry.getKey().toLowerCase().endsWith(URL_SUFFIX.toLowerCase()) ||
+                    entry.getKey().toLowerCase().endsWith("X-Auth-Token-Expires".toLowerCase())){
+                servicesMapBuilder.put(entry.getKey(), URI.create(entry.getValue().iterator().next()));
+            }
+        }
+        AuthenticationResponse authResponse = new AuthenticationResponse(tokenHttpResponse1.getHeaderLists().get(AuthHeaders.AUTH_TOKEN).get(0), servicesMapBuilder.build());
+
+        getAuthCache().put(new Credentials(identity, credential), authResponse);
+    }
+
+    private LoadingCache<Credentials, AuthenticationResponse> getAuthCache() {
+        return context.utils().injector().getInstance(CachePeeker.class).authenticationResponseCache;
+    }
+    
+    public static class CachePeeker {
+        private final LoadingCache<Credentials, AuthenticationResponse> authenticationResponseCache;
+
+        @Inject
+        protected CachePeeker(LoadingCache<Credentials, AuthenticationResponse> authenticationResponseCache) {
+           this.authenticationResponseCache = authenticationResponseCache;
+        }
+    }
+    
+    public static HttpToolResponse requestTokenWithExplicitLifetime(URL url, String user, String key, Duration expiration) throws URISyntaxException {
+        HttpClient client = HttpTool.httpClientBuilder().build();
+        HttpToolResponse response = HttpTool.httpGet(client, url.toURI(), MutableMap.<String,String>of()
+            .add(AuthHeaders.AUTH_USER, user)
+            .add(AuthHeaders.AUTH_KEY, key)
+            .add("Host", url.getHost())
+            .add("X-Auth-New-Token", "" + true)
+            .add("X-Auth-Token-Lifetime", "" + expiration.toSeconds())
+            );
+//        curl -v https://ams01.objectstorage.softlayer.net/auth/v1.0/v1.0 -H "X-Auth-User: IBMOS12345-2:username" -H "X-Auth-Key: <API KEY>" -H "Host: ams01.objectstorage.softlayer.net" -H "X-Auth-New-Token: true" -H "X-Auth-Token-Lifetime: 15"
+        log.info("Requested token with explicit lifetime: "+expiration+" at "+url+"\n"+response+"\n"+response.getHeaderLists());
+        return response;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStorePersistencePerformanceTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStorePersistencePerformanceTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStorePersistencePerformanceTest.java
new file mode 100644
index 0000000..9690c00
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStorePersistencePerformanceTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
+import org.apache.brooklyn.core.mgmt.persist.PersistMode;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore.StoreObjectAccessor;
+import org.apache.brooklyn.core.mgmt.persist.jclouds.JcloudsBlobStoreBasedObjectStore;
+import org.apache.brooklyn.core.test.qa.performance.AbstractPerformanceTest;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+public class BlobStorePersistencePerformanceTest extends AbstractPerformanceTest {
+
+    public static final String LOCATION_SPEC = "named:brooklyn-jclouds-objstore-test-1";
+    
+    JcloudsBlobStoreBasedObjectStore objectStore;
+    StoreObjectAccessor blobstoreAccessor;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        objectStore = new JcloudsBlobStoreBasedObjectStore(LOCATION_SPEC, "BlobStorePersistencePerformanceTest");
+        objectStore.injectManagementContext(mgmt);
+        objectStore.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.AUTO);
+        blobstoreAccessor = objectStore.newAccessor(Identifiers.makeRandomId(8));
+        
+        app.start(ImmutableList.of(loc));
+    }
+
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (blobstoreAccessor != null) blobstoreAccessor.delete();
+        if (objectStore != null) {
+            objectStore.deleteCompletely();
+            objectStore.close();
+        }
+    }
+    
+    protected int numIterations() {
+        return 100;
+    }
+    
+     @Test(groups={"Live", "Acceptance"})
+     public void testStoreObjectPuts() throws Exception {
+         int numIterations = numIterations();
+         double minRatePerSec = 10 * PERFORMANCE_EXPECTATION;
+         final AtomicInteger i = new AtomicInteger();
+         
+         measureAndAssert("StoreObjectAccessor.put", numIterations, minRatePerSec, new Runnable() {
+             public void run() {
+                 blobstoreAccessor.put(""+i.incrementAndGet());
+             }});
+     }
+ 
+     @Test(groups={"Live", "Acceptance"})
+     public void testStoreObjectGet() throws Exception {
+         // The file system will have done a lot of caching here - we are unlikely to touch the disk more than once.
+         int numIterations = numIterations();
+         double minRatePerSec = 10 * PERFORMANCE_EXPECTATION;
+
+         measureAndAssert("FileBasedStoreObjectAccessor.get", numIterations, minRatePerSec, new Runnable() {
+             public void run() {
+                 blobstoreAccessor.get();
+             }});
+     }
+ 
+     @Test(groups={"Live", "Acceptance"})
+     public void testStoreObjectDelete() throws Exception {
+         int numIterations = numIterations();
+         double minRatePerSec = 10 * PERFORMANCE_EXPECTATION;
+
+         // Will do 10% warm up runs first
+         final List<StoreObjectAccessor> blobstoreAccessors = Lists.newArrayList();
+         for (int i = 0; i < (numIterations * 1.1 + 1); i++) {
+             blobstoreAccessors.add(objectStore.newAccessor("storeObjectDelete-"+i));
+         }
+         
+         final AtomicInteger i = new AtomicInteger();
+
+         try {
+             measureAndAssert("FileBasedStoreObjectAccessor.delete", numIterations, minRatePerSec, new Runnable() {
+                 public void run() {
+                     StoreObjectAccessor blobstoreAccessor = blobstoreAccessors.get(i.getAndIncrement());
+                     blobstoreAccessor.delete();
+                 }});
+         } finally {
+             for (StoreObjectAccessor blobstoreAccessor : blobstoreAccessors) {
+                 blobstoreAccessor.delete();
+             }
+         }
+     }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreTest.java
new file mode 100644
index 0000000..c8e7309
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BlobStoreTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.IOException;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.Blob;
+import org.jclouds.blobstore.domain.PageSet;
+import org.jclouds.blobstore.domain.StorageMetadata;
+import org.jclouds.blobstore.options.ListContainerOptions;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.location.cloud.CloudLocationConfig;
+import org.apache.brooklyn.location.core.LocationConfigKeys;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+import org.apache.brooklyn.location.jclouds.JcloudsUtil;
+
+import com.google.common.base.Preconditions;
+
+@Test(groups={"Live", "Live-sanity"})
+public class BlobStoreTest {
+
+    /**
+     * Live tests as written require a location defined as follows:
+     * 
+     * <code>
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1==jclouds:swift:https://ams01.objectstorage.softlayer.net/auth/v1.0
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1.identity=IBMOS1234-5:yourname
+     * brooklyn.location.named.brooklyn-jclouds-objstore-test-1.credential=0123abcd.......
+     * </code>
+     */
+    public static final String PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC = "named:brooklyn-jclouds-objstore-test-1";
+    
+    public static final String CONTAINER_PREFIX = "brooklyn-persistence-test";
+    
+    private String locationSpec = PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC;
+    
+    private JcloudsLocation location;
+    private BlobStoreContext context;
+
+    private ManagementContext mgmt;
+    private String testContainerName;
+
+    public synchronized BlobStoreContext getBlobStoreContext() {
+        if (context==null) {
+            if (location==null) {
+                Preconditions.checkNotNull(locationSpec, "locationSpec required for remote object store when location is null");
+                Preconditions.checkNotNull(mgmt, "mgmt required for remote object store when location is null");
+                location = (JcloudsLocation) mgmt.getLocationRegistry().resolve(locationSpec);
+            }
+            
+            String identity = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_IDENTITY), "identity must not be null");
+            String credential = checkNotNull(location.getConfig(LocationConfigKeys.ACCESS_CREDENTIAL), "credential must not be null");
+            String provider = checkNotNull(location.getConfig(LocationConfigKeys.CLOUD_PROVIDER), "provider must not be null");
+            String endpoint = location.getConfig(CloudLocationConfig.CLOUD_ENDPOINT);
+
+            context = JcloudsUtil.newBlobstoreContext(provider, endpoint, identity, credential);
+        }
+        return context;
+    }
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setup() {
+        testContainerName = CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(8);
+        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+        getBlobStoreContext();
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void teardown() {
+        Entities.destroyAll(mgmt);
+    }
+    
+    public void testCreateListDestroyContainer() throws IOException {
+        context.getBlobStore().createContainerInLocation(null, testContainerName);
+        context.getBlobStore().list(testContainerName);
+        PageSet<? extends StorageMetadata> ps = context.getBlobStore().list();
+        assertHasItemNamed(ps, testContainerName);
+        
+        Blob b = context.getBlobStore().blobBuilder("my-blob-1").payload(Streams.newInputStreamWithContents("hello world")).build();
+        context.getBlobStore().putBlob(testContainerName, b);
+        
+        Blob b2 = context.getBlobStore().getBlob(testContainerName, "my-blob-1");
+        Assert.assertEquals(Streams.readFullyString(b2.getPayload().openStream()), "hello world");
+        
+        context.getBlobStore().deleteContainer(testContainerName);
+    }
+    
+    public void testCreateListDestroySimpleDirInContainer() throws IOException {
+        context.getBlobStore().createContainerInLocation(null, testContainerName);
+        context.getBlobStore().createDirectory(testContainerName, "my-dir-1");
+        
+        PageSet<? extends StorageMetadata> ps = context.getBlobStore().list(testContainerName);
+        assertHasItemNamed(ps, "my-dir-1");
+        
+        Blob b = context.getBlobStore().blobBuilder("my-blob-1").payload(Streams.newInputStreamWithContents("hello world")).build();
+        context.getBlobStore().putBlob(testContainerName+"/"+"my-dir-1", b);
+        
+        ps = context.getBlobStore().list(testContainerName, ListContainerOptions.Builder.inDirectory("my-dir-1"));
+        assertHasItemNamed(ps, "my-dir-1/my-blob-1");
+
+        // both these syntaxes work:
+        Blob b2 = context.getBlobStore().getBlob(testContainerName+"/"+"my-dir-1", "my-blob-1");
+        Assert.assertEquals(Streams.readFullyString(b2.getPayload().openStream()), "hello world");
+
+        Blob b3 = context.getBlobStore().getBlob(testContainerName, "my-dir-1"+"/"+"my-blob-1");
+        Assert.assertEquals(Streams.readFullyString(b3.getPayload().openStream()), "hello world");
+
+        context.getBlobStore().deleteContainer(testContainerName);
+    }
+
+    static void assertHasItemNamed(PageSet<? extends StorageMetadata> ps, String name) {
+        if (!hasItemNamed(ps, name))
+            Assert.fail("No item named '"+name+"' in "+ps);
+    }
+
+    static boolean hasItemNamed(PageSet<? extends StorageMetadata> ps, String name) {
+        for (StorageMetadata sm: ps)
+            if (name==null || name.equals(sm.getName())) return true;
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BrooklynMementoPersisterJcloudsObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BrooklynMementoPersisterJcloudsObjectStoreTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BrooklynMementoPersisterJcloudsObjectStoreTest.java
new file mode 100644
index 0000000..a94424e
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/BrooklynMementoPersisterJcloudsObjectStoreTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterTestFixture;
+import org.apache.brooklyn.core.mgmt.persist.jclouds.JcloudsBlobStoreBasedObjectStore;
+import org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.apache.brooklyn.util.time.Duration;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author Andrea Turli
+ */
+@Test(groups={"Live", "Live-sanity"})
+public class BrooklynMementoPersisterJcloudsObjectStoreTest extends BrooklynMementoPersisterTestFixture {
+
+    @Override @BeforeMethod
+    public void setUp() throws Exception { super.setUp(); }
+    
+    protected LocalManagementContext newPersistingManagementContext() {
+        objectStore = new JcloudsBlobStoreBasedObjectStore(
+            BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4));
+        return RebindTestUtils.managementContextBuilder(classLoader, objectStore)
+            .persistPeriod(Duration.ONE_MILLISECOND)
+            .properties(BrooklynProperties.Factory.newDefault())
+            .buildStarted();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testCheckPointAndLoadMemento() throws Exception {
+        super.testCheckPointAndLoadMemento();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testDeleteAndLoadMemento() throws Exception {
+        super.testDeleteAndLoadMemento();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testLoadAndCheckpointRawMemento() throws Exception {
+        super.testLoadAndCheckpointRawMemento();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/EntityToBlobStorePersistencePerformanceTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/EntityToBlobStorePersistencePerformanceTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/EntityToBlobStorePersistencePerformanceTest.java
new file mode 100644
index 0000000..24a38a2
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/EntityToBlobStorePersistencePerformanceTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.mgmt.persist.jclouds.JcloudsBlobStoreBasedObjectStore;
+import org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils;
+import org.apache.brooklyn.core.test.qa.performance.EntityPersistencePerformanceTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+public class EntityToBlobStorePersistencePerformanceTest extends EntityPersistencePerformanceTest {
+
+    private static final String LOCATION_SPEC = BlobStorePersistencePerformanceTest.LOCATION_SPEC;
+    
+    private JcloudsBlobStoreBasedObjectStore objectStore;
+
+    @Override
+    protected LocalManagementContext createOrigManagementContext() {
+        objectStore = new JcloudsBlobStoreBasedObjectStore(LOCATION_SPEC, "EntityToBlobStorePersistencePerformanceTest");
+        
+        return RebindTestUtils.managementContextBuilder(classLoader, objectStore)
+                .forLive(true)
+                .persistPeriodMillis(getPersistPeriodMillis())
+                .buildStarted();
+    }
+
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (objectStore != null) {
+            objectStore.deleteCompletely();
+            objectStore.close();
+        }
+    }
+
+    @Test(groups="Live")
+    @Override
+    public void testManyEntities() throws Exception {
+        super.testManyEntities();
+    }
+    
+    @Test(groups="Live")
+    @Override
+    public void testRapidChanges() throws Exception {
+        super.testRapidChanges();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/HighAvailabilityManagerJcloudsObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/HighAvailabilityManagerJcloudsObjectStoreTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/HighAvailabilityManagerJcloudsObjectStoreTest.java
new file mode 100644
index 0000000..c89064b
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/HighAvailabilityManagerJcloudsObjectStoreTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.ha.HighAvailabilityManagerTestFixture;
+import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore;
+import org.apache.brooklyn.core.mgmt.persist.jclouds.JcloudsBlobStoreBasedObjectStore;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Test(groups={"Live", "Live-sanity"})
+public class HighAvailabilityManagerJcloudsObjectStoreTest extends HighAvailabilityManagerTestFixture {
+
+    protected ManagementContextInternal newLocalManagementContext() {
+        return new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+    }
+
+    @Override @BeforeMethod
+    public void setUp() throws Exception { super.setUp(); }
+    
+    protected PersistenceObjectStore newPersistenceObjectStore() {
+        return new JcloudsBlobStoreBasedObjectStore(
+            BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4));
+    }
+
+    @Test(groups="Live", invocationCount=5) //run fewer times w softlayer... 
+    public void testGetManagementPlaneStatusManyTimes() throws Exception {
+        testGetManagementPlaneStatus();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testDoesNotPromoteIfMasterTimeoutNotExpired() throws Exception {
+        super.testDoesNotPromoteIfMasterTimeoutNotExpired();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testGetManagementPlaneStatus() throws Exception {
+        super.testGetManagementPlaneStatus();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testPromotes() throws Exception {
+        super.testPromotes();
+    }
+
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testGetManagementPlaneSyncStateInfersTimedOutNodeAsFailed() throws Exception {
+        super.testGetManagementPlaneSyncStateInfersTimedOutNodeAsFailed();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testGetManagementPlaneSyncStateDoesNotThrowNpeBeforePersisterSet() throws Exception {
+        super.testGetManagementPlaneSyncStateDoesNotThrowNpeBeforePersisterSet();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsBlobStoreBasedObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsBlobStoreBasedObjectStoreTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsBlobStoreBasedObjectStoreTest.java
new file mode 100644
index 0000000..89c9040
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsBlobStoreBasedObjectStoreTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+
+import java.util.List;
+
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.mgmt.persist.BrooklynPersistenceUtils;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore.StoreObjectAccessor;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Stopwatch;
+
+/**
+ * @author Andrea Turli
+ */
+@Test(groups={"Live", "Live-sanity"})
+public class JcloudsBlobStoreBasedObjectStoreTest {
+
+    private static final Logger log = LoggerFactory.getLogger(JcloudsBlobStoreBasedObjectStoreTest.class);
+    
+    private List<PersistenceObjectStore> objectStores = MutableList.of();;
+    private LocalManagementContext mgmt;
+
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception { 
+        mgmt = LocalManagementContextForTests.builder(true).useDefaultProperties().build();
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        for (PersistenceObjectStore store: objectStores) store.deleteCompletely();
+        Entities.destroyAll(mgmt);
+        objectStores.clear();
+    }
+
+    public PersistenceObjectStore newObjectStore(String spec, String container) {
+        PersistenceObjectStore newObjectStore = BrooklynPersistenceUtils.newPersistenceObjectStore(mgmt, spec, container);
+        objectStores.add(newObjectStore);
+        return newObjectStore;
+    }
+    
+    @Test(groups={"Integration"})
+    public void testLocalhost() throws Exception {
+        doTestWithStore( newObjectStore(null, 
+            BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4)) );
+    }
+    
+    @Test(groups={"Integration"})
+    public void testLocalhostWithSubPathInContainerName() throws Exception {
+        doTestWithStore( newObjectStore(null, 
+            BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4)+"/subpath1/subpath2") );
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    public void testJclouds() throws Exception {
+        doTestWithStore( newObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, 
+            BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4)) );
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    public void testJcloudsWithSubPathInContainerName() throws Exception {
+        doTestWithStore( newObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, 
+            BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4)+"/subpath1/subpath2") );
+    }
+    
+    protected void doTestWithStore(PersistenceObjectStore objectStore) {
+        log.info("testing against "+objectStore.getSummaryName());
+        
+        objectStore.createSubPath("foo");
+        StoreObjectAccessor f = objectStore.newAccessor("foo/file1.txt");
+        Assert.assertFalse(f.exists());
+
+        Stopwatch timer = Stopwatch.createStarted();
+        f.append("Hello world");
+        log.info("created in "+Duration.of(timer));
+        timer.reset();
+        Assert.assertEquals(f.get(), "Hello world");
+        log.info("retrieved in "+Duration.of(timer));
+        Assert.assertTrue(f.exists());
+        
+        timer.reset();
+        List<String> files = objectStore.listContentsWithSubPath("foo");
+        log.info("list retrieved in "+Duration.of(timer)+"; is: "+files);
+        Assert.assertEquals(files, MutableList.of("foo/file1.txt"));
+        
+        f.delete();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsExpect100ContinueTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsExpect100ContinueTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsExpect100ContinueTest.java
new file mode 100644
index 0000000..b78cc48
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsExpect100ContinueTest.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.jclouds.blobstore.BlobStore;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.Blob;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+import org.apache.brooklyn.location.jclouds.JcloudsUtil;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.ByteSource;
+
+public class JcloudsExpect100ContinueTest {
+    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(JcloudsExpect100ContinueTest.class);
+
+    private static String LOCATION_SPEC = BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC;
+    private static final String OBJECT_NAME_PUT = "test_put";
+    private static final String OBJECT_NAME_GET = "test_get";
+    
+    private ManagementContext mgmt;
+    private BlobStoreContext context;
+    private String containerName;
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        // It's important to disable jclouds debug logging
+        // as it "fixes" the issue.
+        setInfoLevel(Logger.ROOT_LOGGER_NAME);
+        setInfoLevel("jclouds");
+        setInfoLevel("org.jclouds");
+
+        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+        JcloudsLocation jcloudsLocation = (JcloudsLocation) mgmt.getLocationRegistry().resolve(LOCATION_SPEC);
+        context = JcloudsUtil.newBlobstoreContext(
+                jcloudsLocation.getProvider(),
+                jcloudsLocation.getEndpoint(),
+                jcloudsLocation.getIdentity(),
+                jcloudsLocation.getCredential());
+        containerName = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(8);
+        context.getBlobStore().createContainerInLocation(null, containerName);
+    }
+
+    private void setInfoLevel(String loggerName) {
+        Logger logger = (Logger) LoggerFactory.getLogger(loggerName);
+        logger.setLevel(Level.INFO);
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        try {
+            context.getBlobStore().deleteContainer(containerName);
+        } catch (Exception e){}
+        context.close();
+        Entities.destroyAll(mgmt);
+    }
+    
+    @Test(groups = "Live", timeOut=240000)
+    public void testPutAfterUnclosedGet() {
+        put(OBJECT_NAME_PUT, getContent());
+        put(OBJECT_NAME_GET, getContent());
+
+        for (int i = 1; i <= 50; i++) {
+            long start = System.currentTimeMillis();
+            get(OBJECT_NAME_GET);
+            long afterGet = System.currentTimeMillis();
+            LOG.info(i + ". GET @" + (afterGet - start));
+
+            System.gc();
+            System.gc();
+            System.gc();
+            sleep(1000);
+
+            // Without excluding Expect: 100-Continue header
+            // the PUT is supposed to block until the server
+            // times out
+
+            long beforePut = System.currentTimeMillis();
+            put(OBJECT_NAME_PUT, getContent());
+            long end = System.currentTimeMillis();
+            LOG.info(i + ". PUT @" + (end - beforePut));
+        }
+    }
+
+    private String getContent() {
+        return "1234567890";
+    }
+
+    private void put(String name, String content) {
+        BlobStore blobStore = context.getBlobStore();
+        byte[] bytes = content.getBytes(Charsets.UTF_8);
+        Blob blob = blobStore.blobBuilder(name)
+                .payload(ByteSource.wrap(bytes))
+                .contentLength(bytes.length)
+                .build();
+        try {
+            blobStore.putBlob(containerName, blob);
+        } catch (Exception e) {
+            LOG.error("PUT " + name + " failed", e);
+        }
+    }
+
+    private Blob get(String name) {
+        try {
+            BlobStore blobStore = context.getBlobStore();
+            return blobStore.getBlob(containerName, name);
+        } catch (Exception e) {
+            LOG.error("GET " + name + " failed", e);
+            return null;
+        }
+    }
+
+    private void sleep(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException e) {
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsObjectStoreAccessorWriterTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsObjectStoreAccessorWriterTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsObjectStoreAccessorWriterTest.java
new file mode 100644
index 0000000..446fd4a
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/core/mgmt/persist/jclouds/JcloudsObjectStoreAccessorWriterTest.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.mgmt.persist.jclouds;
+
+import java.io.IOException;
+
+import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.persist.PersistMode;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceStoreObjectAccessorWriterTestFixture;
+import org.apache.brooklyn.core.mgmt.persist.StoreObjectAccessorLocking;
+import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore.StoreObjectAccessorWithLock;
+import org.apache.brooklyn.core.mgmt.persist.jclouds.JcloudsBlobStoreBasedObjectStore;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.net.Urls;
+import org.apache.brooklyn.util.text.Identifiers;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Test(groups={"Live", "Live-sanity"})
+public class JcloudsObjectStoreAccessorWriterTest extends PersistenceStoreObjectAccessorWriterTestFixture {
+
+    private static final Logger log = LoggerFactory.getLogger(JcloudsObjectStoreAccessorWriterTest.class);
+    
+    private JcloudsBlobStoreBasedObjectStore store;
+    private LocalManagementContextForTests mgmt;
+
+    @Override @BeforeMethod
+    public void setUp() throws Exception {
+        store = new JcloudsBlobStoreBasedObjectStore(
+            BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4));
+        store.injectManagementContext(mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault()));
+        store.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED);
+        super.setUp();
+    }
+
+    @Override @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (mgmt!=null) Entities.destroyAll(mgmt);
+        if (store!=null) store.deleteCompletely();
+    }
+    
+    protected StoreObjectAccessorWithLock newPersistenceStoreObjectAccessor() throws IOException {
+        return newPersistenceStoreObjectAccessor(store, "");
+    }
+    protected StoreObjectAccessorWithLock newPersistenceStoreObjectAccessor(JcloudsBlobStoreBasedObjectStore aStore, String prefix) throws IOException {
+        return new StoreObjectAccessorLocking(aStore.newAccessor(prefix+"sample-file-"+Identifiers.makeRandomId(4)));
+    }
+
+    @Override
+    protected Duration getLastModifiedResolution() {
+        // Not sure what timing resolution is on things like Softlayer's Swift.
+        // It passed for Aled repeatedly on 2014-11-05 with 2 seconds.
+        return Duration.seconds(2);
+    }
+    
+    protected int biggishSize() {
+        // bit smaller since it's actually uploading here!
+        return 10000;
+    }
+
+    /** Tests what happen when we ask the store to be in a container with a path, e.g. path1/path2 
+     * and then the accessor to a file within that (path3/file) --
+     * this does it an emulated way, where the store tracks the subpath so we don't have to */
+    @Test(groups={"Live"})
+    public void testNestedPath1() throws IOException {
+        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+        String path1 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        String path2 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        String path3 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        JcloudsBlobStoreBasedObjectStore store0 = null;
+        try {
+            store0 = new JcloudsBlobStoreBasedObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, Urls.mergePaths(path1, path2));
+            store0.injectManagementContext(mgmt);
+            store0.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED);
+
+            newPersistenceStoreObjectAccessor(store0, path3+"/").put("hello world");
+        } catch (Exception e) {
+            log.warn("Failed with: "+e, e);
+            throw Exceptions.propagate(e);
+            
+        } finally {
+            store0.deleteCompletely();
+            
+            JcloudsBlobStoreBasedObjectStore storeD = new JcloudsBlobStoreBasedObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, path1);
+            storeD.injectManagementContext(mgmt);
+            storeD.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED);
+            storeD.deleteCompletely();
+        }
+    }
+
+    /** Tests what happen when we ask the store to be in a container with a path, e.g. path1/path2 
+     * and then the accessor to a file within that (path3/file) --
+     * this does it the "official" way, where we ask for the store's container
+     * to be the first path segment */
+    @Test(groups={"Live"})
+    public void testNestedPath2() throws IOException {
+        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+        String path1 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        String path2 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        String path3 = BlobStoreTest.CONTAINER_PREFIX+"-"+Identifiers.makeRandomId(4);
+        JcloudsBlobStoreBasedObjectStore store1 = null, store2 = null;
+        try {
+            store1 = new JcloudsBlobStoreBasedObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, 
+                path1);
+            store1.injectManagementContext(mgmt);
+            store1.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED);
+            store1.createSubPath(path2);
+            newPersistenceStoreObjectAccessor(store1, path2+"/"+path3+"/").put("hello world");
+            
+            store2 = new JcloudsBlobStoreBasedObjectStore(BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC, 
+                Urls.mergePaths(path1, path2));
+            store2.injectManagementContext(mgmt);
+            store2.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED);
+
+            newPersistenceStoreObjectAccessor(store2, path3+"/").put("hello world");
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            // this doesn't work
+//            store2.deleteCompletely();
+            // this is how you have to do it:
+            store1.newAccessor(path2).delete();
+            
+            store1.deleteCompletely();
+        }
+    }
+
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testWriteBacklogThenDeleteWillLeaveFileDeleted() throws Exception {
+        super.testWriteBacklogThenDeleteWillLeaveFileDeleted();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testWritesFile() throws Exception {
+        super.testWritesFile();
+    }
+
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testLastModifiedTime() throws Exception {
+        super.testLastModifiedTime();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testExists() throws Exception {
+        super.testExists();
+    }
+    
+    @Test(groups={"Live", "Live-sanity"})
+    @Override
+    public void testAppendsFile() throws Exception {
+        super.testAppendsFile();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
index 0f8518a..ae8e254 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
@@ -34,7 +34,7 @@ import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
index bec2262..d31d7e5 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
@@ -46,9 +46,11 @@ import com.google.common.reflect.TypeToken;
 
 public class BailOutJcloudsLocation extends JcloudsLocation {
 
+    public static final String ERROR_MESSAGE = "early termination for test";
+    public static final RuntimeException BAIL_OUT_FOR_TESTING = new RuntimeException(ERROR_MESSAGE);
+    
     // Don't care which image; not actually provisioning
     private static final String US_EAST_IMAGE_ID = "us-east-1/ami-7d7bfc14";
-    public static final RuntimeException BAIL_OUT_FOR_TESTING = new RuntimeException("early termination for test");
 
     public static final ConfigKey<Function<ConfigBag, Void>> BUILD_TEMPLATE_INTERCEPTOR = ConfigKeys.newConfigKey(
             new TypeToken<Function<ConfigBag, Void>>() {},

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BrooklynMachinePoolLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BrooklynMachinePoolLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BrooklynMachinePoolLiveTest.java
index e379df1..2f6afcb 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BrooklynMachinePoolLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BrooklynMachinePoolLiveTest.java
@@ -26,9 +26,9 @@ import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
 import org.apache.brooklyn.location.jclouds.pool.MachinePoolPredicates;
 import org.apache.brooklyn.location.jclouds.pool.ReusableMachineTemplate;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 
 public class BrooklynMachinePoolLiveTest {
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsAddressesLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsAddressesLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsAddressesLiveTest.java
index 86cd8a4..0d1ed21 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsAddressesLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsAddressesLiveTest.java
@@ -29,8 +29,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.location.basic.Locations;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.core.Locations;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.stream.Streams;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverAwsLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverAwsLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverAwsLiveTest.java
index 755c74a..486f5e7 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverAwsLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverAwsLiveTest.java
@@ -29,7 +29,7 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.location.basic.FixedListMachineProvisioningLocation;
+import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
 import org.apache.brooklyn.util.collections.MutableMap;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverSoftlayerLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverSoftlayerLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverSoftlayerLiveTest.java
index e0ccaec..112e039 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverSoftlayerLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverSoftlayerLiveTest.java
@@ -24,7 +24,7 @@ import static org.testng.Assert.assertTrue;
 import java.util.Set;
 
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.location.basic.FixedListMachineProvisioningLocation;
+import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverTest.java
index 6377d47..6b70773 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverTest.java
@@ -25,7 +25,7 @@ import java.util.NoSuchElementException;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.location.basic.FixedListMachineProvisioningLocation;
+import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationMetadataTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationMetadataTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationMetadataTest.java
index da4979d..ebbec3f 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationMetadataTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationMetadataTest.java
@@ -28,7 +28,7 @@ import org.apache.brooklyn.entity.core.Entities;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.apache.brooklyn.location.basic.LocationConfigKeys;
+import org.apache.brooklyn.location.core.LocationConfigKeys;
 
 import com.google.common.collect.ImmutableSet;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationRebindMachineLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationRebindMachineLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationRebindMachineLiveTest.java
index 006f62e..bf9ad59 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationRebindMachineLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationRebindMachineLiveTest.java
@@ -26,7 +26,7 @@ import static org.testng.Assert.assertTrue;
 import java.net.InetAddress;
 import java.util.Collections;
 
-import org.apache.brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationResolverTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationResolverTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationResolverTest.java
index df9a988..779bf6b 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationResolverTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationResolverTest.java
@@ -30,8 +30,8 @@ import org.apache.brooklyn.core.config.SetConfigKey;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.location.basic.LocationInternal;
 import org.apache.brooklyn.location.cloud.CloudLocationConfig;
+import org.apache.brooklyn.location.core.internal.LocationInternal;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationTest.java
index af47ccc..8f4129d 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationTest.java
@@ -38,6 +38,7 @@ import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.entity.core.Entities;
 import org.apache.brooklyn.location.cloud.names.CustomMachineNamer;
+import org.apache.brooklyn.location.core.LocationConfigKeys;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.config.ConfigBag;
@@ -58,7 +59,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.reflect.TypeToken;
 
-import org.apache.brooklyn.location.basic.LocationConfigKeys;
 import org.apache.brooklyn.location.geo.HostGeoInfo;
 import org.apache.brooklyn.location.jclouds.JcloudsLocation.UserCreation;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLoginLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLoginLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLoginLiveTest.java
index 9b0c873..aa61487 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLoginLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLoginLiveTest.java
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.stream.Streams;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a1ad34d7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/LiveTestEntity.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/LiveTestEntity.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/LiveTestEntity.java
index 98082c9..4bbf385 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/LiveTestEntity.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/LiveTestEntity.java
@@ -29,7 +29,7 @@ import org.apache.brooklyn.core.test.entity.TestEntityImpl;
 import org.apache.brooklyn.entity.lifecycle.Lifecycle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.brooklyn.location.basic.LocationInternal;
+import org.apache.brooklyn.location.core.internal.LocationInternal;
 
 import com.google.common.base.Predicates;
 import com.google.common.base.Throwables;



Mime
View raw message