http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
deleted file mode 100644
index dab6ac2f..0000000
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
+++ /dev/null
@@ -1,96 +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 io.brooklyn.camp.brooklyn.catalog;
-
-import static org.testng.Assert.assertEquals;
-import io.brooklyn.camp.brooklyn.AbstractYamlTest;
-
-import org.testng.Assert;
-import org.testng.TestListenerAdapter;
-import org.testng.TestNG;
-import org.testng.annotations.Test;
-
-import org.apache.brooklyn.catalog.CatalogItem;
-import org.apache.brooklyn.catalog.CatalogItem.CatalogItemType;
-import brooklyn.management.osgi.OsgiStandaloneTest;
-import brooklyn.management.osgi.OsgiTestResources;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-
-
-public class CatalogYamlTemplateTest extends AbstractYamlTest {
-    
-    private static final String SIMPLE_ENTITY_TYPE = 
OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY;
-
-    @Test
-    public void testAddCatalogItem() throws Exception {
-        CatalogItem<?, ?> item = makeItem();
-        assertEquals(item.getCatalogItemType(), CatalogItemType.TEMPLATE);
-        Assert.assertTrue(item.getPlanYaml().indexOf("sample comment")>=0,
-            "YAML did not include original comments; it 
was:\n"+item.getPlanYaml());
-        Assert.assertFalse(item.getPlanYaml().indexOf("description")>=0,
-            "YAML included metadata which should have been excluded; it 
was:\n"+item.getPlanYaml());
-
-        deleteCatalogEntity("t1");
-    }
-
-    @Test
-    public void testAddCatalogItemAndCheckSource() throws Exception {
-        // this will fail with the Eclipse TestNG plugin -- use the static 
main instead to run in eclipse!
-        // see Yamls.KnownClassVersionException for details
-        
-        CatalogItem<?, ?> item = makeItem();
-        Assert.assertTrue(item.getPlanYaml().indexOf("sample comment")>=0,
-            "YAML did not include original comments; it 
was:\n"+item.getPlanYaml());
-        Assert.assertFalse(item.getPlanYaml().indexOf("description")>=0,
-            "YAML included metadata which should have been excluded; it 
was:\n"+item.getPlanYaml());
-
-        deleteCatalogEntity("t1");
-    }
-
-    private CatalogItem<?, ?> makeItem() {
-        
TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), 
OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-        
-        addCatalogItems(
-            "brooklyn.catalog:",
-            "  id: t1",
-            "  item_type: template",
-            "  name: My Catalog App",
-            "  description: My description",
-            "  icon_url: classpath://path/to/myicon.jpg",
-            "  version: " + TEST_VERSION,
-            "  libraries:",
-            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
-            "  item:",
-            "    services:",
-            "    # this sample comment should be included",
-            "    - type: " + SIMPLE_ENTITY_TYPE);
-
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem("t1", 
TEST_VERSION);
-        return item;
-    }
-
-    // convenience for running in eclipse when the TestNG plugin drags in old 
version of snake yaml
-    public static void main(String[] args) {
-        TestListenerAdapter tla = new TestListenerAdapter();
-        TestNG testng = new TestNG();
-        testng.setTestClasses(new Class[] { CatalogYamlTemplateTest.class });
-        testng.addListener(tla);
-        testng.run();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
deleted file mode 100644
index 0249c3f..0000000
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
+++ /dev/null
@@ -1,258 +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 io.brooklyn.camp.brooklyn.catalog;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import io.brooklyn.camp.brooklyn.AbstractYamlTest;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.apache.brooklyn.catalog.BrooklynCatalog;
-import org.apache.brooklyn.catalog.CatalogItem;
-import brooklyn.catalog.CatalogPredicates;
-import brooklyn.catalog.internal.BasicBrooklynCatalog;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.BasicApplication;
-import brooklyn.entity.basic.BasicEntity;
-import brooklyn.entity.basic.ConfigKeys;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-
-public class CatalogYamlVersioningTest extends AbstractYamlTest {
-    
-    private BrooklynCatalog catalog;
-    
-    @BeforeMethod(alwaysRun = true)
-    public void setUp() {
-        super.setUp();
-        catalog = mgmt().getCatalog();
-    }
-
-    @Test
-    public void testAddItem() {
-        String symbolicName = "sampleId";
-        String version = "0.1.0";
-        addCatalogEntity(symbolicName, version);
-        assertSingleCatalogItem(symbolicName, version);
-    }
-
-    @Test
-    public void testAddUnversionedItem() {
-        String symbolicName = "sampleId";
-        addCatalogEntity(symbolicName, null);
-        assertSingleCatalogItem(symbolicName, BasicBrooklynCatalog.NO_VERSION);
-    }
-
-    @Test
-    public void testAddSameVersionFailsWhenIconIsDifferent() {
-        String symbolicName = "sampleId";
-        String version = "0.1.0";
-        addCatalogEntity(symbolicName, version);
-        addCatalogEntity(symbolicName, version);
-        try {
-            addCatalogEntity(symbolicName, version, 
BasicEntity.class.getName(), "classpath:/another/icon.png");
-            fail("Expected to fail");
-        } catch (IllegalStateException e) {
-            assertEquals(e.getMessage(), "Updating existing catalog entries is 
forbidden: " + symbolicName + ":" + version + ". Use forceUpdate argument to 
override.");
-        }
-    }
-    
-    @Test
-    public void testAddSameVersionForce() {
-        String symbolicName = "sampleId";
-        String version = "0.1.0";
-        addCatalogEntity(symbolicName, version);
-        forceCatalogUpdate();
-        String expectedType = "brooklyn.entity.basic.BasicApplication";
-        addCatalogEntity(symbolicName, version, expectedType);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, version);
-        assertTrue(item.getPlanYaml().contains(expectedType), "Version not 
updated");
-    }
-    
-    @Test
-    public void testGetLatest() {
-        String symbolicName = "sampleId";
-        String v1 = "0.1.0";
-        String v2 = "0.2.0";
-        addCatalogEntity(symbolicName, v1);
-        addCatalogEntity(symbolicName, v2);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, 
BasicBrooklynCatalog.DEFAULT_VERSION);
-        assertEquals(item.getVersion(), v2);
-    }
-    
-    @Test
-    public void testGetLatestStable() {
-        String symbolicName = "sampleId";
-        String v1 = "0.1.0";
-        String v2 = "0.2.0-SNAPSHOT";
-        addCatalogEntity(symbolicName, v1);
-        addCatalogEntity(symbolicName, v2);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, 
BasicBrooklynCatalog.DEFAULT_VERSION);
-        assertEquals(item.getVersion(), v1);
-    }
-
-    @Test
-    public void testDelete() {
-        String symbolicName = "sampleId";
-        String version = "0.1.0";
-        addCatalogEntity(symbolicName, version);
-        
assertTrue(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-        catalog.deleteCatalogItem(symbolicName, version);
-        
assertFalse(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-    }
-    
-    @Test
-    public void testDeleteDefault() {
-        String symbolicName = "sampleId";
-        addCatalogEntity(symbolicName, null);
-        
assertTrue(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-        catalog.deleteCatalogItem(symbolicName, 
BasicBrooklynCatalog.NO_VERSION);
-        
assertFalse(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-    }
-    
-    @Test
-    public void testList() {
-        String symbolicName = "sampleId";
-        String v1 = "0.1.0";
-        String v2 = "0.2.0-SNAPSHOT";
-        addCatalogEntity(symbolicName, v1);
-        addCatalogEntity(symbolicName, v2);
-        Iterable<CatalogItem<Object, Object>> items = 
catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName)));
-        assertEquals(Iterables.size(items), 2);
-    }
-    
-    @Test
-    public void testVersionedReference() throws Exception {
-        String symbolicName = "sampleId";
-        String parentName = "parentId";
-        String v1 = "0.1.0";
-        String v2 = "0.2.0";
-        String expectedType = BasicApplication.class.getName();
-
-        addCatalogEntity(symbolicName, v1, expectedType);
-        addCatalogEntity(symbolicName, v2);
-        addCatalogEntity(parentName, v1, symbolicName + ":" + v1);
-
-        Entity app = createAndStartApplication(
-                "services:",
-                "- type: " + parentName + ":" + v1);
-
-        assertEquals(app.getEntityType().getName(), expectedType);
-    }
-
-    @Test
-    public void testUnversionedReference() throws Exception {
-        String symbolicName = "sampleId";
-        String parentName = "parentId";
-        String v1 = "0.1.0";
-        String v2 = "0.2.0";
-        String expectedType = BasicApplication.class.getName();
-
-        addCatalogEntity(symbolicName, v1);
-        addCatalogEntity(symbolicName, v2, expectedType);
-        addCatalogEntity(parentName, v1, symbolicName);
-
-        Entity app = createAndStartApplication(
-                "services:",
-                "- type: " + parentName + ":" + v1);
-
-        assertEquals(app.getEntityType().getName(), expectedType);
-    }
-
-    private void doTestVersionedReferenceJustAdded(boolean 
isVersionImplicitSyntax) throws Exception {
-        addCatalogItems(            "brooklyn.catalog:",
-            "  version: 0.9",
-            "  items:",
-            "  - id: referrent",
-            "    item:",
-            "      type: "+BasicEntity.class.getName(),
-            "  - id: referrent",
-            "    version: 1.1",
-            "    item:",
-            "      type: "+BasicEntity.class.getName(),
-            "      brooklyn.config: { foo: bar }",
-            "  - id: referrer",
-            "    version: 1.0",
-            "    item:",
-            (isVersionImplicitSyntax ? 
-                "      type: referrent:1.1" :
-                "      type: referrent\n" +
-                "      version: 1.1"));
-        
-        Iterable<CatalogItem<Object, Object>> items = 
catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo("referrer")));
-        Assert.assertEquals(Iterables.size(items), 1, "Wrong number of: 
"+items);
-        CatalogItem<Object, Object> item = Iterables.getOnlyElement(items);
-        Assert.assertEquals(item.getVersion(), "1.0");
-        
-        Entity app = createAndStartApplication(
-            "services:",
-            (isVersionImplicitSyntax ? 
-                "- type: referrer:1.0" :
-                "- type: referrer\n" +
-                "  version: 1.0") );
-        Entity child = Iterables.getOnlyElement(app.getChildren());
-        Assert.assertTrue(child instanceof BasicEntity, "Wrong child: "+child);
-        
Assert.assertEquals(child.getConfig(ConfigKeys.newStringConfigKey("foo")), 
"bar");
-    }
-
-    @Test
-    public void testVersionedReferenceJustAddedExplicitVersion() throws 
Exception {
-        doTestVersionedReferenceJustAdded(false);
-    }
-    
-    @Test
-    public void testVersionedReferenceJustAddedImplicitVersionSyntax() throws 
Exception {
-        doTestVersionedReferenceJustAdded(true);
-    }
-    
-    private void assertSingleCatalogItem(String symbolicName, String version) {
-        Iterable<CatalogItem<Object, Object>> items = 
catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName)));
-        CatalogItem<Object, Object> item = Iterables.getOnlyElement(items);
-        assertEquals(item.getSymbolicName(), symbolicName);
-        assertEquals(item.getVersion(), version);
-    }
-    
-    private void addCatalogEntity(String symbolicName, String version) {
-        addCatalogEntity(symbolicName, version, BasicEntity.class.getName());
-    }
-
-    private void addCatalogEntity(String symbolicName, String version, String 
type) {
-        addCatalogEntity(symbolicName, version, type, 
"classpath://path/to/myicon.jpg");
-    }
-    
-    private void addCatalogEntity(String symbolicName, String version, String 
type, String iconUrl) {
-        addCatalogItems(
-            "brooklyn.catalog:",
-            "  id: " + symbolicName,
-            "  name: My Catalog App",
-            "  description: My description",
-            "  icon_url: "+iconUrl,
-            (version != null ? "  version: " + version : ""),
-            "",
-            "services:",
-            "- type: " + type);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
deleted file mode 100644
index 46347c5..0000000
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
+++ /dev/null
@@ -1,27 +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 io.brooklyn.camp.brooklyn.catalog;
-
-import brooklyn.entity.basic.BasicApplication;
-import brooklyn.entity.proxying.ImplementedBy;
-
-@ImplementedBy(TestBasicAppImpl.class)
-public interface TestBasicApp extends BasicApplication {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
deleted file mode 100644
index 952ccd9..0000000
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
+++ /dev/null
@@ -1,24 +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 io.brooklyn.camp.brooklyn.catalog;
-
-import brooklyn.entity.basic.BasicApplicationImpl;
-
-public class TestBasicAppImpl extends BasicApplicationImpl implements 
TestBasicApp {
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/spi/dsl/DslParseTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/spi/dsl/DslParseTest.java 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/spi/dsl/DslParseTest.java
deleted file mode 100644
index e701318..0000000
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/spi/dsl/DslParseTest.java
+++ /dev/null
@@ -1,79 +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 io.brooklyn.camp.brooklyn.spi.dsl;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import io.brooklyn.camp.brooklyn.spi.dsl.parse.DslParser;
-import io.brooklyn.camp.brooklyn.spi.dsl.parse.FunctionWithArgs;
-import io.brooklyn.camp.brooklyn.spi.dsl.parse.QuotedString;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.testng.annotations.Test;
-
-import brooklyn.util.text.StringEscapes.JavaStringEscapes;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-@Test
-public class DslParseTest {
-
-    public void testParseString() {
-        assertEquals(new DslParser("\"hello world\"").parse(), new 
QuotedString(JavaStringEscapes.wrapJavaString("hello world")));
-    }
-
-    public void testParseNoArgFunction() {
-        Object fx = new DslParser("f()").parse();
-        fx = Iterables.getOnlyElement( (List<?>)fx );
-        assertEquals( ((FunctionWithArgs)fx).getFunction(), "f" );
-        assertEquals( ((FunctionWithArgs)fx).getArgs(), ImmutableList.of());
-    }
-    
-    public void testParseOneArgFunction() {
-        Object fx = new DslParser("f(\"x\")").parse();
-        fx = Iterables.getOnlyElement( (List<?>)fx );
-        assertEquals( ((FunctionWithArgs)fx).getFunction(), "f" );
-        assertEquals( ((FunctionWithArgs)fx).getArgs(), Arrays.asList(new 
QuotedString("\"x\"")) );
-    }
-    
-    public void testParseMultiArgMultiTypeFunction() {
-        // TODO Parsing "f(\"x\", 1)" fails, because it interprets 1 as a 
function rather than a number. Is that expected?
-        Object fx = new DslParser("f(\"x\", \"y\")").parse();
-        fx = Iterables.getOnlyElement( (List<?>)fx );
-        assertEquals( ((FunctionWithArgs)fx).getFunction(), "f" );
-        assertEquals( ((FunctionWithArgs)fx).getArgs(), ImmutableList.of(new 
QuotedString("\"x\""), new QuotedString("\"y\"")));
-    }
-
-    
-    public void testParseFunctionChain() {
-        Object fx = new DslParser("f(\"x\").g()").parse();
-        assertTrue(((List<?>)fx).size() == 2, ""+fx);
-        Object fx1 = ((List<?>)fx).get(0);
-        Object fx2 = ((List<?>)fx).get(1);
-        assertEquals( ((FunctionWithArgs)fx1).getFunction(), "f" );
-        assertEquals( ((FunctionWithArgs)fx1).getArgs(), ImmutableList.of(new 
QuotedString("\"x\"")) );
-        assertEquals( ((FunctionWithArgs)fx2).getFunction(), "g" );
-        assertTrue( ((FunctionWithArgs)fx2).getArgs().isEmpty() );
-    }
-    
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
new file mode 100644
index 0000000..9b3c855
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
@@ -0,0 +1,208 @@
+/*
+ * 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.camp.brooklyn;
+
+import io.brooklyn.camp.spi.Assembly;
+import io.brooklyn.camp.spi.AssemblyTemplate;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Set;
+
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatform;
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherNoServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+import brooklyn.catalog.internal.CatalogUtils;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BrooklynTaskTags;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.rebind.RebindOptions;
+import brooklyn.entity.rebind.RebindTestFixture;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.Task;
+import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.config.ConfigBag;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+public class AbstractYamlRebindTest extends 
RebindTestFixture<StartableApplication> {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(AbstractYamlTest.class);
+    protected static final String TEST_VERSION = "0.1.2";
+
+    protected BrooklynCampPlatform platform;
+    protected BrooklynCampPlatformLauncherNoServer launcher;
+    private boolean forceUpdate;
+    
+    @BeforeMethod(alwaysRun = true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        launcher = new BrooklynCampPlatformLauncherNoServer() {
+            @Override
+            protected LocalManagementContext newMgmtContext() {
+                return (LocalManagementContext) mgmt();
+            }
+        };
+        launcher.launch();
+        platform = launcher.getCampPlatform();
+    }
+
+    @AfterMethod(alwaysRun = true)
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            super.tearDown();
+        } finally {
+            if (launcher != null) launcher.stopServers();
+        }
+    }
+
+    protected StartableApplication rebind(RebindOptions options) throws 
Exception {
+        StartableApplication result = super.rebind(options);
+        if (launcher != null) {
+            launcher.stopServers();
+            launcher = new BrooklynCampPlatformLauncherNoServer() {
+                @Override
+                protected LocalManagementContext newMgmtContext() {
+                    return (LocalManagementContext) mgmt();
+                }
+            };
+            launcher.launch();
+            platform = launcher.getCampPlatform();
+        }
+        return result;
+    }
+    
+    @Override
+    protected StartableApplication createApp() {
+        return null;
+    }
+
+    protected ManagementContext mgmt() {
+        return (newManagementContext != null) ? newManagementContext : 
origManagementContext;
+    }
+    
+    ///////////////////////////////////////////////////
+    // TODO code below is duplicate of AbstractYamlTest
+    ///////////////////////////////////////////////////
+    
+    protected void waitForApplicationTasks(Entity app) {
+        Set<Task<?>> tasks = 
BrooklynTaskTags.getTasksInEntityContext(origManagementContext.getExecutionManager(),
 app);
+        getLogger().info("Waiting on " + tasks.size() + " task(s)");
+        for (Task<?> t : tasks) {
+            t.blockUntilEnded();
+        }
+    }
+
+    protected Reader loadYaml(String yamlFileName, String ...extraLines) 
throws Exception {
+        String input = new 
ResourceUtils(this).getResourceAsString(yamlFileName).trim();
+        StringBuilder builder = new StringBuilder(input);
+        for (String l: extraLines)
+            builder.append("\n").append(l);
+        return new StringReader(builder.toString());
+    }
+    
+    protected Entity createAndStartApplication(String... multiLineYaml) throws 
Exception {
+        return createAndStartApplication(joinLines(multiLineYaml));
+    }
+    
+    protected Entity createAndStartApplication(String input) throws Exception {
+        return createAndStartApplication(new StringReader(input));
+    }
+
+    protected Entity createAndStartApplication(Reader input) throws Exception {
+        AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
+        Assembly assembly;
+        try {
+            assembly = at.getInstantiator().newInstance().instantiate(at, 
platform);
+        } catch (Exception e) {
+            getLogger().warn("Unable to instantiate " + at + " (rethrowing): " 
+ e);
+            throw e;
+        }
+        getLogger().info("Test - created " + assembly);
+        final Entity app = 
origManagementContext.getEntityManager().getEntity(assembly.getId());
+        getLogger().info("App - " + app);
+        
+        // wait for app to have started
+        Set<Task<?>> tasks = 
origManagementContext.getExecutionManager().getTasksWithAllTags(ImmutableList.of(
+                BrooklynTaskTags.EFFECTOR_TAG, 
+                BrooklynTaskTags.tagForContextEntity(app), 
+                BrooklynTaskTags.tagForEffectorCall(app, "start", 
ConfigBag.newInstance(ImmutableMap.of("locations", ImmutableMap.of())))));
+        Iterables.getOnlyElement(tasks).get();
+        
+        return app;
+    }
+
+    protected Entity createStartWaitAndLogApplication(Reader input) throws 
Exception {
+        Entity app = createAndStartApplication(input);
+        waitForApplicationTasks(app);
+
+        getLogger().info("App started:");
+        Entities.dumpInfo(app);
+        
+        return app;
+    }
+
+    protected void addCatalogItems(Iterable<String> catalogYaml) {
+        addCatalogItems(joinLines(catalogYaml));
+    }
+
+    protected void addCatalogItems(String... catalogYaml) {
+        addCatalogItems(joinLines(catalogYaml));
+    }
+
+    protected void addCatalogItems(String catalogYaml) {
+        mgmt().getCatalog().addItems(catalogYaml, forceUpdate);
+    }
+
+    protected void deleteCatalogEntity(String catalogItem) {
+        mgmt().getCatalog().deleteCatalogItem(catalogItem, TEST_VERSION);
+    }
+
+    protected Logger getLogger() {
+        return LOG;
+    }
+
+    private String joinLines(Iterable<String> catalogYaml) {
+        return Joiner.on("\n").join(catalogYaml);
+    }
+
+    private String joinLines(String[] catalogYaml) {
+        return Joiner.on("\n").join(catalogYaml);
+    }
+
+    protected String ver(String id) {
+        return CatalogUtils.getVersionedId(id, TEST_VERSION);
+    }
+
+    public void forceCatalogUpdate() {
+        forceUpdate = true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
new file mode 100644
index 0000000..e222b9f
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
@@ -0,0 +1,184 @@
+/*
+ * 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.camp.brooklyn;
+
+import io.brooklyn.camp.spi.Assembly;
+import io.brooklyn.camp.spi.AssemblyTemplate;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Set;
+
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatform;
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherNoServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+import brooklyn.catalog.internal.CatalogUtils;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BrooklynTaskTags;
+import brooklyn.entity.basic.Entities;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.Task;
+import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.test.entity.LocalManagementContextForTests;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.config.ConfigBag;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+public abstract class AbstractYamlTest {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(AbstractYamlTest.class);
+    protected static final String TEST_VERSION = "0.1.2";
+
+    private ManagementContext brooklynMgmt;
+    protected BrooklynCampPlatform platform;
+    protected BrooklynCampPlatformLauncherNoServer launcher;
+    private boolean forceUpdate;
+    
+    public AbstractYamlTest() {
+        super();
+    }
+
+    protected ManagementContext mgmt() { return brooklynMgmt; }
+    
+    @BeforeMethod(alwaysRun = true)
+    public void setUp() {
+        forceUpdate = false;
+        launcher = new BrooklynCampPlatformLauncherNoServer() {
+            @Override
+            protected LocalManagementContext newMgmtContext() {
+                return newTestManagementContext();
+            }
+        };
+        launcher.launch();
+        brooklynMgmt = launcher.getBrooklynMgmt();
+        platform = launcher.getCampPlatform();
+    }
+
+    protected LocalManagementContext newTestManagementContext() {
+        // TODO they don't all need osgi, just a few do, so could speed it up 
by specifying when they do
+        return LocalManagementContextForTests.newInstanceWithOsgi();
+    }
+    
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() {
+        if (brooklynMgmt != null) Entities.destroyAll(brooklynMgmt);
+        if (launcher != null) launcher.stopServers();
+    }
+
+    protected void waitForApplicationTasks(Entity app) {
+        Set<Task<?>> tasks = 
BrooklynTaskTags.getTasksInEntityContext(brooklynMgmt.getExecutionManager(), 
app);
+        getLogger().info("Waiting on " + tasks.size() + " task(s)");
+        for (Task<?> t : tasks) {
+            t.blockUntilEnded();
+        }
+    }
+
+    protected Reader loadYaml(String yamlFileName, String ...extraLines) 
throws Exception {
+        String input = new 
ResourceUtils(this).getResourceAsString(yamlFileName).trim();
+        StringBuilder builder = new StringBuilder(input);
+        for (String l: extraLines)
+            builder.append("\n").append(l);
+        return new StringReader(builder.toString());
+    }
+    
+    protected Entity createAndStartApplication(String... multiLineYaml) throws 
Exception {
+        return createAndStartApplication(joinLines(multiLineYaml));
+    }
+    
+    protected Entity createAndStartApplication(String input) throws Exception {
+        return createAndStartApplication(new StringReader(input));
+    }
+
+    protected Entity createAndStartApplication(Reader input) throws Exception {
+        AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
+        Assembly assembly;
+        try {
+            assembly = at.getInstantiator().newInstance().instantiate(at, 
platform);
+        } catch (Exception e) {
+            getLogger().warn("Unable to instantiate " + at + " (rethrowing): " 
+ e);
+            throw e;
+        }
+        getLogger().info("Test - created " + assembly);
+        final Entity app = 
brooklynMgmt.getEntityManager().getEntity(assembly.getId());
+        getLogger().info("App - " + app);
+        
+        // wait for app to have started
+        Set<Task<?>> tasks = 
brooklynMgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of(
+                BrooklynTaskTags.EFFECTOR_TAG, 
+                BrooklynTaskTags.tagForContextEntity(app), 
+                BrooklynTaskTags.tagForEffectorCall(app, "start", 
ConfigBag.newInstance(ImmutableMap.of("locations", ImmutableMap.of())))));
+        Iterables.getOnlyElement(tasks).get();
+        
+        return app;
+    }
+
+    protected Entity createStartWaitAndLogApplication(Reader input) throws 
Exception {
+        Entity app = createAndStartApplication(input);
+        waitForApplicationTasks(app);
+
+        getLogger().info("App started:");
+        Entities.dumpInfo(app);
+        
+        return app;
+    }
+
+    protected void addCatalogItems(Iterable<String> catalogYaml) {
+        addCatalogItems(joinLines(catalogYaml));
+    }
+
+    protected void addCatalogItems(String... catalogYaml) {
+        addCatalogItems(joinLines(catalogYaml));
+    }
+
+    protected void addCatalogItems(String catalogYaml) {
+        mgmt().getCatalog().addItems(catalogYaml, forceUpdate);
+    }
+
+    protected void deleteCatalogEntity(String catalogItem) {
+        mgmt().getCatalog().deleteCatalogItem(catalogItem, TEST_VERSION);
+    }
+
+    protected Logger getLogger() {
+        return LOG;
+    }
+
+    private String joinLines(Iterable<String> catalogYaml) {
+        return Joiner.on("\n").join(catalogYaml);
+    }
+
+    private String joinLines(String[] catalogYaml) {
+        return Joiner.on("\n").join(catalogYaml);
+    }
+
+    protected String ver(String id) {
+        return CatalogUtils.getVersionedId(id, TEST_VERSION);
+    }
+
+    public void forceCatalogUpdate() {
+        forceUpdate = true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AppYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AppYamlTest.java 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AppYamlTest.java
new file mode 100644
index 0000000..44d9780
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/AppYamlTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.camp.brooklyn;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.StringReader;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.api.client.repackaged.com.google.common.base.Joiner;
+import com.google.common.collect.Iterables;
+
+import brooklyn.entity.basic.BasicApplication;
+import brooklyn.test.entity.TestApplication;
+import brooklyn.test.entity.TestEntity;
+
+@Test
+public class AppYamlTest extends AbstractYamlTest {
+    private static final Logger log = 
LoggerFactory.getLogger(AppYamlTest.class);
+
+    @Test
+    public void testAutoWrapsEntityInApp() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestEntity");
+        
+        BasicApplication app = (BasicApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        @SuppressWarnings("unused")
+        TestEntity entity = (TestEntity) 
Iterables.getOnlyElement(app.getChildren());
+    }
+    
+    @Test
+    public void testDoesNotAutoWrapApp() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestApplication");
+        
+        TestApplication app = (TestApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        assertTrue(app.getChildren().isEmpty());
+    }
+    
+    @Test
+    public void testWrapsAppIfNameAtTopLevelAndOnApp() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "name: myTopLevelName",
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestApplication",
+                "  name: myEntityName");
+        
+        BasicApplication app = (BasicApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        TestApplication entity = (TestApplication) 
Iterables.getOnlyElement(app.getChildren());
+        assertEquals(app.getDisplayName(), "myTopLevelName");
+        assertEquals(entity.getDisplayName(), "myEntityName");
+    }
+    
+    @Test
+    public void testDoesNotWrapAppIfNoConflictingNameOnApp() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "name: myTopLevelName",
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestApplication");
+        
+        TestApplication app = (TestApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        assertTrue(app.getChildren().isEmpty());
+        assertEquals(app.getDisplayName(), "myTopLevelName");
+    }
+    
+    @Test
+    public void testDoesNotWrapAppWithDefaultDisplayName() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "name: myTopLevelName",
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestApplication",
+                "  brooklyn.config:",
+                "    defaultDisplayName: myDefaultEntityName");
+        
+        TestApplication app = (TestApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        assertTrue(app.getChildren().isEmpty());
+        assertEquals(app.getDisplayName(), "myTopLevelName");
+    }
+    
+    @Test
+    public void testUsesDefaultDisplayNameIfNoOther() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- serviceType: brooklyn.test.entity.TestApplication",
+                "  brooklyn.config:",
+                "    defaultDisplayName: myDefaultEntityName");
+        
+        TestApplication app = (TestApplication) 
createStartWaitAndLogApplication(new StringReader(yaml));
+        assertTrue(app.getChildren().isEmpty());
+        assertEquals(app.getDisplayName(), "myDefaultEntityName");
+    }
+    
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/BrooklynYamlTypeInstantiatorTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/BrooklynYamlTypeInstantiatorTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/BrooklynYamlTypeInstantiatorTest.java
new file mode 100644
index 0000000..b65f042
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/BrooklynYamlTypeInstantiatorTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.camp.brooklyn;
+
+import 
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator;
+import 
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator.Factory;
+import 
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator.InstantiatorFromKey;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.management.classloading.BrooklynClassLoadingContext;
+import brooklyn.management.classloading.JavaBrooklynClassLoadingContext;
+import brooklyn.policy.Policy;
+import brooklyn.policy.ha.ServiceRestarter;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.javalang.JavaClassNames;
+import brooklyn.util.time.Duration;
+
+public class BrooklynYamlTypeInstantiatorTest extends AbstractYamlTest {
+
+    protected BrooklynClassLoadingContext loader() {
+        return JavaBrooklynClassLoadingContext.create(mgmt());
+    }
+    
+    @Test
+    public void testLoadPolicySpecProgrammatically() {
+        Factory loader = new BrooklynYamlTypeInstantiator.Factory(loader(), 
"test:"+JavaClassNames.niceClassAndMethod());
+        InstantiatorFromKey decoL = loader.from(MutableMap.of("some_type", 
ServiceRestarter.class.getName())).prefix("some");
+        
+        Assert.assertTrue(decoL.getConfigMap().isEmpty());
+        Assert.assertEquals(decoL.getTypeName().get(), 
ServiceRestarter.class.getName());
+        Assert.assertEquals(decoL.getType(), ServiceRestarter.class);
+        
+        Object sl1 = decoL.newInstance();
+        Assert.assertTrue(sl1 instanceof ServiceRestarter);
+        
+        Policy sl2 = decoL.newInstance(Policy.class);
+        Assert.assertTrue(sl2 instanceof ServiceRestarter);
+    }
+    
+    @Test
+    public void testLoadPolicySpecWithBrooklynConfig() {
+        Factory loader = new BrooklynYamlTypeInstantiator.Factory(loader(), 
"test:"+JavaClassNames.niceClassAndMethod());
+        InstantiatorFromKey decoL = loader.from(MutableMap.of("some_type", 
ServiceRestarter.class.getName(),
+            "brooklyn.config", 
MutableMap.of("failOnRecurringFailuresInThisDuration", 
Duration.seconds(42)))).prefix("some");
+        Policy sl2 = decoL.newInstance(Policy.class);
+        
Assert.assertEquals(sl2.getConfig(ServiceRestarter.FAIL_ON_RECURRING_FAILURES_IN_THIS_DURATION).toSeconds(),
 42);
+    }
+
+    @Test(groups = "WIP")
+    public void testLoadPolicySpecWithFlag() {
+        Factory loader = new BrooklynYamlTypeInstantiator.Factory(loader(), 
"test:"+JavaClassNames.niceClassAndMethod());
+        InstantiatorFromKey decoL = loader.from(MutableMap.of("some_type", 
ServiceRestarter.class.getName(),
+            "failOnRecurringFailuresInThisDuration", 
Duration.seconds(42))).prefix("some");
+        Policy sl2 = decoL.newInstance(Policy.class);
+        
Assert.assertEquals(sl2.getConfig(ServiceRestarter.FAIL_ON_RECURRING_FAILURES_IN_THIS_DURATION).toSeconds(),
 42);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ByonLocationsYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ByonLocationsYamlTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ByonLocationsYamlTest.java
new file mode 100644
index 0000000..4fe40c8
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ByonLocationsYamlTest.java
@@ -0,0 +1,281 @@
+/*
+ * 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.camp.brooklyn;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import java.io.StringReader;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.api.client.repackaged.com.google.common.base.Joiner;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.DoNothingSoftwareProcess;
+import brooklyn.entity.basic.Entities;
+import brooklyn.location.MachineLocation;
+import brooklyn.location.access.PortForwardManager;
+import brooklyn.location.basic.FixedListMachineProvisioningLocation;
+import brooklyn.location.basic.LocationPredicates;
+import brooklyn.location.basic.Machines;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.location.basic.WinRmMachineLocation;
+import brooklyn.location.cloud.CloudLocationConfig;
+import brooklyn.test.Asserts;
+import brooklyn.util.net.UserAndHostAndPort;
+
+public class ByonLocationsYamlTest extends AbstractYamlTest {
+    private static final Logger log = 
LoggerFactory.getLogger(ByonLocationsYamlTest.class);
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testByonSpec() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location: byon(user=myuser,mykey=myval,hosts=\"1.1.1.1\")",
+                "services:",
+                "- serviceType: brooklyn.entity.basic.BasicApplication");
+        
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        FixedListMachineProvisioningLocation<SshMachineLocation> loc = 
(FixedListMachineProvisioningLocation<SshMachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        
+        Set<SshMachineLocation> machines = loc.getAvailable();
+        SshMachineLocation machine = Iterables.getOnlyElement(machines);
+        assertMachine(machine, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.1",  22), ImmutableMap.of("mykey", "myval"));
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testByonMachine() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location:",
+                "  byon:",
+                "    hosts:",
+                "    - ssh: 1.1.1.1:8022",
+                "      privateAddresses: [10.0.0.1]",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval",
+                "services:",
+                "- serviceType: brooklyn.entity.basic.BasicApplication");
+        
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        FixedListMachineProvisioningLocation<SshMachineLocation> loc = 
(FixedListMachineProvisioningLocation<SshMachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        
+        Set<SshMachineLocation> machines = loc.getAvailable();
+        SshMachineLocation machine = Iterables.getOnlyElement(machines);
+        assertMachine(machine, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.1",  8022), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval"));
+        assertEquals(machine.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.1"));
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testByonWindowsMachine() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location:",
+                "  byon:",
+                "    hosts:",
+                "    - winrm: 1.1.1.1:8985",
+                "      privateAddresses: [10.0.0.1]",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval",
+                "      osfamily: windows",
+                "services:",
+                "- serviceType: brooklyn.entity.basic.BasicApplication");
+        
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        FixedListMachineProvisioningLocation<WinRmMachineLocation> loc = 
(FixedListMachineProvisioningLocation<WinRmMachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        
+        Set<WinRmMachineLocation> machines = loc.getAvailable();
+        WinRmMachineLocation machine = Iterables.getOnlyElement(machines);
+        assertMachine(machine, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.1",  8985), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval"));
+        assertEquals(machine.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.1"));
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testByonMultiMachine() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location:",
+                "  byon:",
+                "    hosts:",
+                "    - ssh: 1.1.1.1:8022",
+                "      privateAddresses: [10.0.0.1]",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval1",
+                "    - ssh: 1.1.1.2:8022",
+                "      privateAddresses: [10.0.0.2]",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval2",
+                "    - winrm: 1.1.1.3:8985",
+                "      privateAddresses: [10.0.0.3]",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval3",
+                "      osfamily: windows",
+                "services:",
+                "- serviceType: brooklyn.entity.basic.BasicApplication");
+        
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        FixedListMachineProvisioningLocation<MachineLocation> loc = 
(FixedListMachineProvisioningLocation<MachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        
+        Set<MachineLocation> machines = loc.getAvailable();
+        assertEquals(machines.size(), 3, "machines="+machines);
+        SshMachineLocation machine1 = (SshMachineLocation) 
Iterables.find(machines, 
LocationPredicates.configEqualTo(ConfigKeys.newStringConfigKey("mykey"), 
"myval1"));
+        SshMachineLocation machine2 = (SshMachineLocation) 
Iterables.find(machines, 
LocationPredicates.configEqualTo(ConfigKeys.newStringConfigKey("mykey"), 
"myval2"));
+        WinRmMachineLocation machine3 = (WinRmMachineLocation) 
Iterables.find(machines, Predicates.instanceOf(WinRmMachineLocation.class));
+
+        assertMachine(machine1, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.1",  8022), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval1"));
+        assertEquals(machine1.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.1"));
+
+        assertMachine(machine2, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.2",  8022), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval2"));
+        assertEquals(machine2.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.2"));
+
+        assertMachine(machine3, UserAndHostAndPort.fromParts("myuser", 
"1.1.1.3",  8985), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval3"));
+        assertEquals(machine3.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.3"));
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testByonPortMapping() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location:",
+                "  byon:",
+                "    hosts:",
+                "    - ssh: 1.1.1.1:22",
+                "      privateAddresses: [10.0.0.1]",
+                "      tcpPortMappings: {22: \"83.222.229.1:12001\", 8080: 
\"83.222.229.1:12002\"}",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval1",
+                "    - winrm: 1.1.1.2:8985",
+                "      privateAddresses: [10.0.0.2]",
+                "      tcpPortMappings: {8985: \"83.222.229.2:12003\", 8080: 
\"83.222.229.2:12004\"}",
+                "      password: mypassword",
+                "      user: myuser",
+                "      mykey: myval2",
+                "      osfamily: windows",
+                "services:",
+                "- serviceType: brooklyn.entity.basic.BasicApplication");
+
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        FixedListMachineProvisioningLocation<MachineLocation> loc = 
(FixedListMachineProvisioningLocation<MachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        PortForwardManager pfm = (PortForwardManager) 
mgmt().getLocationRegistry().resolve("portForwardManager(scope=global)");
+        
+        Set<MachineLocation> machines = loc.getAvailable();
+        assertEquals(machines.size(), 2, "machines="+machines);
+        SshMachineLocation machine1 = (SshMachineLocation) 
Iterables.find(machines, 
LocationPredicates.configEqualTo(ConfigKeys.newStringConfigKey("mykey"), 
"myval1"));
+        WinRmMachineLocation machine2 = (WinRmMachineLocation) 
Iterables.find(machines, Predicates.instanceOf(WinRmMachineLocation.class));
+
+        assertMachine(machine1, UserAndHostAndPort.fromParts("myuser", 
"83.222.229.1", 12001), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval1"));
+        assertEquals(machine1.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.1"));
+        assertEquals(pfm.lookup(machine1, 22), 
HostAndPort.fromParts("83.222.229.1", 12001));
+        assertEquals(pfm.lookup(machine1, 8080), 
HostAndPort.fromParts("83.222.229.1", 12002));
+        assertNull(pfm.lookup(machine1, 12345));
+        
+        assertMachine(machine2, UserAndHostAndPort.fromParts("myuser", 
"83.222.229.2",  12003), ImmutableMap.of(
+                SshMachineLocation.PASSWORD.getName(), "mypassword",
+                "mykey", "myval2"));
+        assertEquals(machine2.getPrivateAddresses(), 
ImmutableSet.of("10.0.0.2"));
+        assertEquals(pfm.lookup(machine2, 8985), 
HostAndPort.fromParts("83.222.229.2", 12003));
+        assertEquals(pfm.lookup(machine2, 8080), 
HostAndPort.fromParts("83.222.229.2", 12004));
+        assertNull(pfm.lookup(machine2, 12345));
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testPassesInboundPortsToMachineAndRemovesOnceMachineReleased() 
throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "location:",
+                "  byon:",
+                "    hosts:",
+                "    - ssh: 1.1.1.1:22",
+                "      password: mypassword",
+                "      user: myuser",
+                "services:",
+                "- type: brooklyn.entity.basic.DoNothingSoftwareProcess",
+                "  brooklyn.config:",
+                "    requiredOpenLoginPorts: [22, 1024]");
+
+        Entity app = createStartWaitAndLogApplication(new StringReader(yaml));
+        DoNothingSoftwareProcess entity = (DoNothingSoftwareProcess) 
Iterables.find(Entities.descendants(app), 
Predicates.instanceOf(DoNothingSoftwareProcess.class));
+        FixedListMachineProvisioningLocation<MachineLocation> loc = 
(FixedListMachineProvisioningLocation<MachineLocation>) 
Iterables.get(app.getLocations(), 0);
+        
+        // Machine should have been given the inbound-ports
+        SshMachineLocation machine = 
Machines.findUniqueSshMachineLocation(entity.getLocations()).get();
+        
Asserts.assertEqualsIgnoringOrder((Iterable<?>)machine.config().get(CloudLocationConfig.INBOUND_PORTS),
 ImmutableList.of(22, 1024));
+        
+        // Stop the entity; should release the machine
+        entity.stop();
+        MachineLocation availableMachine = 
Iterables.getOnlyElement(loc.getAvailable());
+        assertEquals(availableMachine, machine);
+        assertNull(machine.config().get(CloudLocationConfig.INBOUND_PORTS));
+    }
+
+    private void assertMachine(SshMachineLocation machine, UserAndHostAndPort 
conn, Map<String, ?> config) {
+        assertEquals(machine.getAddress().getHostAddress(), 
conn.getHostAndPort().getHostText());
+        assertEquals(machine.getPort(), conn.getHostAndPort().getPort());
+        assertEquals(machine.getUser(), conn.getUser());
+        for (Map.Entry<String, ?> entry : config.entrySet()) {
+            Object actualVal = 
machine.getConfig(ConfigKeys.newConfigKey(Object.class, entry.getKey()));
+            assertEquals(actualVal, entry.getValue());
+        }
+    }
+    
+    private void assertMachine(WinRmMachineLocation machine, 
UserAndHostAndPort conn, Map<String, ?> config) {
+        assertEquals(machine.getAddress().getHostAddress(), 
conn.getHostAndPort().getHostText());
+        assertEquals(machine.getConfig(WinRmMachineLocation.WINRM_PORT), 
(Integer) conn.getHostAndPort().getPort());
+        assertEquals(machine.getUser(), conn.getUser());
+        for (Map.Entry<String, ?> entry : config.entrySet()) {
+            Object actualVal = 
machine.getConfig(ConfigKeys.newConfigKey(Object.class, entry.getKey()));
+            assertEquals(actualVal, entry.getValue());
+        }
+    }
+    
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
new file mode 100644
index 0000000..fb0aa36
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
@@ -0,0 +1,245 @@
+/*
+ * 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.camp.brooklyn;
+
+import java.io.File;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.Application;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.rebind.RebindTestUtils;
+import brooklyn.event.Sensor;
+import brooklyn.event.basic.Sensors;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.test.entity.TestEntity;
+import brooklyn.util.collections.MutableSet;
+import brooklyn.util.task.Tasks;
+
+import com.google.common.collect.Iterables;
+import com.google.common.io.Files;
+
+@Test
+public class DslAndRebindYamlTest extends AbstractYamlTest {
+    
+    private static final Logger log = 
LoggerFactory.getLogger(DslAndRebindYamlTest.class);
+    
+    protected ClassLoader classLoader = getClass().getClassLoader();
+    protected File mementoDir;
+    protected Set<ManagementContext> mgmtContexts = MutableSet.of();
+
+    @Override
+    protected LocalManagementContext newTestManagementContext() {
+        if (mementoDir!=null) throw new IllegalStateException("already created 
mgmt context");
+        mementoDir = Files.createTempDir();
+        LocalManagementContext mgmt = 
RebindTestUtils.newPersistingManagementContext(mementoDir, classLoader, 1);
+        mgmtContexts.add(mgmt);
+        return mgmt;
+    }
+    
+    @AfterMethod(alwaysRun = true)
+    @Override
+    public void tearDown() {
+        for (ManagementContext mgmt: mgmtContexts) Entities.destroyAll(mgmt);
+        super.tearDown();
+        mementoDir = null;
+        mgmtContexts.clear();
+    }
+
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+
+    public Application rebind(Application app) throws Exception {
+        RebindTestUtils.waitForPersisted(app);
+        // not strictly needed, but for good measure:
+        RebindTestUtils.checkCurrentMementoSerializable(app);
+        Application result = RebindTestUtils.rebind(mementoDir, 
getClass().getClassLoader());
+        mgmtContexts.add(result.getManagementContext());
+        return result;
+    }
+
+
+    protected Entity setupAndCheckTestEntityInBasicYamlWith(String ...extras) 
throws Exception {
+        Entity app = 
createAndStartApplication(loadYaml("test-entity-basic-template.yaml", extras));
+        waitForApplicationTasks(app);
+
+        Assert.assertEquals(app.getDisplayName(), 
"test-entity-basic-template");
+
+        log.info("App started:");
+        Entities.dumpInfo(app);
+        
+        Assert.assertTrue(app.getChildren().iterator().hasNext(), "Expected 
app to have child entity");
+        Entity entity = app.getChildren().iterator().next();
+        Assert.assertTrue(entity instanceof TestEntity, "Expected TestEntity, 
found " + entity.getClass());
+        
+        return (TestEntity)entity;
+    }
+
+    public static <T> T getConfigInTask(final Entity entity, final 
ConfigKey<T> key) {
+        return Entities.submit(entity, Tasks.<T>builder().body(new 
Callable<T>() {
+            @Override
+            public T call() throws Exception {
+                return entity.getConfig(key);
+            }
+        }).build()).getUnchecked();
+    }
+    
+    @Test
+    public void testDslAttributeWhenReady() throws Exception {
+        Entity testEntity = entityWithAttributeWhenReady();
+        
((EntityInternal)testEntity).setAttribute(Sensors.newStringSensor("foo"), 
"bar");
+        Assert.assertEquals(getConfigInTask(testEntity, TestEntity.CONF_NAME), 
"bar");
+    }
+
+    @Test
+    public void testDslAttributeWhenReadyRebind() throws Exception {
+        Entity testEntity = entityWithAttributeWhenReady();
+        
((EntityInternal)testEntity).setAttribute(Sensors.newStringSensor("foo"), 
"bar");
+        Application app2 = rebind(testEntity.getApplication());
+        Entity e2 = Iterables.getOnlyElement( app2.getChildren() );
+        
+        Assert.assertEquals(getConfigInTask(e2, TestEntity.CONF_NAME), "bar");
+    }
+
+    private Entity entityWithAttributeWhenReady() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.confName: 
$brooklyn:component(\"x\").attributeWhenReady(\"foo\")");
+    }
+
+    private void doTestOnEntityWithSensor(Entity testEntity, Sensor<?> 
expectedSensor) throws Exception {
+        doTestOnEntityWithSensor(testEntity, expectedSensor, true);
+    }
+    private void doTestOnEntityWithSensor(Entity testEntity, Sensor<?> 
expectedSensor, boolean inTask) throws Exception {
+        @SuppressWarnings("rawtypes")
+        ConfigKey<Sensor> configKey = ConfigKeys.newConfigKey(Sensor.class, 
"test.sensor");
+        Sensor<?> s;
+        s = inTask ? getConfigInTask(testEntity, configKey) : 
testEntity.getConfig(configKey);
+        Assert.assertEquals(s, expectedSensor);
+        Application app2 = rebind(testEntity.getApplication());
+        Entity te2 = Iterables.getOnlyElement( app2.getChildren() );
+        s = inTask ? getConfigInTask(te2, configKey) : 
te2.getConfig(configKey);
+        Assert.assertEquals(s, expectedSensor);
+    }
+    
+    @Test
+    public void testDslSensorFromClass() throws Exception {
+        doTestOnEntityWithSensor(entityWithSensorFromClass(), 
Attributes.SERVICE_UP);
+        // without context it can still find it
+        doTestOnEntityWithSensor(entityWithSensorFromClass(), 
Attributes.SERVICE_UP, false);
+    }
+    @Test
+    public void testDslSensorLocal() throws Exception {
+        doTestOnEntityWithSensor(entityWithSensorLocal(), TestEntity.SEQUENCE);
+        // here without context it makes one up, so type info (and description 
etc) not present; 
+        // but context is needed to submit the DslDeferredSupplier object, so 
this would fail
+//        doTestOnEntityWithSensor(entityWithSensorAdHoc(), 
Sensors.newSensor(Object.class, TestEntity.SEQUENCE.getName()), false);
+    }
+    @Test
+    public void testDslSensorAdHoc() throws Exception {
+        doTestOnEntityWithSensor(entityWithSensorAdHoc(), 
Sensors.newSensor(Object.class, "sensor.foo"));
+        // here context has no impact, but it is needed to submit the 
DslDeferredSupplier object so this would fail
+//        doTestOnEntityWithSensor(entityWithSensorAdHoc(), 
Sensors.newSensor(Object.class, "sensor.foo"), false);
+    }
+    
+    private Entity entityWithSensorFromClass() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.sensor: 
$brooklyn:sensor(\""+Attributes.class.getName()+"\", 
\""+Attributes.SERVICE_UP.getName()+"\")");
+    }
+
+    private Entity entityWithSensorLocal() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.sensor: 
$brooklyn:sensor(\""+TestEntity.SEQUENCE.getName()+"\")");
+    }
+
+    private Entity entityWithSensorAdHoc() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.sensor: $brooklyn:sensor(\"sensor.foo\")");
+    }
+
+
+    @Test
+    public void testDslConfigFromRoot() throws Exception {
+        Entity testEntity = entityWithConfigFromRoot();
+        Assert.assertEquals(getConfigInTask(testEntity, TestEntity.CONF_NAME), 
"bar");
+    }
+
+    @Test
+    public void testDslConfigFromRootRebind() throws Exception {
+        Entity testEntity = entityWithConfigFromRoot();
+        Application app2 = rebind(testEntity.getApplication());
+        Entity e2 = Iterables.getOnlyElement( app2.getChildren() );
+        
+        Assert.assertEquals(getConfigInTask(e2, TestEntity.CONF_NAME), "bar");
+    }
+
+    private Entity entityWithConfigFromRoot() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.confName: $brooklyn:component(\"x\").config(\"foo\")",
+            "brooklyn.config:",
+            "  foo: bar");
+    }
+
+
+    @Test
+    public void testDslFormatString() throws Exception {
+        Entity testEntity = entityWithFormatString();
+        Assert.assertEquals(getConfigInTask(testEntity, TestEntity.CONF_NAME), 
"hello world");
+    }
+
+    @Test
+    public void testDslFormatStringRebind() throws Exception {
+        Entity testEntity = entityWithFormatString();
+        Application app2 = rebind(testEntity.getApplication());
+        Entity e2 = Iterables.getOnlyElement( app2.getChildren() );
+        
+        Assert.assertEquals(getConfigInTask(e2, TestEntity.CONF_NAME), "hello 
world");
+    }
+
+    private Entity entityWithFormatString() throws Exception {
+        return setupAndCheckTestEntityInBasicYamlWith( 
+            "  id: x",
+            "  brooklyn.config:",
+            "    test.confName: $brooklyn:formatString(\"hello %s\", 
\"world\")");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptySoftwareProcessYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptySoftwareProcessYamlTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptySoftwareProcessYamlTest.java
new file mode 100644
index 0000000..f45fddb
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptySoftwareProcessYamlTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.camp.brooklyn;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.EmptySoftwareProcess;
+import brooklyn.entity.basic.Entities;
+import brooklyn.location.Location;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.util.collections.Jsonya;
+
+@Test
+public class EmptySoftwareProcessYamlTest extends AbstractYamlTest {
+    private static final Logger log = 
LoggerFactory.getLogger(EnrichersYamlTest.class);
+
+    @Test(groups="Integration")
+    public void testProvisioningProperties() throws Exception {
+        Entity app = createAndStartApplication(
+            "location: localhost",
+            "services:",
+            "- type: "+EmptySoftwareProcess.class.getName(),
+            "  provisioning.properties:",
+            "    minRam: 16384");
+        waitForApplicationTasks(app);
+
+        log.info("App started:");
+        Entities.dumpInfo(app);
+        
+        EmptySoftwareProcess entity = (EmptySoftwareProcess) 
app.getChildren().iterator().next();
+        Map<String, Object> pp = 
entity.getConfig(EmptySoftwareProcess.PROVISIONING_PROPERTIES);
+        Assert.assertEquals(pp.get("minRam"), 16384);
+    }
+
+    @Test(groups="Integration")
+    public void testProvisioningPropertiesViaJsonya() throws Exception {
+        Entity app = createAndStartApplication(
+            Jsonya.newInstance()
+                .put("location", "localhost")
+                .at("services").list()
+                .put("type", EmptySoftwareProcess.class.getName())
+                .at("provisioning.properties").put("minRam", 16384)
+                .root().toString());
+        waitForApplicationTasks(app);
+
+        log.info("App started:");
+        Entities.dumpInfo(app);
+        
+        EmptySoftwareProcess entity = (EmptySoftwareProcess) 
app.getChildren().iterator().next();
+        Map<String, Object> pp = 
entity.getConfig(EmptySoftwareProcess.PROVISIONING_PROPERTIES);
+        Assert.assertEquals(pp.get("minRam"), 16384);
+    }
+
+    // for https://github.com/brooklyncentral/brooklyn/issues/1377
+    @Test(groups="Integration")
+    public void testWithAppAndEntityLocations() throws Exception {
+        Entity app = createAndStartApplication(
+                "services:",
+                "- type: "+EmptySoftwareProcess.class.getName(),
+                "  location: localhost:(name=localhost on entity)",
+                "location: byon:(hosts=\"127.0.0.1\", name=loopback on app)");
+        waitForApplicationTasks(app);
+        Entities.dumpInfo(app);
+        
+        Assert.assertEquals(app.getLocations().size(), 1);
+        Assert.assertEquals(app.getChildren().size(), 1);
+        Entity entity = app.getChildren().iterator().next();
+        
+        Location appLocation = app.getLocations().iterator().next();
+        Assert.assertEquals(appLocation.getDisplayName(), "loopback on app");
+        
+        Assert.assertEquals(entity.getLocations().size(), 2);
+        Iterator<Location> entityLocationIterator = 
entity.getLocations().iterator();
+        Assert.assertEquals(entityLocationIterator.next().getDisplayName(), 
"localhost on entity");
+        Location actualMachine = entityLocationIterator.next();
+        Assert.assertTrue(actualMachine instanceof SshMachineLocation, "wrong 
location: "+actualMachine);
+        // TODO this, below, probably should be 'localhost on entity', see 
#1377
+        Assert.assertEquals(actualMachine.getParent().getDisplayName(), 
"loopback on app");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EnrichersSlightlySimplerYamlTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EnrichersSlightlySimplerYamlTest.java
 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EnrichersSlightlySimplerYamlTest.java
new file mode 100644
index 0000000..b416be5
--- /dev/null
+++ 
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EnrichersSlightlySimplerYamlTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.camp.brooklyn;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.group.DynamicCluster;
+import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
+import brooklyn.event.basic.Sensors;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.collections.CollectionFunctionals;
+import brooklyn.util.collections.MutableList;
+import brooklyn.util.math.MathPredicates;
+import brooklyn.util.text.StringPredicates;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/** Tests some improvements to enricher classes to make them a bit more yaml 
friendly.
+ * Called "SlightlySimpler" as it would be nice to make enrichers a lot more 
yaml friendly! */
+@Test
+public class EnrichersSlightlySimplerYamlTest extends AbstractYamlTest {
+    private static final Logger log = 
LoggerFactory.getLogger(EnrichersSlightlySimplerYamlTest.class);
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @Test
+    public void testWithAppEnricher() throws Exception {
+        Entity app = 
createAndStartApplication(loadYaml("test-app-with-enrichers-slightly-simpler.yaml"));
+        waitForApplicationTasks(app);
+        log.info("Started "+app+":");
+        Entities.dumpInfo(app);
+        
+        Entity cluster = Iterables.getOnlyElement( app.getChildren() );
+        Collection<Entity> leafs = ((DynamicCluster)cluster).getMembers();
+        Iterator<Entity> li = leafs.iterator();
+        
+        Entity e1 = li.next();
+        ((EntityInternal)e1).setAttribute(Sensors.newStringSensor("ip"), 
"127.0.0.1");
+        EntityTestUtils.assertAttributeEqualsEventually(e1, 
Sensors.newStringSensor("url"), "http://127.0.0.1/";);
+        EntityTestUtils.assertAttributeEqualsEventually(e1, 
Attributes.MAIN_URI, URI.create("http://127.0.0.1/";));
+
+        int i=2;
+        while (li.hasNext()) {
+            Entity ei = li.next();
+            ((EntityInternal)ei).setAttribute(Sensors.newStringSensor("ip"), 
"127.0.0."+i);
+            i++;
+        }
+        
+        EntityTestUtils.assertAttributeEventually(cluster, 
Sensors.newSensor(Iterable.class, "urls.list"),
+            (Predicate)CollectionFunctionals.sizeEquals(3));
+        
+        EntityTestUtils.assertAttributeEventually(cluster, 
Sensors.newSensor(String.class, "urls.list.comma_separated.max_2"),
+            
StringPredicates.matchesRegex("\"http:\\/\\/127[^\"]*\\/\",\"http:\\/\\/127[^\"]*\\/\""));
+
+        EntityTestUtils.assertAttributeEventually(cluster, 
Attributes.MAIN_URI, Predicates.notNull());
+        URI main = cluster.getAttribute(Attributes.MAIN_URI);
+        Assert.assertTrue(main.toString().matches("http:\\/\\/127.0.0..\\/"), 
"Wrong URI: "+main);
+        
+        EntityTestUtils.assertAttributeEventually(app, Attributes.MAIN_URI, 
Predicates.notNull());
+        main = app.getAttribute(Attributes.MAIN_URI);
+        Assert.assertTrue(main.toString().matches("http:\\/\\/127.0.0..\\/"), 
"Wrong URI: "+main);
+        
+        // TODO would we want to allow "all-but-usual" as the default if 
nothing specified
+    }
+    
+    @Test(groups="Integration")
+    public void testWebappWithAveragingEnricher() throws Exception {
+        Entity app = 
createAndStartApplication(loadYaml("test-webapp-with-averaging-enricher.yaml"));
+        waitForApplicationTasks(app);
+        log.info("Started "+app+":");
+        Entities.dumpInfo(app);
+
+        List<JavaWebAppSoftwareProcess> appservers = 
MutableList.copyOf(Entities.descendants(app, JavaWebAppSoftwareProcess.class));
+        Assert.assertEquals(appservers.size(), 3);
+        
+        EntityInternal srv0 = (EntityInternal) appservers.get(0);
+        EntityInternal dwac = (EntityInternal) srv0.getParent();
+        EntityInternal cdwac = (EntityInternal) dwac.getParent();
+        
+        srv0.setAttribute(Sensors.newDoubleSensor("my.load"), 20.0);
+        
+        EntityTestUtils.assertAttributeEventually(dwac, 
Sensors.newSensor(Double.class, "my.load.averaged"),
+            MathPredicates.equalsApproximately(20));
+        EntityTestUtils.assertAttributeEventually(cdwac, 
Sensors.newSensor(Double.class, "my.load.averaged"),
+            MathPredicates.equalsApproximately(20));
+
+        srv0.setAttribute(Sensors.newDoubleSensor("my.load"), null);
+        EntityTestUtils.assertAttributeEventually(cdwac, 
Sensors.newSensor(Double.class, "my.load.averaged"),
+            Predicates.isNull());
+
+        ((EntityInternal) 
appservers.get(1)).setAttribute(Sensors.newDoubleSensor("my.load"), 10.0);
+        ((EntityInternal) 
appservers.get(2)).setAttribute(Sensors.newDoubleSensor("my.load"), 20.0);
+        EntityTestUtils.assertAttributeEventually(cdwac, 
Sensors.newSensor(Double.class, "my.load.averaged"),
+            MathPredicates.equalsApproximately(15));
+        srv0.setAttribute(Sensors.newDoubleSensor("my.load"), 0.0);
+        EntityTestUtils.assertAttributeEventually(cdwac, 
Sensors.newSensor(Double.class, "my.load.averaged"),
+            MathPredicates.equalsApproximately(10));
+    }
+    
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+    
+}

Reply via email to