brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [6/9] incubator-brooklyn git commit: Fix indents in rest-server
Date Thu, 15 Jan 2015 15:00:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bfac921f/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
index e009302..a6c26ab 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -112,469 +112,462 @@ public class ApplicationResourceTest extends BrooklynRestResourceTest {
           .locations(ImmutableSet.of("localhost"))
           .build();
 
-  // Convenience for finding an EntitySummary within a collection, based on its name
-  private static Predicate<EntitySummary> withName(final String name) {
-    return new Predicate<EntitySummary>() {
-      public boolean apply(EntitySummary input) {
-        return name.equals(input.getName());
-      }
-    };
-  }
-
-  // Convenience for finding a Map within a collection, based on the value of one of its keys
-  private static Predicate<? super Map<?,?>> withValueForKey(final Object key, final Object value) {
-      return new Predicate<Object>() {
-          public boolean apply(Object input) {
-              if (!(input instanceof Map)) return false;
-              return value.equals(((Map<?, ?>) input).get(key));
-          }
-      };
-  }
-
-  @Test
-  public void testGetUndefinedApplication() {
-    try {
-      client().resource("/v1/applications/dummy-not-found").get(ApplicationSummary.class);
-    } catch (UniformInterfaceException e) {
-      assertEquals(e.getResponse().getStatus(), 404);
+    // Convenience for finding an EntitySummary within a collection, based on its name
+    private static Predicate<EntitySummary> withName(final String name) {
+        return new Predicate<EntitySummary>() {
+            public boolean apply(EntitySummary input) {
+                return name.equals(input.getName());
+            }
+        };
     }
-  }
-
-  private static void assertRegexMatches(String actual, String patternExpected) {
-      if (actual==null) Assert.fail("Actual value is null; expected "+patternExpected);
-      if (!actual.matches(patternExpected)) {
-          Assert.fail("Text '"+actual+"' does not match expected pattern "+patternExpected);
-      }
-  }
-  
-  @Test
-  public void testDeployApplication() throws Exception {
-    ClientResponse response = clientDeploy(simpleSpec);
-    
-    HttpTestUtils.assertHealthyStatusCode(response.getStatus());
-    assertEquals(getManagementContext().getApplications().size(), 1);
-    assertRegexMatches(response.getLocation().getPath(), "/v1/applications/.*");
-//    Object taskO = response.getEntity(Object.class);
-    TaskSummary task = response.getEntity(TaskSummary.class);
-    log.info("deployed, got "+task);
-    assertEquals(task.getEntityId(), 
-            getManagementContext().getApplications().iterator().next().getApplicationId());
-
-    waitForApplicationToBeRunning(response.getLocation());
-  }
-
-  @Test(dependsOnMethods = {"testDeleteApplication"})
-  // this must happen after we've deleted the main application, as testLocatedLocations assumes a single location
-  public void testDeployApplicationImpl() throws Exception {
+
+    // Convenience for finding a Map within a collection, based on the value of one of its keys
+    private static Predicate<? super Map<?,?>> withValueForKey(final Object key, final Object value) {
+        return new Predicate<Object>() {
+            public boolean apply(Object input) {
+                if (!(input instanceof Map)) return false;
+                return value.equals(((Map<?, ?>) input).get(key));
+            }
+        };
+    }
+
+    @Test
+    public void testGetUndefinedApplication() {
+        try {
+            client().resource("/v1/applications/dummy-not-found").get(ApplicationSummary.class);
+        } catch (UniformInterfaceException e) {
+            assertEquals(e.getResponse().getStatus(), 404);
+        }
+    }
+
+    private static void assertRegexMatches(String actual, String patternExpected) {
+        if (actual==null) Assert.fail("Actual value is null; expected "+patternExpected);
+        if (!actual.matches(patternExpected)) {
+            Assert.fail("Text '"+actual+"' does not match expected pattern "+patternExpected);
+        }
+    }
+
+    @Test
+    public void testDeployApplication() throws Exception {
+        ClientResponse response = clientDeploy(simpleSpec);
+
+        HttpTestUtils.assertHealthyStatusCode(response.getStatus());
+        assertEquals(getManagementContext().getApplications().size(), 1);
+        assertRegexMatches(response.getLocation().getPath(), "/v1/applications/.*");
+        // Object taskO = response.getEntity(Object.class);
+        TaskSummary task = response.getEntity(TaskSummary.class);
+        log.info("deployed, got " + task);
+        assertEquals(task.getEntityId(), getManagementContext().getApplications().iterator().next().getApplicationId());
+
+        waitForApplicationToBeRunning(response.getLocation());
+    }
+
+    @Test(dependsOnMethods = { "testDeleteApplication" })
+    // this must happen after we've deleted the main application, as testLocatedLocations assumes a single location
+    public void testDeployApplicationImpl() throws Exception {
     ApplicationSpec spec = ApplicationSpec.builder()
             .type(RestMockApp.class.getCanonicalName())
             .name("simple-app-impl")
             .locations(ImmutableSet.of("localhost"))
             .build();
-      
-    ClientResponse response = clientDeploy(spec);
-    assertTrue(response.getStatus()/100 == 2, "response is "+response);
-    
-    // Expect app to be running
-    URI appUri = response.getLocation();
-    waitForApplicationToBeRunning(response.getLocation());
-    assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-impl");
-  }
-
-  @Test(dependsOnMethods = {"testDeployApplication", "testLocatedLocation"})
-  public void testDeployApplicationFromInterface() throws Exception {
-    ApplicationSpec spec = ApplicationSpec.builder()
-            .type(BasicApplication.class.getCanonicalName())
-            .name("simple-app-interface")
-            .locations(ImmutableSet.of("localhost"))
-            .build();
-      
-    ClientResponse response = clientDeploy(spec);
-    assertTrue(response.getStatus()/100 == 2, "response is "+response);
-    
-    // Expect app to be running
-    URI appUri = response.getLocation();
-    waitForApplicationToBeRunning(response.getLocation());
-    assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-interface");
-  }
-
-  @Test(dependsOnMethods = {"testDeployApplication", "testLocatedLocation"})
-  public void testDeployApplicationFromBuilder() throws Exception {
-    ApplicationSpec spec = ApplicationSpec.builder()
-            .type(RestMockAppBuilder.class.getCanonicalName())
-            .name("simple-app-builder")
-            .locations(ImmutableSet.of("localhost"))
-            .build();
-      
-    ClientResponse response = clientDeploy(spec);
-    assertTrue(response.getStatus()/100 == 2, "response is "+response);
-    
-    // Expect app to be running
-    URI appUri = response.getLocation();
-    waitForApplicationToBeRunning(response.getLocation(), Duration.TEN_SECONDS);
-    assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-builder");
-    
-    // Expect app to have the child-entity
-    Set<EntitySummary> entities = client().resource(appUri.toString() + "/entities")
-            .get(new GenericType<Set<EntitySummary>>() {});
-    assertEquals(entities.size(), 1);
-    assertEquals(Iterables.getOnlyElement(entities).getName(), "child1");
-    assertEquals(Iterables.getOnlyElement(entities).getType(), RestMockSimpleEntity.class.getCanonicalName());
-  }
-  
-
-  @Test(dependsOnMethods = {"testDeployApplication", "testLocatedLocation"})
-  public void testDeployApplicationYaml() throws Exception {
-    String yaml = "{ name: simple-app-yaml, location: localhost, services: [ { serviceType: "+BasicApplication.class.getCanonicalName()+" } ] }";
-      
-    ClientResponse response = client().resource("/v1/applications")
-        .entity(yaml, "application/x-yaml")
-        .post(ClientResponse.class);
-    assertTrue(response.getStatus()/100 == 2, "response is "+response);
-    
-    // Expect app to be running
-    URI appUri = response.getLocation();
-    waitForApplicationToBeRunning(response.getLocation());
-    assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-yaml");
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void testReferenceCatalogEntity() throws Exception {
-      getManagementContext().getCatalog().addItem(BasicEntity.class);
-
-      String yaml = "{ name: simple-app-yaml, location: localhost, services: [ { serviceType: " + BasicEntity.class.getName() + " } ] }";
-      
-    ClientResponse response = client().resource("/v1/applications")
-        .entity(yaml, "application/x-yaml")
-        .post(ClientResponse.class);
-    assertTrue(response.getStatus()/100 == 2, "response is "+response);
-    
-    // Expect app to be running
-    URI appUri = response.getLocation();
-    waitForApplicationToBeRunning(response.getLocation());
-    assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-yaml");
-    
-    ClientResponse response2 = client().resource(appUri.getPath())
-        .delete(ClientResponse.class);
-    assertEquals(response2.getStatus(), Response.Status.ACCEPTED.getStatusCode());
-  }
-
-  @Test
-  public void testDeployWithInvalidEntityType() {
-    try {
-      clientDeploy(
-          ApplicationSpec.builder().name("invalid-app")
-              .entities(ImmutableSet.of(new EntitySpec("invalid-ent", "not.existing.entity")))
-              .locations(ImmutableSet.of("localhost"))
-              .build()
-      );
-
-    } catch (UniformInterfaceException e) {
-      ApiError error = e.getResponse().getEntity(ApiError.class);
-      assertEquals(error.getMessage(), "Undefined type 'not.existing.entity'");
+
+        ClientResponse response = clientDeploy(spec);
+        assertTrue(response.getStatus() / 100 == 2, "response is " + response);
+
+        // Expect app to be running
+        URI appUri = response.getLocation();
+        waitForApplicationToBeRunning(response.getLocation());
+        assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-impl");
     }
-  }
-
-  @Test
-  public void testDeployWithInvalidLocation() {
-    try {
-        clientDeploy(
-          ApplicationSpec.builder().name("invalid-app")
-              .entities(ImmutableSet.of(new EntitySpec("simple-ent", RestMockSimpleEntity.class.getName())))
-              .locations(ImmutableSet.of("3423"))
-              .build()
-      );
-
-    } catch (UniformInterfaceException e) {
-      ApiError error = e.getResponse().getEntity(ApiError.class);
-      assertEquals(error.getMessage(), "Undefined location '3423'");
+
+    @Test(dependsOnMethods = { "testDeployApplication", "testLocatedLocation" })
+    public void testDeployApplicationFromInterface() throws Exception {
+        ApplicationSpec spec = ApplicationSpec.builder()
+                .type(BasicApplication.class.getCanonicalName())
+                .name("simple-app-interface")
+                .locations(ImmutableSet.of("localhost"))
+                .build();
+
+        ClientResponse response = clientDeploy(spec);
+        assertTrue(response.getStatus() / 100 == 2, "response is " + response);
+
+        // Expect app to be running
+        URI appUri = response.getLocation();
+        waitForApplicationToBeRunning(response.getLocation());
+        assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-interface");
     }
-  }
-
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testListEntities() {
-    Set<EntitySummary> entities = client().resource("/v1/applications/simple-app/entities")
-        .get(new GenericType<Set<EntitySummary>>() {});
-
-    assertEquals(entities.size(), 2);
-
-    EntitySummary entity = Iterables.find(entities, withName("simple-ent"), null);
-    EntitySummary group = Iterables.find(entities, withName("simple-group"), null);
-    Assert.assertNotNull(entity);
-    Assert.assertNotNull(group);
-
-    client().resource(entity.getLinks().get("self")).get(ClientResponse.class);
-
-    Set<EntitySummary> children = client().resource(entity.getLinks().get("children"))
-        .get(new GenericType<Set<EntitySummary>>() {});
-    assertEquals(children.size(), 0);
-  }
-
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testListApplications() {
-    Set<ApplicationSummary> applications = client().resource("/v1/applications")
-        .get(new GenericType<Set<ApplicationSummary>>() { });
-    log.info("Applications listed are: "+applications);
-    for (ApplicationSummary app: applications) {
-        if (simpleSpec.getName().equals(app.getSpec().getName())) return;
+
+    @Test(dependsOnMethods = { "testDeployApplication", "testLocatedLocation" })
+    public void testDeployApplicationFromBuilder() throws Exception {
+        ApplicationSpec spec = ApplicationSpec.builder()
+                .type(RestMockAppBuilder.class.getCanonicalName())
+                .name("simple-app-builder")
+                .locations(ImmutableSet.of("localhost"))
+                .build();
+
+        ClientResponse response = clientDeploy(spec);
+        assertTrue(response.getStatus() / 100 == 2, "response is " + response);
+
+        // Expect app to be running
+        URI appUri = response.getLocation();
+        waitForApplicationToBeRunning(response.getLocation(), Duration.TEN_SECONDS);
+        assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-builder");
+
+        // Expect app to have the child-entity
+        Set<EntitySummary> entities = client().resource(appUri.toString() + "/entities")
+                .get(new GenericType<Set<EntitySummary>>() {});
+        assertEquals(entities.size(), 1);
+        assertEquals(Iterables.getOnlyElement(entities).getName(), "child1");
+        assertEquals(Iterables.getOnlyElement(entities).getType(), RestMockSimpleEntity.class.getCanonicalName());
     }
-    Assert.fail("simple-app not found in list of applications: "+applications);
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testFetchApplicationsAndEntity() {
-    Collection apps = client().resource("/v1/applications/fetch").get(Collection.class);
-    log.info("Applications fetched are: "+apps);
-    
-    Map app = null;
-    for (Object appI: apps) {
-        Object name = ((Map)appI).get("name");
-        if ("simple-app".equals( name )) {
-            app = (Map) appI;
+
+    @Test(dependsOnMethods = { "testDeployApplication", "testLocatedLocation" })
+    public void testDeployApplicationYaml() throws Exception {
+        String yaml = "{ name: simple-app-yaml, location: localhost, services: [ { serviceType: "+BasicApplication.class.getCanonicalName()+" } ] }";
+
+        ClientResponse response = client().resource("/v1/applications")
+                .entity(yaml, "application/x-yaml")
+                .post(ClientResponse.class);
+        assertTrue(response.getStatus()/100 == 2, "response is "+response);
+
+        // Expect app to be running
+        URI appUri = response.getLocation();
+        waitForApplicationToBeRunning(response.getLocation());
+        assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-yaml");
+    }
+
+    @SuppressWarnings("deprecation")
+    @Test
+    public void testReferenceCatalogEntity() throws Exception {
+        getManagementContext().getCatalog().addItem(BasicEntity.class);
+
+        String yaml = "{ name: simple-app-yaml, location: localhost, services: [ { serviceType: " + BasicEntity.class.getName() + " } ] }";
+
+        ClientResponse response = client().resource("/v1/applications")
+                .entity(yaml, "application/x-yaml")
+                .post(ClientResponse.class);
+        assertTrue(response.getStatus()/100 == 2, "response is "+response);
+
+        // Expect app to be running
+        URI appUri = response.getLocation();
+        waitForApplicationToBeRunning(response.getLocation());
+        assertEquals(client().resource(appUri).get(ApplicationSummary.class).getSpec().getName(), "simple-app-yaml");
+
+        ClientResponse response2 = client().resource(appUri.getPath())
+                .delete(ClientResponse.class);
+        assertEquals(response2.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+    }
+
+    @Test
+    public void testDeployWithInvalidEntityType() {
+        try {
+            clientDeploy(ApplicationSpec.builder()
+                    .name("invalid-app")
+                    .entities(ImmutableSet.of(new EntitySpec("invalid-ent", "not.existing.entity")))
+                    .locations(ImmutableSet.of("localhost"))
+                    .build());
+
+        } catch (UniformInterfaceException e) {
+            ApiError error = e.getResponse().getEntity(ApiError.class);
+            assertEquals(error.getMessage(), "Undefined type 'not.existing.entity'");
         }
-        if (ImmutableSet.of("simple-ent", "simple-group").contains(name))
-            Assert.fail(name+" should not be listed at high level: "+apps);
     }
-    
-    Assert.assertNotNull(app);
-    Collection children = (Collection) app.get("children");
-    Assert.assertEquals(children.size(), 2);
-    
-    Map entitySummary = (Map) Iterables.find(children, withValueForKey("name", "simple-ent"), null);
-    Map groupSummary = (Map) Iterables.find(children, withValueForKey("name", "simple-group"), null);
-    Assert.assertNotNull(entitySummary);
-    Assert.assertNotNull(groupSummary);
-    
-    String itemIds = app.get("id")+","+entitySummary.get("id")+","+groupSummary.get("id");
-    Collection entities = client().resource("/v1/applications/fetch?items="+itemIds)
-            .get(Collection.class);
-    log.info("Applications+Entities fetched are: "+entities);
-    
-    Assert.assertEquals(entities.size(), apps.size()+2);
-    Map entityDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-ent"), null);
-    Map groupDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-group"), null);
-    Assert.assertNotNull(entityDetails);
-    Assert.assertNotNull(groupDetails);
-    
-    Assert.assertEquals(entityDetails.get("parentId"), app.get("id"));
-    Assert.assertNull(entityDetails.get("children"));
-    Assert.assertEquals(groupDetails.get("parentId"), app.get("id"));
-    Assert.assertNull(groupDetails.get("children"));
-    
-    Collection entityGroupIds = (Collection) entityDetails.get("groupIds");
-    Assert.assertNotNull(entityGroupIds);
-    Assert.assertEquals(entityGroupIds.size(), 1);
-    Assert.assertEquals(entityGroupIds.iterator().next(), groupDetails.get("id"));
-    
-    Collection groupMembers = (Collection) groupDetails.get("members");
-    Assert.assertNotNull(groupMembers);
-    
-    for (Application appi: getManagementContext().getApplications()) {
-        Entities.dumpInfo(appi);
+
+    @Test
+    public void testDeployWithInvalidLocation() {
+        try {
+            clientDeploy(ApplicationSpec.builder()
+                    .name("invalid-app")
+                    .entities(ImmutableSet.of(new EntitySpec("simple-ent", RestMockSimpleEntity.class.getName())))
+                    .locations(ImmutableSet.of("3423"))
+                    .build());
+
+        } catch (UniformInterfaceException e) {
+            ApiError error = e.getResponse().getEntity(ApiError.class);
+            assertEquals(error.getMessage(), "Undefined location '3423'");
+        }
     }
-    log.info("MEMBERS: "+groupMembers);
-    
-    Assert.assertEquals(groupMembers.size(), 1);
-    Map entityMemberDetails = (Map) Iterables.find(groupMembers, withValueForKey("name", "simple-ent"), null);
-    Assert.assertNotNull(entityMemberDetails);
-    Assert.assertEquals(entityMemberDetails.get("id"), entityDetails.get("id"));
-  }
-
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testListSensors() {
-    Set<SensorSummary> sensors = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors")
-        .get(new GenericType<Set<SensorSummary>>() { });
-    assertTrue(sensors.size() > 0);
-    SensorSummary sample = Iterables.find(sensors, new Predicate<SensorSummary>() {
-      @Override
-      public boolean apply(SensorSummary sensorSummary) {
-        return sensorSummary.getName().equals(RestMockSimpleEntity.SAMPLE_SENSOR.getName());
-      }
-    });
-    assertEquals(sample.getType(), "java.lang.String");
-  }
-
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testListConfig() {
-    Set<EntityConfigSummary> config = client().resource("/v1/applications/simple-app/entities/simple-ent/config")
-        .get(new GenericType<Set<EntityConfigSummary>>() { });
-    assertTrue(config.size() > 0);
-    System.out.println(("CONFIG: "+config));
-  }
-  
-  @Test(dependsOnMethods = "testListConfig")
-  public void testListConfig2() {
-    Set<EntityConfigSummary> config = client().resource("/v1/applications/simple-app/entities/simple-ent/config")
-        .get(new GenericType<Set<EntityConfigSummary>>() {
-        });
-    assertTrue(config.size() > 0);
-    System.out.println(("CONFIG: "+config));
-  }
-  
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testListEffectors() {
-    Set<EffectorSummary> effectors = client().resource("/v1/applications/simple-app/entities/simple-ent/effectors")
-        .get(new GenericType<Set<EffectorSummary>>() {
+
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testListEntities() {
+        Set<EntitySummary> entities = client().resource("/v1/applications/simple-app/entities")
+                .get(new GenericType<Set<EntitySummary>>() {});
+
+        assertEquals(entities.size(), 2);
+
+        EntitySummary entity = Iterables.find(entities, withName("simple-ent"), null);
+        EntitySummary group = Iterables.find(entities, withName("simple-group"), null);
+        Assert.assertNotNull(entity);
+        Assert.assertNotNull(group);
+
+        client().resource(entity.getLinks().get("self")).get(ClientResponse.class);
+
+        Set<EntitySummary> children = client().resource(entity.getLinks().get("children"))
+                .get(new GenericType<Set<EntitySummary>>() {});
+        assertEquals(children.size(), 0);
+    }
+
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testListApplications() {
+        Set<ApplicationSummary> applications = client().resource("/v1/applications")
+                .get(new GenericType<Set<ApplicationSummary>>() { });
+        log.info("Applications listed are: " + applications);
+        for (ApplicationSummary app : applications) {
+            if (simpleSpec.getName().equals(app.getSpec().getName())) return;
+        }
+        Assert.fail("simple-app not found in list of applications: "+applications);
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testFetchApplicationsAndEntity() {
+        Collection apps = client().resource("/v1/applications/fetch").get(Collection.class);
+        log.info("Applications fetched are: " + apps);
+
+        Map app = null;
+        for (Object appI : apps) {
+            Object name = ((Map) appI).get("name");
+            if ("simple-app".equals(name)) {
+                app = (Map) appI;
+            }
+            if (ImmutableSet.of("simple-ent", "simple-group").contains(name))
+                Assert.fail(name + " should not be listed at high level: " + apps);
+        }
+
+        Assert.assertNotNull(app);
+        Collection children = (Collection) app.get("children");
+        Assert.assertEquals(children.size(), 2);
+
+        Map entitySummary = (Map) Iterables.find(children, withValueForKey("name", "simple-ent"), null);
+        Map groupSummary = (Map) Iterables.find(children, withValueForKey("name", "simple-group"), null);
+        Assert.assertNotNull(entitySummary);
+        Assert.assertNotNull(groupSummary);
+
+        String itemIds = app.get("id") + "," + entitySummary.get("id") + "," + groupSummary.get("id");
+        Collection entities = client().resource("/v1/applications/fetch?items="+itemIds)
+                .get(Collection.class);
+        log.info("Applications+Entities fetched are: " + entities);
+
+        Assert.assertEquals(entities.size(), apps.size() + 2);
+        Map entityDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-ent"), null);
+        Map groupDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-group"), null);
+        Assert.assertNotNull(entityDetails);
+        Assert.assertNotNull(groupDetails);
+
+        Assert.assertEquals(entityDetails.get("parentId"), app.get("id"));
+        Assert.assertNull(entityDetails.get("children"));
+        Assert.assertEquals(groupDetails.get("parentId"), app.get("id"));
+        Assert.assertNull(groupDetails.get("children"));
+
+        Collection entityGroupIds = (Collection) entityDetails.get("groupIds");
+        Assert.assertNotNull(entityGroupIds);
+        Assert.assertEquals(entityGroupIds.size(), 1);
+        Assert.assertEquals(entityGroupIds.iterator().next(), groupDetails.get("id"));
+
+        Collection groupMembers = (Collection) groupDetails.get("members");
+        Assert.assertNotNull(groupMembers);
+
+        for (Application appi : getManagementContext().getApplications()) {
+            Entities.dumpInfo(appi);
+        }
+        log.info("MEMBERS: " + groupMembers);
+
+        Assert.assertEquals(groupMembers.size(), 1);
+        Map entityMemberDetails = (Map) Iterables.find(groupMembers, withValueForKey("name", "simple-ent"), null);
+        Assert.assertNotNull(entityMemberDetails);
+        Assert.assertEquals(entityMemberDetails.get("id"), entityDetails.get("id"));
+    }
+
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testListSensors() {
+        Set<SensorSummary> sensors = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors")
+                .get(new GenericType<Set<SensorSummary>>() { });
+        assertTrue(sensors.size() > 0);
+        SensorSummary sample = Iterables.find(sensors, new Predicate<SensorSummary>() {
+            @Override
+            public boolean apply(SensorSummary sensorSummary) {
+                return sensorSummary.getName().equals(RestMockSimpleEntity.SAMPLE_SENSOR.getName());
+            }
         });
+        assertEquals(sample.getType(), "java.lang.String");
+    }
 
-    assertTrue(effectors.size() > 0);
-
-    EffectorSummary sampleEffector = find(effectors, new Predicate<EffectorSummary>() {
-      @Override
-      public boolean apply(EffectorSummary input) {
-        return input.getName().equals("sampleEffector");
-      }
-    });
-    assertEquals(sampleEffector.getReturnType(), "java.lang.String");
-  }
-
-  @Test(dependsOnMethods = "testListSensors")
-  public void testTriggerSampleEffector() throws InterruptedException, IOException {
-    ClientResponse response = client().resource("/v1/applications/simple-app/entities/simple-ent/effectors/"+
-            RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
-        .type(MediaType.APPLICATION_JSON_TYPE)
-        .post(ClientResponse.class, ImmutableMap.of("param1", "foo", "param2", 4));
-
-    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
-    
-    String result = response.getEntity(String.class);
-    assertEquals(result, "foo4");
-  }
-
-  @Test(dependsOnMethods = "testListSensors")
-  public void testTriggerSampleEffectorWithFormData() throws InterruptedException, IOException {
-    MultivaluedMap<String, String> data = new MultivaluedMapImpl();
-    data.add("param1", "foo");
-    data.add("param2", "4");
-    ClientResponse response = client().resource("/v1/applications/simple-app/entities/simple-ent/effectors/"+
-            RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
-        .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-        .post(ClientResponse.class, data);
-
-    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
-
-    String result = response.getEntity(String.class);
-    assertEquals(result, "foo4");
-  }
-
-  @Test(dependsOnMethods = "testTriggerSampleEffector")
-  public void testBatchSensorValues() {
-    WebResource resource = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors/current-state");
-    Map<String,Object> sensors = resource.get(new GenericType<Map<String,Object>>() {});
-    assertTrue(sensors.size() > 0);
-    assertEquals(sensors.get(RestMockSimpleEntity.SAMPLE_SENSOR.getName()), "foo4");
-  }
-
-  @Test(dependsOnMethods = "testBatchSensorValues")
-  public void testReadEachSensor() {
-    Set<SensorSummary> sensors = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors")
-        .get(new GenericType<Set<SensorSummary>>() {
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testListConfig() {
+        Set<EntityConfigSummary> config = client().resource("/v1/applications/simple-app/entities/simple-ent/config")
+                .get(new GenericType<Set<EntityConfigSummary>>() { });
+        assertTrue(config.size() > 0);
+        System.out.println(("CONFIG: " + config));
+    }
+
+    @Test(dependsOnMethods = "testListConfig")
+    public void testListConfig2() {
+        Set<EntityConfigSummary> config = client().resource("/v1/applications/simple-app/entities/simple-ent/config")
+                .get(new GenericType<Set<EntityConfigSummary>>() {});
+        assertTrue(config.size() > 0);
+        System.out.println(("CONFIG: " + config));
+    }
+
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testListEffectors() {
+        Set<EffectorSummary> effectors = client().resource("/v1/applications/simple-app/entities/simple-ent/effectors")
+                .get(new GenericType<Set<EffectorSummary>>() {});
+
+        assertTrue(effectors.size() > 0);
+
+        EffectorSummary sampleEffector = find(effectors, new Predicate<EffectorSummary>() {
+            @Override
+            public boolean apply(EffectorSummary input) {
+                return input.getName().equals("sampleEffector");
+            }
         });
+        assertEquals(sampleEffector.getReturnType(), "java.lang.String");
+    }
+
+    @Test(dependsOnMethods = "testListSensors")
+    public void testTriggerSampleEffector() throws InterruptedException, IOException {
+        ClientResponse response = client()
+                .resource("/v1/applications/simple-app/entities/simple-ent/effectors/"+RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
+                .type(MediaType.APPLICATION_JSON_TYPE)
+                .post(ClientResponse.class, ImmutableMap.of("param1", "foo", "param2", 4));
+
+        assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+
+        String result = response.getEntity(String.class);
+        assertEquals(result, "foo4");
+    }
+
+    @Test(dependsOnMethods = "testListSensors")
+    public void testTriggerSampleEffectorWithFormData() throws InterruptedException, IOException {
+        MultivaluedMap<String, String> data = new MultivaluedMapImpl();
+        data.add("param1", "foo");
+        data.add("param2", "4");
+        ClientResponse response = client()
+                .resource("/v1/applications/simple-app/entities/simple-ent/effectors/"+RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
+                .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
+                .post(ClientResponse.class, data);
+
+        assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+
+        String result = response.getEntity(String.class);
+        assertEquals(result, "foo4");
+    }
+
+    @Test(dependsOnMethods = "testTriggerSampleEffector")
+    public void testBatchSensorValues() {
+        WebResource resource = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors/current-state");
+        Map<String, Object> sensors = resource.get(new GenericType<Map<String, Object>>() {});
+        assertTrue(sensors.size() > 0);
+        assertEquals(sensors.get(RestMockSimpleEntity.SAMPLE_SENSOR.getName()), "foo4");
+    }
 
-    Map<String, String> readings = Maps.newHashMap();
-    for (SensorSummary sensor : sensors) {
-      try {
-      readings.put(sensor.getName(), client().resource(sensor.getLinks().get("self")).accept(MediaType.TEXT_PLAIN).get(String.class));
-      } catch (UniformInterfaceException uie) {
-        if (uie.getResponse().getStatus() == 204) { // no content
-          readings.put(sensor.getName(), null);
-        } else {
-          Exceptions.propagate(uie);
+    @Test(dependsOnMethods = "testBatchSensorValues")
+    public void testReadEachSensor() {
+    Set<SensorSummary> sensors = client().resource("/v1/applications/simple-app/entities/simple-ent/sensors")
+            .get(new GenericType<Set<SensorSummary>>() {});
+
+        Map<String, String> readings = Maps.newHashMap();
+        for (SensorSummary sensor : sensors) {
+            try {
+                readings.put(sensor.getName(), client().resource(sensor.getLinks().get("self")).accept(MediaType.TEXT_PLAIN).get(String.class));
+            } catch (UniformInterfaceException uie) {
+                if (uie.getResponse().getStatus() == 204) { // no content
+                    readings.put(sensor.getName(), null);
+                } else {
+                    Exceptions.propagate(uie);
+                }
+            }
         }
-      }
+
+        assertEquals(readings.get(RestMockSimpleEntity.SAMPLE_SENSOR.getName()), "foo4");
     }
 
-    assertEquals(readings.get(RestMockSimpleEntity.SAMPLE_SENSOR.getName()), "foo4");
-  }
-
-  @Test(dependsOnMethods = "testTriggerSampleEffector")
-  public void testPolicyWhichCapitalizes() {
-      String policiesEndpoint = "/v1/applications/simple-app/entities/simple-ent/policies";
-      Set<PolicySummary> policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>(){});
-      assertEquals(policies.size(), 0);
-      
-      ClientResponse response = client().resource(policiesEndpoint)
-              .queryParam("type", CapitalizePolicy.class.getCanonicalName())
-              .type(MediaType.APPLICATION_JSON_TYPE)
-              .post(ClientResponse.class, Maps.newHashMap());
-      assertEquals(response.getStatus(), 200);
-      PolicySummary policy = response.getEntity(PolicySummary.class);
-      assertNotNull(policy.getId());
-      String newPolicyId = policy.getId();
-      log.info("POLICY CREATED: "+newPolicyId);
-      policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>(){});
-      assertEquals(policies.size(), 1);
-      
-      Lifecycle status = client().resource(policiesEndpoint+"/"+newPolicyId).get(Lifecycle.class);
-      log.info("POLICY STATUS: "+status);
-      
-      response = client().resource(policiesEndpoint+"/"+newPolicyId+"/start")
-              .post(ClientResponse.class);
-      assertEquals(response.getStatus(), 204);
-      status = client().resource(policiesEndpoint+"/"+newPolicyId).get(Lifecycle.class);
-      assertEquals(status, Lifecycle.RUNNING);
-      
-      response = client().resource(policiesEndpoint+"/"+newPolicyId+"/stop")
-              .post(ClientResponse.class);
-      assertEquals(response.getStatus(), 204);
-      status = client().resource(policiesEndpoint+"/"+newPolicyId).get(Lifecycle.class);
-      assertEquals(status, Lifecycle.STOPPED);
-      
-      response = client().resource(policiesEndpoint+"/"+newPolicyId+"/destroy")
-              .post(ClientResponse.class);
-      assertEquals(response.getStatus(), 204);
-
-      response = client().resource(policiesEndpoint+"/"+newPolicyId).get(ClientResponse.class);
-      log.info("POLICY STATUS RESPONSE AFTER DESTROY: "+response.getStatus());
-      assertEquals(response.getStatus(), 404);
-
-      policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>(){});
-      assertEquals(0, policies.size());
-  }
-
-  @SuppressWarnings({ "rawtypes" })
-  @Test(dependsOnMethods = "testDeployApplication")
-  public void testLocatedLocation() {
-      log.info("starting testLocatedLocations");
-      testListApplications();
-      
-    Location l = getManagementContext().getApplications().iterator().next().getLocations().iterator().next();
-    if (!l.hasConfig(LocationConfigKeys.LATITUDE, false)) {
-        log.info("Supplying fake locations for localhost because could not be autodetected");
-        ((AbstractLocation)l).setHostGeoInfo(new HostGeoInfo("localhost", "localhost", 50, 0));
+    @Test(dependsOnMethods = "testTriggerSampleEffector")
+    public void testPolicyWhichCapitalizes() {
+        String policiesEndpoint = "/v1/applications/simple-app/entities/simple-ent/policies";
+        Set<PolicySummary> policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>(){});
+        assertEquals(policies.size(), 0);
+
+        ClientResponse response = client().resource(policiesEndpoint)
+                .queryParam("type", CapitalizePolicy.class.getCanonicalName())
+                .type(MediaType.APPLICATION_JSON_TYPE)
+                .post(ClientResponse.class, Maps.newHashMap());
+        assertEquals(response.getStatus(), 200);
+        PolicySummary policy = response.getEntity(PolicySummary.class);
+        assertNotNull(policy.getId());
+        String newPolicyId = policy.getId();
+        log.info("POLICY CREATED: " + newPolicyId);
+        policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>() {});
+        assertEquals(policies.size(), 1);
+
+        Lifecycle status = client().resource(policiesEndpoint + "/" + newPolicyId).get(Lifecycle.class);
+        log.info("POLICY STATUS: " + status);
+
+        response = client().resource(policiesEndpoint+"/"+newPolicyId+"/start")
+                .post(ClientResponse.class);
+        assertEquals(response.getStatus(), 204);
+        status = client().resource(policiesEndpoint + "/" + newPolicyId).get(Lifecycle.class);
+        assertEquals(status, Lifecycle.RUNNING);
+
+        response = client().resource(policiesEndpoint+"/"+newPolicyId+"/stop")
+                .post(ClientResponse.class);
+        assertEquals(response.getStatus(), 204);
+        status = client().resource(policiesEndpoint + "/" + newPolicyId).get(Lifecycle.class);
+        assertEquals(status, Lifecycle.STOPPED);
+
+        response = client().resource(policiesEndpoint+"/"+newPolicyId+"/destroy")
+                .post(ClientResponse.class);
+        assertEquals(response.getStatus(), 204);
+
+        response = client().resource(policiesEndpoint+"/"+newPolicyId).get(ClientResponse.class);
+        log.info("POLICY STATUS RESPONSE AFTER DESTROY: " + response.getStatus());
+        assertEquals(response.getStatus(), 404);
+
+        policies = client().resource(policiesEndpoint).get(new GenericType<Set<PolicySummary>>() {});
+        assertEquals(0, policies.size());
     }
-    Map result = client().resource("/v1/locations/usage/LocatedLocations")
-        .get(Map.class);
-    log.info("LOCATIONS: "+result);
-    Assert.assertEquals(result.size(), 1);
-    Map details = (Map) result.values().iterator().next();
-    assertEquals(details.get("leafEntityCount"), 2);
-  }
-
-  @Test(dependsOnMethods = {"testListEffectors", "testFetchApplicationsAndEntity", "testTriggerSampleEffector", "testListApplications","testReadEachSensor","testPolicyWhichCapitalizes","testLocatedLocation"})
-  public void testDeleteApplication() throws TimeoutException, InterruptedException {
-    waitForPageFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);
-    Collection<Application> apps = getManagementContext().getApplications();
-    log.info("Deleting simple-app from "+apps);
-    int size = apps.size();
-    
-    ClientResponse response = client().resource("/v1/applications/simple-app")
-        .delete(ClientResponse.class);
 
-    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
-    TaskSummary task = response.getEntity(TaskSummary.class);
-    assertTrue(task.getDescription().toLowerCase().contains("destroy"), task.getDescription());
-    assertTrue(task.getDescription().toLowerCase().contains("simple-app"), task.getDescription());
-    
-    waitForPageNotFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);
+    @SuppressWarnings({ "rawtypes" })
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testLocatedLocation() {
+        log.info("starting testLocatedLocations");
+        testListApplications();
 
-    log.info("App appears gone, apps are: "+getManagementContext().getApplications());
-    // more logging above, for failure in the check below
+        Location l = getManagementContext().getApplications().iterator().next().getLocations().iterator().next();
+        if (!l.hasConfig(LocationConfigKeys.LATITUDE, false)) {
+            log.info("Supplying fake locations for localhost because could not be autodetected");
+            ((AbstractLocation) l).setHostGeoInfo(new HostGeoInfo("localhost", "localhost", 50, 0));
+        }
+        Map result = client().resource("/v1/locations/usage/LocatedLocations")
+                .get(Map.class);
+        log.info("LOCATIONS: " + result);
+        Assert.assertEquals(result.size(), 1);
+        Map details = (Map) result.values().iterator().next();
+        assertEquals(details.get("leafEntityCount"), 2);
+    }
 
-    Asserts.eventually(
-        EntityFunctions.applications(getManagementContext()),
-        Predicates.compose(Predicates.equalTo(size-1), CollectionFunctionals.sizeFunction()) );
-  }
+    @Test(dependsOnMethods = {"testListEffectors", "testFetchApplicationsAndEntity", "testTriggerSampleEffector", "testListApplications","testReadEachSensor","testPolicyWhichCapitalizes","testLocatedLocation"})
+    public void testDeleteApplication() throws TimeoutException, InterruptedException {
+        waitForPageFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);
+        Collection<Application> apps = getManagementContext().getApplications();
+        log.info("Deleting simple-app from " + apps);
+        int size = apps.size();
+
+        ClientResponse response = client().resource("/v1/applications/simple-app")
+                .delete(ClientResponse.class);
+
+        assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+        TaskSummary task = response.getEntity(TaskSummary.class);
+        assertTrue(task.getDescription().toLowerCase().contains("destroy"), task.getDescription());
+        assertTrue(task.getDescription().toLowerCase().contains("simple-app"), task.getDescription());
+
+        waitForPageNotFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);
+
+        log.info("App appears gone, apps are: " + getManagementContext().getApplications());
+        // more logging above, for failure in the check below
+
+        Asserts.eventually(
+                EntityFunctions.applications(getManagementContext()),
+                Predicates.compose(Predicates.equalTo(size-1), CollectionFunctionals.sizeFunction()) );
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bfac921f/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
index 049a0fa..060e3c8 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
@@ -72,217 +72,215 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
         addResource(new CatalogResource());
     }
 
-  @Test
-  /** based on CampYamlLiteTest */
-  public void testRegisterCustomEntityWithBundleWhereEntityIsFromCoreAndIconFromBundle() {
-    TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
-    String symbolicName = "my.catalog.entity.id";
-    String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
-    String yaml =
-        "brooklyn.catalog:\n"+
-        "  id: " + symbolicName + "\n"+
-        "  name: My Catalog App\n"+
-        "  description: My description\n"+
-        "  icon_url: classpath:/brooklyn/osgi/tests/icon.gif\n"+
-        "  version: " + TEST_VERSION + "\n"+
-        "  libraries:\n"+
-        "  - url: " + bundleUrl + "\n"+
-        "\n"+
-        "services:\n"+
-        "- type: brooklyn.test.entity.TestEntity\n";
-
-    ClientResponse response = client().resource("/v1/catalog")
-        .post(ClientResponse.class, yaml);
-
-    assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
-
-    CatalogEntitySummary entityItem = client().resource("/v1/catalog/entities/"+symbolicName + "/" + TEST_VERSION)
-            .get(CatalogEntitySummary.class);
-
-    Assert.assertNotNull(entityItem.getPlanYaml());
-    Assert.assertTrue(entityItem.getPlanYaml().contains("brooklyn.test.entity.TestEntity"));
-    
-    assertEquals(entityItem.getId(), ver(symbolicName));
-    assertEquals(entityItem.getSymbolicName(), symbolicName);
-    assertEquals(entityItem.getVersion(), TEST_VERSION);
-    
-    // and internally let's check we have libraries
-    CatalogItem<?, ?> item = getManagementContext().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
-    Assert.assertNotNull(item);
-    Collection<CatalogBundle> libs = item.getLibraries();
-    assertEquals(libs.size(), 1);
-    assertEquals(Iterables.getOnlyElement(libs).getUrl(), bundleUrl);
-
-    // now let's check other things on the item
-    assertEquals(entityItem.getName(), "My Catalog App");
-    assertEquals(entityItem.getDescription(), "My description");
-    assertEquals(entityItem.getIconUrl(), "/v1/catalog/icon/" + symbolicName + "/" + entityItem.getVersion());
-    assertEquals(item.getIconUrl(), "classpath:/brooklyn/osgi/tests/icon.gif");
-    
-    byte[] iconData = client().resource("/v1/catalog/icon/"+symbolicName + "/" + TEST_VERSION).get(byte[].class);
-    assertEquals(iconData.length, 43);
-  }
-
-  @Test
-  public void testRegisterOSGiPolicy() {
-    TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
-    String symbolicName = "my.catalog.policy.id";
-    String policyType = "brooklyn.osgi.tests.SimplePolicy";
-    String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
-
-    String yaml =
-        "brooklyn.catalog:\n"+
-        "  id: " + symbolicName + "\n"+
-        "  name: My Catalog App\n"+
-        "  description: My description\n"+
-        "  version: " + TEST_VERSION + "\n" +
-        "  libraries:\n"+
-        "  - url: " + bundleUrl + "\n"+
-        "\n"+
-        "brooklyn.policies:\n"+
-        "- type: " + policyType;
-
-    CatalogPolicySummary entityItem = client().resource("/v1/catalog")
-        .post(CatalogPolicySummary.class, yaml);
-
-    Assert.assertNotNull(entityItem.getPlanYaml());
-    Assert.assertTrue(entityItem.getPlanYaml().contains(policyType));
-    assertEquals(entityItem.getId(), ver(symbolicName));
-    assertEquals(entityItem.getSymbolicName(), symbolicName);
-    assertEquals(entityItem.getVersion(), TEST_VERSION);
-  }
-
-  @Test
-  public void testListAllEntities() {
-    List<CatalogItemSummary> entities = client().resource("/v1/catalog/entities")
-        .get(new GenericType<List<CatalogItemSummary>>() {
-        });
-    assertTrue(entities.size() > 0);
-  }
-
-  @Test
-  public void testFilterListOfEntitiesByName() {
-    List<CatalogItemSummary> entities = client().resource("/v1/catalog/entities")
-            .queryParam("fragment", "reDISclusTER").get(new GenericType<List<CatalogItemSummary>>() {});
-    assertEquals(entities.size(), 1);
-
-    log.info("RedisCluster-like entities are: "+entities);
-    
-    List<CatalogItemSummary> entities2 = client().resource("/v1/catalog/entities")
-            .queryParam("regex", "[Rr]ed.[sulC]+ter").get(new GenericType<List<CatalogItemSummary>>() {});
-    assertEquals(entities2.size(), 1);
-    
-    assertEquals(entities, entities2);
-    
-    List<CatalogItemSummary> entities3 = client().resource("/v1/catalog/entities")
-            .queryParam("fragment", "bweqQzZ").get(new GenericType<List<CatalogItemSummary>>() {});
-    assertEquals(entities3.size(), 0);
-    
-    List<CatalogItemSummary> entities4 = client().resource("/v1/catalog/entities")
-            .queryParam("regex", "bweq+z+").get(new GenericType<List<CatalogItemSummary>>() {});
-    assertEquals(entities4.size(), 0);
-  }
-
-  @Test
-  @Deprecated
-  //If we move to using a yaml catalog item, the details will be of the wrapping app,
-  //not of the entity itself, so the test won't make sense any more.
-  public void testGetCatalogEntityDetails() {
-      CatalogEntitySummary details = client().resource(
-              URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStore"))
-              .get(CatalogEntitySummary.class);
-      assertTrue(details.toString().contains("redis.port"), "expected more config, only got: "+details);
-      String iconUrl = "/v1/catalog/icon/" + details.getSymbolicName();
-      assertTrue(details.getIconUrl().contains(iconUrl), "expected brooklyn URL for icon image, but got: "+details.getIconUrl());
-  }
-
-  @Test
-  @Deprecated
-  //If we move to using a yaml catalog item, the details will be of the wrapping app,
-  //not of the entity itself, so the test won't make sense any more.
-  public void testGetCatalogEntityPlusVersionDetails() {
-      CatalogEntitySummary details = client().resource(
-              URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStore:0.0.0.SNAPSHOT"))
-              .get(CatalogEntitySummary.class);
-      assertTrue(details.toString().contains("redis.port"), "expected more config, only got: "+details);
-      String expectedIconUrl = "/v1/catalog/icon/" + details.getSymbolicName() + "/" + details.getVersion();
-      assertEquals(details.getIconUrl(), expectedIconUrl, "expected brooklyn URL for icon image ("+expectedIconUrl+"), but got: "+details.getIconUrl());
-  }
-
-  @Test
-  public void testGetCatalogEntityIconDetails() throws IOException {
-      String catalogItemId = "testGetCatalogEntityIconDetails";
-      addTestCatalogItem(catalogItemId);
-      ClientResponse response = client().resource(URI.create("/v1/catalog/icon/" + catalogItemId + "/" + TEST_VERSION))
-              .get(ClientResponse.class);
-      response.bufferEntity();
-      Assert.assertEquals(response.getStatus(), 200);
-      Assert.assertEquals(response.getType(), MediaType.valueOf("image/png"));
-      Image image = Toolkit.getDefaultToolkit().createImage(Files.readFile(response.getEntityInputStream()));
-      Assert.assertNotNull(image);
-  }
-
-  private void addTestCatalogItem(String catalogItemId) {
-      String yaml =
-              "brooklyn.catalog:\n"+
-              "  id: " + catalogItemId + "\n"+
-              "  name: My Catalog App\n"+
-              "  description: My description\n"+
-              "  icon_url: classpath:///redis-logo.png\n"+
-              "  version: " + TEST_VERSION + "\n"+
-              "\n"+
-              "services:\n"+
-              "- type: brooklyn.entity.nosql.redis.RedisStore\n";
-
-      client().resource("/v1/catalog").post(yaml);
-  }
-
-  @Test
-  public void testListPolicies() {
-    Set<CatalogItemSummary> policies = client().resource("/v1/catalog/policies")
-        .get(new GenericType<Set<CatalogItemSummary>>() {
-        });
-
-    assertTrue(policies.size() > 0);
-    CatalogItemSummary asp = null;
-    for (CatalogItemSummary p: policies) {
-        if (AutoScalerPolicy.class.getName().equals(p.getType()))
-            asp = p;
+    @Test
+    /** based on CampYamlLiteTest */
+    public void testRegisterCustomEntityWithBundleWhereEntityIsFromCoreAndIconFromBundle() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+        String symbolicName = "my.catalog.entity.id";
+        String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
+        String yaml =
+                "brooklyn.catalog:\n"+
+                "  id: " + symbolicName + "\n"+
+                "  name: My Catalog App\n"+
+                "  description: My description\n"+
+                "  icon_url: classpath:/brooklyn/osgi/tests/icon.gif\n"+
+                "  version: " + TEST_VERSION + "\n"+
+                "  libraries:\n"+
+                "  - url: " + bundleUrl + "\n"+
+                "\n"+
+                "services:\n"+
+                "- type: brooklyn.test.entity.TestEntity\n";
+
+        ClientResponse response = client().resource("/v1/catalog")
+                .post(ClientResponse.class, yaml);
+
+        assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+
+        CatalogEntitySummary entityItem = client().resource("/v1/catalog/entities/"+symbolicName + "/" + TEST_VERSION)
+                .get(CatalogEntitySummary.class);
+
+        Assert.assertNotNull(entityItem.getPlanYaml());
+        Assert.assertTrue(entityItem.getPlanYaml().contains("brooklyn.test.entity.TestEntity"));
+
+        assertEquals(entityItem.getId(), ver(symbolicName));
+        assertEquals(entityItem.getSymbolicName(), symbolicName);
+        assertEquals(entityItem.getVersion(), TEST_VERSION);
+
+        // and internally let's check we have libraries
+        CatalogItem<?, ?> item = getManagementContext().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        Assert.assertNotNull(item);
+        Collection<CatalogBundle> libs = item.getLibraries();
+        assertEquals(libs.size(), 1);
+        assertEquals(Iterables.getOnlyElement(libs).getUrl(), bundleUrl);
+
+        // now let's check other things on the item
+        assertEquals(entityItem.getName(), "My Catalog App");
+        assertEquals(entityItem.getDescription(), "My description");
+        assertEquals(entityItem.getIconUrl(), "/v1/catalog/icon/" + symbolicName + "/" + entityItem.getVersion());
+        assertEquals(item.getIconUrl(), "classpath:/brooklyn/osgi/tests/icon.gif");
+
+        byte[] iconData = client().resource("/v1/catalog/icon/" + symbolicName + "/" + TEST_VERSION).get(byte[].class);
+        assertEquals(iconData.length, 43);
+    }
+
+    @Test
+    public void testRegisterOSGiPolicy() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+        String symbolicName = "my.catalog.policy.id";
+        String policyType = "brooklyn.osgi.tests.SimplePolicy";
+        String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
+
+        String yaml =
+                "brooklyn.catalog:\n"+
+                "  id: " + symbolicName + "\n"+
+                "  name: My Catalog App\n"+
+                "  description: My description\n"+
+                "  version: " + TEST_VERSION + "\n" +
+                "  libraries:\n"+
+                "  - url: " + bundleUrl + "\n"+
+                "\n"+
+                "brooklyn.policies:\n"+
+                "- type: " + policyType;
+
+        CatalogPolicySummary entityItem = client().resource("/v1/catalog")
+                .post(CatalogPolicySummary.class, yaml);
+
+        Assert.assertNotNull(entityItem.getPlanYaml());
+        Assert.assertTrue(entityItem.getPlanYaml().contains(policyType));
+        assertEquals(entityItem.getId(), ver(symbolicName));
+        assertEquals(entityItem.getSymbolicName(), symbolicName);
+        assertEquals(entityItem.getVersion(), TEST_VERSION);
+    }
+
+    @Test
+    public void testListAllEntities() {
+        List<CatalogItemSummary> entities = client().resource("/v1/catalog/entities")
+                .get(new GenericType<List<CatalogItemSummary>>() {});
+        assertTrue(entities.size() > 0);
     }
-    Assert.assertNotNull(asp, "didn't find AutoScalerPolicy");
-  }
-  
-  @Test
-  public void testDeleteCustomEntityFromCatalog() {
-    String symbolicName = "my.catalog.app.id.to.subsequently.delete";
-    String yaml =
-        "name: "+symbolicName+"\n"+
-        // FIXME name above should be unnecessary when brooklyn.catalog below is working
-        "brooklyn.catalog:\n"+
-        "  id: " + symbolicName + "\n"+
-        "  name: My Catalog App To Be Deleted\n"+
-        "  description: My description\n"+
-        "  version: " + TEST_VERSION + "\n"+
-        "\n"+
-        "services:\n"+
-        "- type: brooklyn.test.entity.TestEntity\n";
-
-    client().resource("/v1/catalog")
-            .post(ClientResponse.class, yaml);
+
+    @Test
+    public void testFilterListOfEntitiesByName() {
+        List<CatalogItemSummary> entities = client().resource("/v1/catalog/entities")
+                .queryParam("fragment", "reDISclusTER").get(new GenericType<List<CatalogItemSummary>>() {});
+        assertEquals(entities.size(), 1);
+
+        log.info("RedisCluster-like entities are: " + entities);
+
+        List<CatalogItemSummary> entities2 = client().resource("/v1/catalog/entities")
+                .queryParam("regex", "[Rr]ed.[sulC]+ter").get(new GenericType<List<CatalogItemSummary>>() {});
+        assertEquals(entities2.size(), 1);
+
+        assertEquals(entities, entities2);
     
-    ClientResponse deleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
-            .delete(ClientResponse.class);
-
-    assertEquals(deleteResponse.getStatus(), Response.Status.NO_CONTENT.getStatusCode());
-
-    ClientResponse getPostDeleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
-            .get(ClientResponse.class);
-    assertEquals(getPostDeleteResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
-  }
-  
-  private static String ver(String id) {
-      return CatalogUtils.getVersionedId(id, TEST_VERSION);
-  }
+        List<CatalogItemSummary> entities3 = client().resource("/v1/catalog/entities")
+                .queryParam("fragment", "bweqQzZ").get(new GenericType<List<CatalogItemSummary>>() {});
+        assertEquals(entities3.size(), 0);
+
+        List<CatalogItemSummary> entities4 = client().resource("/v1/catalog/entities")
+                .queryParam("regex", "bweq+z+").get(new GenericType<List<CatalogItemSummary>>() {});
+        assertEquals(entities4.size(), 0);
+    }
+
+    @Test
+    @Deprecated
+    // If we move to using a yaml catalog item, the details will be of the wrapping app,
+    // not of the entity itself, so the test won't make sense any more.
+    public void testGetCatalogEntityDetails() {
+        CatalogEntitySummary details = client()
+                .resource(URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStore"))
+                .get(CatalogEntitySummary.class);
+        assertTrue(details.toString().contains("redis.port"), "expected more config, only got: "+details);
+        String iconUrl = "/v1/catalog/icon/" + details.getSymbolicName();
+        assertTrue(details.getIconUrl().contains(iconUrl), "expected brooklyn URL for icon image, but got: " + details.getIconUrl());
+    }
+
+    @Test
+    @Deprecated
+    // If we move to using a yaml catalog item, the details will be of the wrapping app,
+    // not of the entity itself, so the test won't make sense any more.
+    public void testGetCatalogEntityPlusVersionDetails() {
+        CatalogEntitySummary details = client()
+                .resource(URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStore:0.0.0.SNAPSHOT"))
+                .get(CatalogEntitySummary.class);
+        assertTrue(details.toString().contains("redis.port"), "expected more config, only got: "+details);
+        String expectedIconUrl = "/v1/catalog/icon/" + details.getSymbolicName() + "/" + details.getVersion();
+        assertEquals(details.getIconUrl(), expectedIconUrl, "expected brooklyn URL for icon image ("+expectedIconUrl+"), but got: "+details.getIconUrl());
+    }
+
+    @Test
+    public void testGetCatalogEntityIconDetails() throws IOException {
+        String catalogItemId = "testGetCatalogEntityIconDetails";
+        addTestCatalogItem(catalogItemId);
+        ClientResponse response = client().resource(URI.create("/v1/catalog/icon/" + catalogItemId + "/" + TEST_VERSION))
+                .get(ClientResponse.class);
+        response.bufferEntity();
+        Assert.assertEquals(response.getStatus(), 200);
+        Assert.assertEquals(response.getType(), MediaType.valueOf("image/png"));
+        Image image = Toolkit.getDefaultToolkit().createImage(Files.readFile(response.getEntityInputStream()));
+        Assert.assertNotNull(image);
+    }
+
+    private void addTestCatalogItem(String catalogItemId) {
+        String yaml =
+                "brooklyn.catalog:\n"+
+                "  id: " + catalogItemId + "\n"+
+                "  name: My Catalog App\n"+
+                "  description: My description\n"+
+                "  icon_url: classpath:///redis-logo.png\n"+
+                "  version: " + TEST_VERSION + "\n"+
+                "\n"+
+                "services:\n"+
+                "- type: brooklyn.entity.nosql.redis.RedisStore\n";
+
+        client().resource("/v1/catalog").post(yaml);
+    }
+
+    @Test
+    public void testListPolicies() {
+        Set<CatalogItemSummary> policies = client().resource("/v1/catalog/policies")
+                .get(new GenericType<Set<CatalogItemSummary>>() {});
+
+        assertTrue(policies.size() > 0);
+        CatalogItemSummary asp = null;
+        for (CatalogItemSummary p : policies) {
+            if (AutoScalerPolicy.class.getName().equals(p.getType()))
+                asp = p;
+        }
+        Assert.assertNotNull(asp, "didn't find AutoScalerPolicy");
+    }
+
+    @Test
+    public void testDeleteCustomEntityFromCatalog() {
+        String symbolicName = "my.catalog.app.id.to.subsequently.delete";
+        String yaml =
+                "name: "+symbolicName+"\n"+
+                // FIXME name above should be unnecessary when brooklyn.catalog below is working
+                "brooklyn.catalog:\n"+
+                "  id: " + symbolicName + "\n"+
+                "  name: My Catalog App To Be Deleted\n"+
+                "  description: My description\n"+
+                "  version: " + TEST_VERSION + "\n"+
+                "\n"+
+                "services:\n"+
+                "- type: brooklyn.test.entity.TestEntity\n";
+
+        client().resource("/v1/catalog")
+                .post(ClientResponse.class, yaml);
+
+        ClientResponse deleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
+                .delete(ClientResponse.class);
+
+        assertEquals(deleteResponse.getStatus(), Response.Status.NO_CONTENT.getStatusCode());
+
+        ClientResponse getPostDeleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
+                .get(ClientResponse.class);
+        assertEquals(getPostDeleteResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
+    }
+
+    private static String ver(String id) {
+        return CatalogUtils.getVersionedId(id, TEST_VERSION);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bfac921f/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
index a3573fa..0511ca4 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
@@ -53,63 +53,62 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
     private static final Logger log = LoggerFactory.getLogger(LocationResourceTest.class);
     private URI addedLocationUri;
     
-  @Test
-  public void testAddNewLocation() {
-    Map<String, String> expectedConfig = ImmutableMap.of(
-        "identity", "bob",
-        "credential", "CR3dential",
-        "location", "us-east-1");
-    ClientResponse response = client().resource("/v1/locations")
-        .type(MediaType.APPLICATION_JSON_TYPE)
-        .post(ClientResponse.class, new LocationSpec("my-jungle", "aws-ec2", expectedConfig));
+    @Test
+    public void testAddNewLocation() {
+        Map<String, String> expectedConfig = ImmutableMap.of(
+                "identity", "bob",
+                "credential", "CR3dential",
+                "location", "us-east-1");
+        ClientResponse response = client().resource("/v1/locations")
+                .type(MediaType.APPLICATION_JSON_TYPE)
+                .post(ClientResponse.class, new LocationSpec("my-jungle", "aws-ec2", expectedConfig));
 
-    addedLocationUri = response.getLocation();
-    log.info("added, at: "+addedLocationUri);
-    LocationSummary location = client().resource(response.getLocation()).get(LocationSummary.class);
-    log.info(" contents: "+location);
-    assertThat(location.getSpec(), is("aws-ec2"));
+        addedLocationUri = response.getLocation();
+        log.info("added, at: " + addedLocationUri);
+        LocationSummary location = client().resource(response.getLocation()).get(LocationSummary.class);
+        log.info(" contents: " + location);
+        assertThat(location.getSpec(), is("aws-ec2"));
 
-    assertThat(location.getConfig().get("identity"), is((Object)"bob"));
-    assertFalse(location.getConfig().containsKey("CR3dential"));
-    Assert.assertTrue(addedLocationUri.toString().startsWith("/v1/locations/"));
-    
-    JcloudsLocation l = (JcloudsLocation) getManagementContext().getLocationRegistry().resolve(location.getId());
-    Assert.assertEquals(l.getProvider(), "aws-ec2");
-  }
+        assertThat(location.getConfig().get("identity"), is((Object) "bob"));
+        assertFalse(location.getConfig().containsKey("CR3dential"));
+        Assert.assertTrue(addedLocationUri.toString().startsWith("/v1/locations/"));
+
+        JcloudsLocation l = (JcloudsLocation) getManagementContext().getLocationRegistry().resolve(location.getId());
+        Assert.assertEquals(l.getProvider(), "aws-ec2");
+    }
 
-  @Test(dependsOnMethods={"testAddNewLocation"})
-  public void testListAllLocations() {
-    Set<LocationSummary> locations = client().resource("/v1/locations")
-        .get(new GenericType<Set<LocationSummary>>() {
+    @Test(dependsOnMethods = { "testAddNewLocation" })
+    public void testListAllLocations() {
+        Set<LocationSummary> locations = client().resource("/v1/locations")
+                .get(new GenericType<Set<LocationSummary>>() {});
+        Iterable<LocationSummary> matching = Iterables.filter(locations, new Predicate<LocationSummary>() {
+            @Override
+            public boolean apply(@Nullable LocationSummary l) {
+                return "my-jungle".equals(l.getName());
+            }
         });
-    Iterable<LocationSummary> matching = Iterables.filter(locations, new Predicate<LocationSummary>() {
-        @Override
-        public boolean apply(@Nullable LocationSummary l) {
-            return "my-jungle".equals(l.getName());
-        }
-    });
-    LocationSummary location = Iterables.getOnlyElement(matching);
-    assertThat(location.getSpec(), is("aws-ec2"));
-    Assert.assertEquals(location.getLinks().get("self"), addedLocationUri);
-  }
+        LocationSummary location = Iterables.getOnlyElement(matching);
+        assertThat(location.getSpec(), is("aws-ec2"));
+        Assert.assertEquals(location.getLinks().get("self"), addedLocationUri);
+    }
 
-  @Test(dependsOnMethods={"testListAllLocations"})
-  public void testGetASpecificLocation() {
-    LocationSummary location = client().resource(addedLocationUri.toString()).get(LocationSummary.class);
-    assertThat(location.getSpec(), is("aws-ec2"));
-  }
+    @Test(dependsOnMethods = { "testListAllLocations" })
+    public void testGetASpecificLocation() {
+        LocationSummary location = client().resource(addedLocationUri.toString()).get(LocationSummary.class);
+        assertThat(location.getSpec(), is("aws-ec2"));
+    }
 
-  @Test(dependsOnMethods = {"testGetASpecificLocation"})
-  public void testDeleteLocation() {
-    final int size = getLocationRegistry().getDefinedLocations().size();
+    @Test(dependsOnMethods = { "testGetASpecificLocation" })
+    public void testDeleteLocation() {
+        final int size = getLocationRegistry().getDefinedLocations().size();
 
-    ClientResponse response = client().resource(addedLocationUri).delete(ClientResponse.class);
-    assertThat(response.getStatus(), is(Response.Status.NO_CONTENT.getStatusCode()));
-      Asserts.succeedsEventually(new Runnable() {
-        @Override
-        public void run() {
-            assertThat(getLocationRegistry().getDefinedLocations().size(), is(size - 1));
-        }
-    });
-  }
+        ClientResponse response = client().resource(addedLocationUri).delete(ClientResponse.class);
+        assertThat(response.getStatus(), is(Response.Status.NO_CONTENT.getStatusCode()));
+        Asserts.succeedsEventually(new Runnable() {
+            @Override
+            public void run() {
+                assertThat(getLocationRegistry().getDefinedLocations().size(), is(size - 1));
+            }
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bfac921f/usage/rest-server/src/test/java/brooklyn/rest/resources/VersionResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/VersionResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/VersionResourceTest.java
index ce9aece..fb8ac95 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/VersionResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/VersionResourceTest.java
@@ -31,21 +31,20 @@ import com.sun.jersey.api.client.ClientResponse;
 
 public class VersionResourceTest extends BrooklynRestResourceTest {
 
-  @Test
-  public void testGetVersion() {
-    ClientResponse response = client().resource("/v1/version")
-        .get(ClientResponse.class);
-
-    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
-    String version = response.getEntity(String.class);
-
-    assertTrue(version.matches("^\\d+\\.\\d+\\.\\d+.*"));
-  }
-
-  @SuppressWarnings("deprecation")
-  @Override
-  protected void addBrooklynResources() {
-      addResource(new VersionResource());
-  }
-  
+    @Test
+    public void testGetVersion() {
+        ClientResponse response = client().resource("/v1/version")
+                .get(ClientResponse.class);
+
+        assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+        String version = response.getEntity(String.class);
+
+        assertTrue(version.matches("^\\d+\\.\\d+\\.\\d+.*"));
+    }
+
+    @SuppressWarnings("deprecation")
+    @Override
+    protected void addBrooklynResources() {
+        addResource(new VersionResource());
+    }
 }


Mime
View raw message