brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [14/50] git commit: Test adding an YAML OSGi backed item to the catalog and launching it using YAML.
Date Wed, 09 Jul 2014 21:46:27 GMT
Test adding an YAML OSGi backed item to the catalog and launching it using YAML.


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

Branch: refs/heads/master
Commit: 8b41b329555022db035f5496b75fd40e47818422
Parents: f3f93b7
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Mon Jul 7 12:43:22 2014 +0300
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Jul 9 22:34:43 2014 +0100

----------------------------------------------------------------------
 .../resources/CatalogBundleResourceTest.java    | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8b41b329/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
new file mode 100644
index 0000000..fda34b0
--- /dev/null
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
@@ -0,0 +1,57 @@
+package brooklyn.rest.resources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.Response;
+
+import org.testng.annotations.Test;
+
+import brooklyn.entity.basic.BasicApplication;
+import brooklyn.management.osgi.OsgiStandaloneTest;
+import brooklyn.rest.domain.ApplicationSummary;
+import brooklyn.rest.testing.BrooklynRestResourceTest;
+
+import com.sun.jersey.api.client.ClientResponse;
+
+public class CatalogBundleResourceTest extends BrooklynRestResourceTest {
+
+    @Test
+    public void testDeployApplicationYaml() throws Exception {
+        String registeredTypeName = "my.catalog.app.id";
+        String catalogYaml =
+            "name: "+registeredTypeName+"\n"+
+            // FIXME name above should be unnecessary when brooklyn.catalog below is working
+            "brooklyn.catalog:\n"+
+            "  id: " + registeredTypeName + "\n"+
+            "  name: My Catalog App\n"+
+            "  description: My description\n"+
+            "  icon_url: classpath://path/to/myicon.jpg\n"+
+            "  version: 0.1.2\n"+
+            "  libraries:\n"+
+            "  - url: classpath:/" + OsgiStandaloneTest.BROOKLYN_TESTS_OSGI_ENTITIES_0_1_0_URL
+ "\n"+
+            "\n"+
+            "services:\n"+
+            "- type: brooklyn.osgi.tests.SimpleEntity\n";
+
+        ClientResponse catalogResponse = client().resource("/v1/catalog")
+            .post(ClientResponse.class, catalogYaml);
+
+        assertEquals(catalogResponse.getStatus(), Response.Status.CREATED.getStatusCode());
+
+        String yaml = "{ name: simple-app-yaml, location: localhost, services: [ { serviceType:
"+registeredTypeName+" } ] }";
+        
+        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");
+      }
+
+}


Mime
View raw message