You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/12/23 12:07:14 UTC

[51/71] [abbrv] incubator-brooklyn git commit: [SERVER] use catalog entities from software-base in rest-server tests removes dependency on software-library submodule repo

[SERVER] use catalog entities from software-base in rest-server tests
removes dependency on software-library submodule repo


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1e748da4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1e748da4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1e748da4

Branch: refs/heads/master
Commit: 1e748da4a5b041ad1ee63e81a0867b2d6f597923
Parents: 356b0f9
Author: John McCabe <jo...@johnmccabe.net>
Authored: Sat Dec 19 13:48:21 2015 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Dec 21 16:43:38 2015 +0000

----------------------------------------------------------------------
 .../rest/BrooklynRestApiLauncherTest.java       |  13 +++++-----
 .../rest/resources/CatalogResourceTest.java     |  24 ++++++++-----------
 .../src/test/resources/brooklyn-test-logo.jpg   | Bin 0 -> 6986 bytes
 3 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1e748da4/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java b/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
index 03f808d..cfdcb28 100644
--- a/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
+++ b/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
@@ -24,6 +24,7 @@ import static org.apache.brooklyn.rest.BrooklynRestApiLauncher.StartMode.WEB_XML
 
 import java.util.concurrent.Callable;
 
+import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
 import org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider;
 import org.apache.brooklyn.rest.util.BrooklynRestResourceUtilsTest.SampleNoOpApplication;
 import org.apache.brooklyn.test.Asserts;
@@ -38,17 +39,17 @@ public class BrooklynRestApiLauncherTest extends BrooklynRestApiLauncherTestFixt
 
     @Test
     public void testFilterStart() throws Exception {
-        checkRestCatalogApplications(useServerForTest(baseLauncher().mode(FILTER).start()));
+        checkRestCatalogEntities(useServerForTest(baseLauncher().mode(FILTER).start()));
     }
 
     @Test
     public void testServletStart() throws Exception {
-        checkRestCatalogApplications(useServerForTest(baseLauncher().mode(SERVLET).start()));
+        checkRestCatalogEntities(useServerForTest(baseLauncher().mode(SERVLET).start()));
     }
 
     @Test
     public void testWebAppStart() throws Exception {
-        checkRestCatalogApplications(useServerForTest(baseLauncher().mode(WEB_XML).start()));
+        checkRestCatalogEntities(useServerForTest(baseLauncher().mode(WEB_XML).start()));
     }
 
     private BrooklynRestApiLauncher baseLauncher() {
@@ -57,12 +58,12 @@ public class BrooklynRestApiLauncherTest extends BrooklynRestApiLauncherTestFixt
                 .forceUseOfDefaultCatalogWithJavaClassPath(true);
     }
     
-    private static void checkRestCatalogApplications(Server server) throws Exception {
+    private static void checkRestCatalogEntities(Server server) throws Exception {
         final String rootUrl = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
         int code = Asserts.succeedsEventually(new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {
-                int code = HttpTool.getHttpStatusCode(rootUrl+"/v1/catalog/applications");
+                int code = HttpTool.getHttpStatusCode(rootUrl+"/v1/catalog/entities");
                 if (code == HttpStatus.SC_FORBIDDEN) {
                     throw new RuntimeException("Retry request");
                 } else {
@@ -71,7 +72,7 @@ public class BrooklynRestApiLauncherTest extends BrooklynRestApiLauncherTestFixt
             }
         });
         HttpAsserts.assertHealthyStatusCode(code);
-        HttpAsserts.assertContentContainsText(rootUrl+"/v1/catalog/applications", SampleNoOpApplication.class.getSimpleName());
+        HttpAsserts.assertContentContainsText(rootUrl+"/v1/catalog/entities", BrooklynNode.class.getSimpleName());
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1e748da4/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java b/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
index 2aef343..921d6fc 100644
--- a/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/brooklyn-server/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
@@ -191,7 +191,7 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
                 .queryParam("fragment", "brOOkLynENTITYmiRrOr").get(new GenericType<List<CatalogEntitySummary>>() {});
         assertEquals(entities.size(), 1);
 
-        log.info("RedisCluster-like entities are: " + entities);
+        log.info("BrooklynEntityMirror-like entities are: " + entities);
 
         List<CatalogEntitySummary> entities2 = client().resource("/v1/catalog/entities")
                 .queryParam("regex", "[Bb]ro+klynEntityMi[ro]+").get(new GenericType<List<CatalogEntitySummary>>() {});
@@ -214,11 +214,9 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
     // 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/org.apache.brooklyn.entity.nosql.redis.RedisStore"))
+                .resource(URI.create("/v1/catalog/entities/org.apache.brooklyn.entity.brooklynnode.BrooklynNode"))
                 .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());
+        assertTrue(details.toString().contains("download.url"), "expected more config, only got: "+details);
     }
 
     @Test
@@ -227,28 +225,26 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
     // 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/org.apache.brooklyn.entity.nosql.redis.RedisStore:0.0.0.SNAPSHOT"))
+                .resource(URI.create("/v1/catalog/entities/org.apache.brooklyn.entity.brooklynnode.BrooklynNode: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());
+        assertTrue(details.toString().contains("download.url"), "expected more config, only got: "+details);
     }
 
     @Test
     public void testGetCatalogEntityIconDetails() throws IOException {
         String catalogItemId = "testGetCatalogEntityIconDetails";
-        addTestCatalogItemRedisAsEntity(catalogItemId);
+        addTestCatalogItemBrooklynNodeAsEntity(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"));
+        Assert.assertEquals(response.getType(), MediaType.valueOf("image/jpeg"));
         Image image = Toolkit.getDefaultToolkit().createImage(Files.readFile(response.getEntityInputStream()));
         Assert.assertNotNull(image);
     }
 
-    private void addTestCatalogItemRedisAsEntity(String catalogItemId) {
-        addTestCatalogItem(catalogItemId, null, TEST_VERSION, "org.apache.brooklyn.entity.nosql.redis.RedisStore");
+    private void addTestCatalogItemBrooklynNodeAsEntity(String catalogItemId) {
+        addTestCatalogItem(catalogItemId, null, TEST_VERSION, "org.apache.brooklyn.entity.brooklynnode.BrooklynNode");
     }
 
     private void addTestCatalogItem(String catalogItemId, String itemType, String version, String service) {
@@ -258,7 +254,7 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
                 "  name: My Catalog App\n"+
                 (itemType!=null ? "  item_type: "+itemType+"\n" : "")+
                 "  description: My description\n"+
-                "  icon_url: classpath:///redis-logo.png\n"+
+                "  icon_url: classpath:///brooklyn-test-logo.jpg\n"+
                 "  version: " + version + "\n"+
                 "\n"+
                 "services:\n"+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1e748da4/brooklyn-server/rest/rest-server/src/test/resources/brooklyn-test-logo.jpg
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/test/resources/brooklyn-test-logo.jpg b/brooklyn-server/rest/rest-server/src/test/resources/brooklyn-test-logo.jpg
new file mode 100644
index 0000000..1fa86fe
Binary files /dev/null and b/brooklyn-server/rest/rest-server/src/test/resources/brooklyn-test-logo.jpg differ