Repository: incubator-brooklyn Updated Branches: refs/heads/master 57129dbac -> 9fa0e3b34
Readding dependency on jackson-jaxrs Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/8e3eb0a7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/8e3eb0a7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/8e3eb0a7 Branch: refs/heads/master Commit: 8e3eb0a7958969ae98d94378a77f15baea58fa88 Parents: 15faad3 Author: Mark McKenna <[email protected]> Authored: Mon Nov 23 17:06:29 2015 +0000 Committer: Mark McKenna <[email protected]> Committed: Tue Nov 24 11:51:38 2015 +0000 ---------------------------------------------------------------------- usage/rest-client/pom.xml | 4 +++ .../rest/client/BrooklynApiRestClientTest.java | 26 ++++++++++++--- .../src/test/resources/catalog/test-catalog.bom | 33 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8e3eb0a7/usage/rest-client/pom.xml ---------------------------------------------------------------------- diff --git a/usage/rest-client/pom.xml b/usage/rest-client/pom.xml index a583672..d518d43 100644 --- a/usage/rest-client/pom.xml +++ b/usage/rest-client/pom.xml @@ -101,6 +101,10 @@ <groupId>org.jboss.resteasy</groupId> <artifactId>jaxrs-api</artifactId> </dependency--> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + </dependency> <dependency> <groupId>org.testng</groupId> http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8e3eb0a7/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java ---------------------------------------------------------------------- diff --git a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java index fa738d8..da5bac5 100644 --- a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java +++ b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java @@ -18,6 +18,11 @@ */ package org.apache.brooklyn.rest.client; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; import java.util.Map; @@ -98,11 +103,18 @@ public class BrooklynApiRestClientTest { log.info("locations from catalog are: "+locations); } + public void testCatalogCreate()throws Exception { + final Response response = api.getCatalogApi().create(getFileContentsAsString("catalog/test-catalog.bom")); + Asserts.assertEquals(response.getStatus(),201); + } + + + public void testApplicationApiList() throws Exception { List<ApplicationSummary> apps = api.getApplicationApi().list(null); log.info("apps are: "+apps); } - + public void testApplicationApiCreate() throws Exception { Response r1 = api.getApplicationApi().createFromYaml("name: test-1234\n" + "services: [ { type: "+TestEntity.class.getName()+" } ]"); @@ -112,14 +124,14 @@ public class BrooklynApiRestClientTest { log.info("apps with test: "+apps); Asserts.assertStringContains(apps.toString(), "test-1234"); } - + public void testApplicationApiHandledError() throws Exception { Response r1 = api.getApplicationApi().createFromYaml("name: test"); HttpAsserts.assertNotHealthyStatusCode(r1.getStatus()); // new-style messages first, old-style messages after (during switch to TypePlanTransformer) - Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(), + Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(), "invalid plan", "no services"); - Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(), + Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(), "format could not be recognized", "Unrecognized application blueprint format"); } @@ -131,4 +143,10 @@ public class BrooklynApiRestClientTest { Asserts.expectedFailureContainsIgnoreCase(e, "404", "not found"); } } + + private String getFileContentsAsString(final String filename) throws Exception { + final URL resource = getClass().getClassLoader().getResource(filename); + Asserts.assertNotNull(resource); + return new String(Files.readAllBytes(Paths.get(resource.toURI())), Charset.defaultCharset()); + } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8e3eb0a7/usage/rest-client/src/test/resources/catalog/test-catalog.bom ---------------------------------------------------------------------- diff --git a/usage/rest-client/src/test/resources/catalog/test-catalog.bom b/usage/rest-client/src/test/resources/catalog/test-catalog.bom new file mode 100644 index 0000000..698bcf2 --- /dev/null +++ b/usage/rest-client/src/test/resources/catalog/test-catalog.bom @@ -0,0 +1,33 @@ +# +# 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. +# +brooklyn.catalog: + id: simple-tomcat + version: 1.0 + itemType: template + iconUrl: http://tomcat.apache.org/images/tomcat.png + name: Simple Tomcat + license: Apache-2.0 + item: + brooklyn.config: + simple.confg: someValue + services: + - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer + id: tomcat + name: Tomcat + war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war \ No newline at end of file
