brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreatu...@apache.org
Subject [03/10] brooklyn-client git commit: move rest-client to brooklyn-client
Date Sat, 10 Sep 2016 17:14:40 GMT
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
new file mode 100644
index 0000000..a305f4e
--- /dev/null
+++ b/java/pom.xml
@@ -0,0 +1,719 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>brooklyn-rest-client</artifactId>
+    <packaging>jar</packaging>
+    <name>Brooklyn REST java Client</name>
+    <description>
+        Client library for Brooklyn REST interface
+    </description>
+
+    <parent>
+        <groupId>org.apache.brooklyn</groupId>
+        <artifactId>brooklyn-client</artifactId>
+        <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rest-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jackson2-provider</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rest-server</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rest-resources</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rest-server</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-test-support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.mockwebserver</groupId>
+            <artifactId>mockwebserver</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Import-Package>*,org.jboss.resteasy.client.core.marshallers</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>Documentation</id>
+            <reporting>
+                <excludeDefaults>true</excludeDefaults>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-project-info-reports-plugin</artifactId>
+                        <version>2.4</version>
+                        <reportSets>
+                            <reportSet>
+                                <reports>
+                                    <report>index</report>
+                                    <report>modules</report>
+                                </reports>
+                            </reportSet>
+                        </reportSets>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <version>2.8</version>
+                        <configuration>
+                            <links>
+                                <link>http://download.oracle.com/javaee/6/api</link>
+                            </links>
+                            <keywords>true</keywords>
+                            <author>false</author>
+                            <quiet>true</quiet>
+                            <aggregate>false</aggregate>
+                            <detectLinks />
+                            <tags>
+                                <tag>
+                                    <name>todo</name>
+                                    <placement>a</placement>
+                                    <head>To-do:</head>
+                                </tag>
+                            </tags>
+                        </configuration>
+                        <reportSets>
+                            <reportSet>
+                                <id>javadoc</id>
+                                <reports>
+                                    <report>javadoc</report>
+                                </reports>
+                            </reportSet>
+                        </reportSets>
+                    </plugin>
+                </plugins>
+            </reporting>
+        </profile>
+        <profile>
+            <id>Bundle</id>
+            <activation>
+                <file>
+                    <!-- NB - this is all the leaf projects, including logback-* (with no src);
+                         the archetype project neatly ignores this however -->
+                    <exists>${basedir}/src</exists>
+                </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.felix</groupId>
+                        <artifactId>maven-bundle-plugin</artifactId>
+                        <extensions>true</extensions>
+                        <!-- configure plugin to generate MANIFEST.MF
+                             adapted from http://blog.knowhowlab.org/2010/06/osgi-tutorial-from-project-structure-to.html -->
+                        <executions>
+                            <execution>
+                                <id>bundle-manifest</id>
+                                <phase>process-classes</phase>
+                                <goals>
+                                    <goal>manifest</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <supportedProjectTypes>
+                                <supportedProjectType>jar</supportedProjectType>
+                            </supportedProjectTypes>
+                            <instructions>
+                                <!-- OSGi specific instruction -->
+                                <!--
+                                    By default packages containing impl and internal
+                                    are not included in the export list. Setting an
+                                    explicit wildcard will include all packages
+                                    regardless of name.
+                                    In time we should minimize our export lists to
+                                    what is really needed.
+                                -->
+                                <Export-Package>brooklyn.*,org.apache.brooklyn.*</Export-Package>
+                                <Implementation-SHA-1>${buildNumber}</Implementation-SHA-1>
+                                <Implementation-Branch>${scmBranch}</Implementation-Branch>
+                            </instructions>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <version>2.6</version>
+                        <configuration>
+                            <archive>
+                                <manifestFile> ${project.build.outputDirectory}/META-INF/MANIFEST.MF </manifestFile>
+                            </archive>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>Tests</id>
+            <activation>
+                <file> <exists>${basedir}/src/test</exists> </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <version>${surefire.version}</version>
+                        <configuration>
+                            <properties>
+                                <property>
+                                    <name>listener</name>
+                                    <value>org.apache.brooklyn.test.support.LoggingVerboseReporter,org.apache.brooklyn.test.support.BrooklynLeakListener,org.apache.brooklyn.test.support.PlatformTestSelectorListener</value>
+                                </property>
+                            </properties>
+                            <enableAssertions>true</enableAssertions>
+                            <groups>${includedTestGroups}</groups>
+                            <excludedGroups>${excludedTestGroups}</excludedGroups>
+                            <testFailureIgnore>false</testFailureIgnore>
+                            <systemPropertyVariables>
+                                <verbose>-1</verbose>
+                                <net.sourceforge.cobertura.datafile>${project.build.directory}/cobertura/cobertura.ser</net.sourceforge.cobertura.datafile>
+                                <cobertura.user.java.nio>false</cobertura.user.java.nio>
+                            </systemPropertyVariables>
+                            <printSummary>true</printSummary>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <inherited>true</inherited>
+                        <executions>
+                            <execution>
+                                <id>test-jar-creation</id>
+                                <goals>
+                                    <goal>test-jar</goal>
+                                </goals>
+                                <configuration>
+                                    <forceCreation>true</forceCreation>
+                                    <archive combine.self="override" />
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>Integration</id>
+            <properties>
+                <includedTestGroups>Integration</includedTestGroups>
+                <excludedTestGroups>Acceptance,Live,WIP,Broken</excludedTestGroups>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <inherited>true</inherited>
+                        <executions>
+                            <execution>
+                                <id>run-tests</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>integration-test</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>Acceptance</id>
+            <properties>
+                <includedTestGroups>Acceptance</includedTestGroups>
+                <excludedTestGroups>Integration,Live,WIP,Broken</excludedTestGroups>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <inherited>true</inherited>
+                        <executions>
+                            <execution>
+                                <id>run-tests</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>integration-test</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>Live</id>
+            <properties>
+                <includedTestGroups>Live</includedTestGroups>
+                <excludedTestGroups>Acceptance,WIP,Broken</excludedTestGroups>
+            </properties>
+        </profile>
+
+        <profile>
+            <id>Live-sanity</id>
+            <properties>
+                <includedTestGroups>Live-sanity</includedTestGroups>
+                <excludedTestGroups>Acceptance,WIP,Broken</excludedTestGroups>
+            </properties>
+        </profile>
+
+        <profile>
+            <id>CI</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>findbugs-maven-plugin</artifactId>
+                        <configuration>
+                            <xmlOutput>true</xmlOutput>
+                            <xmlOutputDirectory>target/site</xmlOutputDirectory>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>process-classes</phase>
+                                <goals>
+                                    <goal>findbugs</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-pmd-plugin</artifactId>
+                        <version>2.5</version>
+                        <inherited>true</inherited>
+                        <configuration>
+                            <failOnViolation>false</failOnViolation>
+                            <linkXref>true</linkXref>
+                            <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
+                            <minimumTokens>100</minimumTokens>
+                            <targetJdk>${java.version}</targetJdk>
+                            <excludes>
+                                <exclude>**/*Test.java</exclude>
+                                <exclude>**/tests/**/*.java</exclude>
+                                <!-- add any more generated source code directories here -->
+                            </excludes>
+                            <excludeRoots>
+                                <excludeRoot>
+                                    ${pom.basedir}/target/generated-sources/groovy-stubs/main
+                                </excludeRoot>
+                            </excludeRoots>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>process-classes</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                    <goal>cpd-check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>Coverage</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>cobertura-maven-plugin</artifactId>
+                    <version>${cobertura.plugin.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <inherited>true</inherited>
+                        <executions>
+                            <execution>
+                                <id>run-tests</id>
+                            </execution>
+                            <execution>
+                                <id>instrument classes</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>process-test-classes</phase>
+                                <configuration>
+                                    <target>
+                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
+                                        <taskdef resource="tasks.properties" classpathref="maven.plugin.classpath" />
+                                        <if>
+                                            <available property="gogocobertura" file="target/test-classes" />
+                                            <then>
+                                                <echo message="INSTRUMENTING CLASSES FOR COBERTURA" />
+                                                <!-- Ensure any and all bits of our project are copied in first -->
+                                                <copy todir="target/cobertura/coverage-classes">
+                                                    <fileset erroronmissingdir="false" dir="target/classes" />
+                                                </copy>
+                                                <cobertura-instrument datafile="target/cobertura/cobertura.ser" todir="target/test-classes">
+                                                    <fileset erroronmissingdir="false" dir="target/classes">
+                                                        <include name="brooklyn/**/*.class" />
+                                                        <exclude name="brooklyn/**/*Test.class" />
+                                                    </fileset>
+                                                    <fileset erroronmissingdir="false" dir="target/cobertura/dependency-classes">
+                                                        <include name="brooklyn/**/*.class" />
+                                                        <exclude name="brooklyn/**/*Test.class" />
+                                                    </fileset>
+                                                </cobertura-instrument>
+                                            </then>
+                                        </if>
+                                    </target>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>coverage report</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>post-integration-test</phase>
+                                <configuration>
+                                    <target>
+                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
+                                        <taskdef resource="tasks.properties" classpathref="maven.plugin.classpath" />
+                                        <if>
+                                            <available property="gogocobertura" file="target/cobertura/cobertura.ser" />
+                                            <then>
+                                                <echo message="GENERATING COBERTURA COVERAGE REPORT" />
+                                                <cobertura-report format="xml" destdir="target/site/cobertura" datafile="target/cobertura/cobertura.ser">
+                                                    <fileset erroronmissingdir="false" dir="src/main/java" />
+                                                    <fileset erroronmissingdir="false" dir="target/cobertura/dependency-sources" />
+                                                </cobertura-report>
+                                                <cobertura-report format="html" destdir="target/site/cobertura" datafile="target/cobertura/cobertura.ser">
+                                                    <fileset erroronmissingdir="false" dir="src/main/java" />
+                                                    <fileset erroronmissingdir="false" dir="target/cobertura/dependency-sources" />
+                                                </cobertura-report>
+                                            </then>
+                                        </if>
+                                    </target>
+                                </configuration>
+                            </execution>
+                        </executions>
+                        <dependencies>
+                            <dependency>
+                                <groupId>ant-contrib</groupId>
+                                <artifactId>ant-contrib</artifactId>
+                                <version>1.0b3</version>
+                                <exclusions>
+                                    <exclusion>
+                                        <groupId>ant</groupId>
+                                        <artifactId>ant</artifactId>
+                                    </exclusion>
+                                </exclusions>
+                            </dependency>
+                            <dependency>
+                                <groupId>org.apache.ant</groupId>
+                                <artifactId>ant-launcher</artifactId>
+                                <version>${ant.version}</version>
+                            </dependency>
+                            <dependency>
+                                <groupId>org.apache.ant</groupId>
+                                <artifactId>ant</artifactId>
+                                <version>${ant.version}</version>
+                            </dependency>
+                            <dependency>
+                                <groupId>org.testng</groupId>
+                                <artifactId>testng</artifactId>
+                                <version>${testng.version}</version>
+                            </dependency>
+                            <dependency>
+                                <groupId>org.codehaus.mojo</groupId>
+                                <artifactId>cobertura-maven-plugin</artifactId>
+                                <version>${cobertura.plugin.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-dependency-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>unpack-coverage-sources</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>unpack-dependencies</goal>
+                                </goals>
+                                <configuration>
+                                    <classifier>sources</classifier>
+                                    <includeScope>compile</includeScope>
+                                    <includeGroupIds>brooklyn</includeGroupIds>
+                                    <outputDirectory>
+                                        ${project.build.directory}/cobertura/dependency-sources
+                                    </outputDirectory>
+                                    <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>unpack-coverage-classes</id>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>unpack-dependencies</goal>
+                                </goals>
+                                <configuration>
+                                    <type>jar</type>
+                                    <includeScope>compile</includeScope>
+                                    <includeGroupIds>brooklyn</includeGroupIds>
+                                    <outputDirectory>
+                                        ${project.build.directory}/cobertura/dependency-classes
+                                    </outputDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <version>${surefire.version}</version>
+                        <inherited>true</inherited>
+                        <configuration>
+                            <reportFormat>xml</reportFormat>
+                            <classesDirectory>${project.build.directory}/cobertura/coverage-classes</classesDirectory>
+                            <systemProperties>
+                                <property>
+                                    <name>net.sourceforge.cobertura.datafile</name>
+                                    <value>${project.build.directory}/cobertura/cobertura.ser
+                                    </value>
+                                </property>
+                                <property>
+                                    <name>cobertura.user.java.nio</name>
+                                    <value>false</value>
+                                </property>
+                            </systemProperties>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>test-jar-creation</id>
+                                <configuration>
+                                    <skip>true</skip>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <configuration>
+                            <skip>true</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- build sources jars by default, it's quick -->
+        <profile>
+            <id>make-sources-jar</id>
+            <activation> <property><name>!skipSources</name></property> </activation>
+            <build><plugins><plugin>
+                <artifactId>maven-source-plugin</artifactId>
+            </plugin></plugins></build>
+        </profile>
+
+        <!-- only build javadoc if asked, or if deploying (it's slow) -->
+        <profile>
+            <id>make-javadoc-jar</id>
+            <activation> <property><name>javadoc</name></property> </activation>
+            <build><plugins><plugin>
+                <artifactId>maven-javadoc-plugin</artifactId>
+            </plugin></plugins></build>
+        </profile>
+
+        <!-- sign and make javadoc when deploying; note, this means you'll need gpg set up to deploy -->
+        <profile>
+            <id>make-more-things-when-deploying</id>
+            <activation> <property><name>brooklyn.deployTo</name></property> </activation>
+            <build><plugins>
+                <plugin>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-gpg-plugin</artifactId>
+                </plugin>
+            </plugins></build>
+        </profile>
+        <profile>
+            <id>apache-repo</id>
+            <activation> <property><name>brooklyn.deployTo</name><value>apache</value></property> </activation>
+            <!-- distributionManagement configured by the parent Apache POM -->
+        </profile>
+        <profile>
+            <id>rat-check</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.rat</groupId>
+                        <artifactId>apache-rat-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>rat-check</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>eclipse-compiler</id>
+            <build>
+                <pluginManagement>
+                    <plugins>
+                        <plugin>
+                            <groupId>org.apache.maven.plugins</groupId>
+                            <artifactId>maven-compiler-plugin</artifactId>
+                            <configuration>
+                                <compilerId>eclipse</compilerId>
+                                <optimize>true</optimize>
+                            </configuration>
+                            <dependencies>
+                                <dependency>
+                                    <groupId>org.codehaus.plexus</groupId>
+                                    <artifactId>plexus-compiler-eclipse</artifactId>
+                                    <version>2.6</version>
+                                </dependency>
+                            </dependencies>
+                        </plugin>
+                    </plugins>
+                </pluginManagement>
+            </build>
+        </profile>
+    </profiles>
+
+</project>

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
new file mode 100644
index 0000000..822e296
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
@@ -0,0 +1,419 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.client;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.annotation.Nullable;
+import javax.ws.rs.core.Response;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.jboss.resteasy.client.ClientExecutor;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyBuilder;
+import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
+import org.jboss.resteasy.client.core.extractors.DefaultEntityExtractorFactory;
+import org.jboss.resteasy.specimpl.BuiltResponse;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.resteasy.util.GenericType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+import org.apache.brooklyn.rest.api.AccessApi;
+import org.apache.brooklyn.rest.api.ActivityApi;
+import org.apache.brooklyn.rest.api.ApplicationApi;
+import org.apache.brooklyn.rest.api.CatalogApi;
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.api.EntityApi;
+import org.apache.brooklyn.rest.api.EntityConfigApi;
+import org.apache.brooklyn.rest.api.LocationApi;
+import org.apache.brooklyn.rest.api.PolicyApi;
+import org.apache.brooklyn.rest.api.PolicyConfigApi;
+import org.apache.brooklyn.rest.api.ScriptApi;
+import org.apache.brooklyn.rest.api.SensorApi;
+import org.apache.brooklyn.rest.api.ServerApi;
+import org.apache.brooklyn.rest.api.UsageApi;
+import org.apache.brooklyn.rest.api.VersionApi;
+import org.apache.brooklyn.rest.client.util.http.BuiltResponsePreservingError;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.javalang.AggregateClassLoader;
+import org.apache.brooklyn.util.net.Urls;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * @author Adam Lowe
+ */
+@SuppressWarnings("deprecation")
+public class BrooklynApi {
+
+    private final String target;
+    private final ClientExecutor clientExecutor;
+    private final int maxPoolSize;
+    private final int timeOutInMillis;
+    private static final Logger LOG = LoggerFactory.getLogger(BrooklynApi.class);
+
+    /**
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(URL endpoint) {
+        this(checkNotNull(endpoint, "endpoint").toString());
+    }
+
+    /**
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(String endpoint) {
+        // username/password cannot be null, but credentials can
+        this(endpoint, null);
+    }
+
+    /**
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(URL endpoint, String username, String password) {
+        this(endpoint.toString(), new UsernamePasswordCredentials(username, password));
+    }
+
+    /**
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(String endpoint, String username, String password) {
+        this(endpoint, new UsernamePasswordCredentials(username, password));
+    }
+
+    /**
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(URL endpoint, @Nullable Credentials credentials) {
+        this(endpoint.toString(), credentials);
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+     */
+    @Deprecated
+    public BrooklynApi(String endpoint, @Nullable Credentials credentials) {
+        this(endpoint, credentials, 20, 5000);
+    }
+
+    /**
+     * Creates a BrooklynApi using a custom ClientExecutor
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @param clientExecutor the ClientExecutor
+     * @see #getClientExecutor(org.apache.http.auth.Credentials)
+     */
+    public BrooklynApi(URL endpoint, ClientExecutor clientExecutor) {
+        this.target = addV1SuffixIfNeeded(checkNotNull(endpoint, "endpoint").toString());
+        this.maxPoolSize = -1;
+        this.timeOutInMillis = -1;
+        this.clientExecutor = checkNotNull(clientExecutor, "clientExecutor");
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @param credentials user credentials or null
+     * @param maxPoolSize maximum pool size
+     * @param timeOutInMillis connection timeout in milliseconds
+     */
+    public BrooklynApi(String endpoint, @Nullable Credentials credentials, int maxPoolSize, int timeOutInMillis) {
+        try {
+            new URL(checkNotNull(endpoint, "endpoint"));
+        } catch (MalformedURLException e) {
+            throw new IllegalArgumentException(e);
+        }
+        this.target = addV1SuffixIfNeeded(endpoint);
+        this.maxPoolSize = maxPoolSize;
+        this.timeOutInMillis = timeOutInMillis;
+        this.clientExecutor = getClientExecutor(credentials);
+    }
+
+    private String addV1SuffixIfNeeded(String endpoint) {
+        if (!endpoint.endsWith("/v1/") && !endpoint.endsWith("/v1")) {
+            return Urls.mergePaths(endpoint, "v1");
+        } else {
+            return endpoint;
+        }
+    }
+
+    private Supplier<PoolingHttpClientConnectionManager> connectionManagerSupplier = Suppliers.memoize(new Supplier<PoolingHttpClientConnectionManager>() {
+        @Override
+        public PoolingHttpClientConnectionManager get() {
+            PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
+            connManager.setMaxTotal(maxPoolSize);
+            connManager.setDefaultMaxPerRoute(maxPoolSize);
+            return connManager;
+        }
+    });
+
+    private Supplier<RequestConfig> reqConfSupplier = Suppliers.memoize(new Supplier<RequestConfig>() {
+        @Override
+        public RequestConfig get() {
+            return RequestConfig.custom()
+                    .setConnectTimeout(timeOutInMillis)
+                    .setConnectionRequestTimeout(timeOutInMillis)
+                    .build();
+        }
+    });
+
+    /**
+     * Creates a ClientExecutor for this BrooklynApi
+     */
+    protected ClientExecutor getClientExecutor(Credentials credentials) {
+        CredentialsProvider provider = new BasicCredentialsProvider();
+        if (credentials != null) provider.setCredentials(AuthScope.ANY, credentials);
+
+        CloseableHttpClient httpClient = HttpClients.custom()
+                .setDefaultCredentialsProvider(provider)
+                .setDefaultRequestConfig(reqConfSupplier.get())
+                .setConnectionManager(connectionManagerSupplier.get())
+                .build();
+
+        return new ApacheHttpClient4Executor(httpClient);
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @return a new BrooklynApi instance
+     */
+    public static BrooklynApi newInstance(String endpoint) {
+        return new BrooklynApi(endpoint, null);
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @param maxPoolSize maximum connection pool size
+     * @param timeOutInMillis connection timeout in millisecond
+     * @return a new BrooklynApi instance
+     */
+    public static BrooklynApi newInstance(String endpoint, int maxPoolSize, int timeOutInMillis) {
+        return new BrooklynApi(endpoint, null, maxPoolSize, timeOutInMillis);
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @param username for authentication
+     * @param password for authentication
+     * @return a new BrooklynApi instance
+     */
+    public static BrooklynApi newInstance(String endpoint, String username, String password) {
+        return new BrooklynApi(endpoint, new UsernamePasswordCredentials(username, password));
+    }
+
+    /**
+     * Creates a BrooklynApi using an HTTP connection pool
+     *
+     * @param endpoint the Brooklyn endpoint
+     * @param username for authentication
+     * @param password for authentication
+     * @param maxPoolSize maximum connection pool size
+     * @param timeOutInMillis connection timeout in millisecond
+     * @return a new BrooklynApi instance
+     */
+    public static BrooklynApi newInstance(String endpoint, String username, String password, int maxPoolSize, int timeOutInMillis) {
+        return new BrooklynApi(endpoint, new UsernamePasswordCredentials(username, password), maxPoolSize, timeOutInMillis);
+    }
+
+    @SuppressWarnings("unchecked")
+    private <T> T proxy(Class<T> clazz) {
+        AggregateClassLoader aggregateClassLoader =  AggregateClassLoader.newInstanceWithNoLoaders();
+        aggregateClassLoader.addLast(clazz.getClassLoader());
+        aggregateClassLoader.addLast(getClass().getClassLoader());
+
+        final T result0 = ProxyBuilder.build(clazz, target)
+                .executor(clientExecutor)
+                .classloader(aggregateClassLoader)
+                .providerFactory(ResteasyProviderFactory.getInstance())
+                .extractorFactory(new DefaultEntityExtractorFactory())
+                .requestAttributes(MutableMap.<String, Object>of())
+                .now();
+
+        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, new InvocationHandler() {
+            @Override
+            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+                try {
+                    Object result1 = method.invoke(result0, args);
+                    Class<?> type = String.class;
+                    if (result1 instanceof Response) {
+                        Response resp = (Response)result1;
+                        if(isStatusCodeHealthy(resp.getStatus()) && method.isAnnotationPresent(ApiOperation.class)) {
+                           type = getClassFromMethodAnnotationOrDefault(method, type);
+                        }
+                        // wrap the original response so it self-closes
+                        result1 = BuiltResponsePreservingError.copyResponseAndClose(resp, type);
+                    }
+                    return result1;
+                } catch (Throwable e) {
+                    if (e instanceof InvocationTargetException) {
+                        // throw the original exception
+                        e = ((InvocationTargetException)e).getTargetException();
+                    }
+                    throw Exceptions.propagate(e);
+                }
+            }
+
+            private boolean isStatusCodeHealthy(int code) { return (code>=200 && code<=299); }
+
+            private Class<?> getClassFromMethodAnnotationOrDefault(Method method, Class<?> def){
+                Class<?> type;
+                try{
+                    type = method.getAnnotation(ApiOperation.class).response();
+                } catch (Exception e) {
+                    type = def;
+                    LOG.debug("Unable to get class from annotation: {}.  Defaulting to {}", e.getMessage(), def.getName());
+                    Exceptions.propagateIfFatal(e);
+                }
+                return type;
+            }
+        });
+    }
+
+    public ActivityApi getActivityApi() {
+        return proxy(ActivityApi.class);
+    }
+
+    public ApplicationApi getApplicationApi() {
+        return proxy(ApplicationApi.class);
+    }
+
+    public CatalogApi getCatalogApi() {
+        return proxy(CatalogApi.class);
+    }
+
+    public EffectorApi getEffectorApi() {
+        return proxy(EffectorApi.class);
+    }
+
+    public EntityConfigApi getEntityConfigApi() {
+        return proxy(EntityConfigApi.class);
+    }
+
+    public EntityApi getEntityApi() {
+        return proxy(EntityApi.class);
+    }
+
+    public LocationApi getLocationApi() {
+        return proxy(LocationApi.class);
+    }
+
+    public PolicyConfigApi getPolicyConfigApi() {
+        return proxy(PolicyConfigApi.class);
+    }
+
+    public PolicyApi getPolicyApi() {
+        return proxy(PolicyApi.class);
+    }
+
+    public ScriptApi getScriptApi() {
+        return proxy(ScriptApi.class);
+    }
+
+    public SensorApi getSensorApi() {
+        return proxy(SensorApi.class);
+    }
+
+    public ServerApi getServerApi() {
+        return proxy(ServerApi.class);
+    }
+
+    public UsageApi getUsageApi() {
+        return proxy(UsageApi.class);
+    }
+
+    public VersionApi getVersionApi() {
+        return proxy(VersionApi.class);
+    }
+
+    public AccessApi getAccessApi() {
+        return proxy(AccessApi.class);
+    }
+
+    public static <T> T getEntity(Response response, Class<T> type) {
+        if (response instanceof ClientResponse) {
+            ClientResponse<?> clientResponse = (ClientResponse<?>) response;
+            return clientResponse.getEntity(type);
+        } else if (response instanceof BuiltResponse) {
+            // Handle BuiltResponsePreservingError turning objects into Strings
+            if (response.getEntity() instanceof String && !type.equals(String.class)) {
+                return new Gson().fromJson(response.getEntity().toString(), type);
+            }
+        }
+        // Last-gasp attempt.
+        return type.cast(response.getEntity());
+    }
+
+    public static <T> T getEntity(Response response, GenericType<T> type) {
+        if (response instanceof ClientResponse) {
+            ClientResponse<?> clientResponse = (ClientResponse<?>) response;
+            return clientResponse.getEntity(type);
+        } else if (response instanceof BuiltResponse) {
+            // Handle BuiltResponsePreservingError turning objects into Strings
+            if (response.getEntity() instanceof String) {
+                return new Gson().fromJson(response.getEntity().toString(), type.getGenericType());
+            }
+        }
+        // Last-gasp attempt.
+        return type.getType().cast(response.getEntity());
+    }
+
+    /**
+     * @deprecated since 0.8.0-incubating. Use {@link #getEntity(Response, GenericType)} instead.
+     */
+    @Deprecated
+    public static <T> T getEntityGeneric(Response response, GenericType<T> type) {
+        return getEntity(response, type);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
new file mode 100644
index 0000000..ce57da5
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.rest.client;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class BrooklynApiUtil {
+
+    private static final Logger LOG = LoggerFactory.getLogger(BrooklynApiUtil.class);
+    private static final Duration DEFAULT_POLL_PERIOD = Duration.FIVE_SECONDS;
+    private static final Duration DEFAULT_TIMEOUT = Duration.FIVE_MINUTES;
+
+    private BrooklynApiUtil() {}
+
+    /**
+     * Deploys the blueprint and returns the task summary.
+     * @throws Exception If the response from the server when deploying was {@link #isUnhealthyResponse unhealthy}.
+     */
+    public static TaskSummary deployBlueprint(BrooklynApi api, String blueprint) throws Exception {
+        Response r = api.getApplicationApi().createFromYaml(blueprint);
+        if (isUnhealthyResponse(r)) {
+            throw new Exception("Unexpected response deploying blueprint to server: " + r.getStatus());
+        } else {
+            LOG.debug("Server response to deploy blueprint: " + r.getStatus());
+        }
+        return BrooklynApi.getEntity(r, TaskSummary.class);
+    }
+
+    /**
+     * Waits for the application with the given ID to be running.
+     *
+     * @throws IllegalStateException If the application was not running after {@link #DEFAULT_TIMEOUT}.
+     */
+    public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String applicationId, String taskId) throws IllegalStateException {
+        waitForRunningAndThrowOtherwise(api, applicationId, taskId, DEFAULT_TIMEOUT);
+    }
+
+    /**
+     * Waits for the application with the given ID to be running.
+     *
+     * @throws IllegalStateException If the application was not running after the given timeout.
+     */
+    public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String applicationId, String taskId, Duration timeout) throws IllegalStateException {
+        Status finalStatus = waitForAppStatus(api, applicationId, Status.RUNNING, timeout, DEFAULT_POLL_PERIOD);
+        if (!Status.RUNNING.equals(finalStatus)) {
+            LOG.error("Application is not running. Is: " + finalStatus.name().toLowerCase());
+
+            StringBuilder message = new StringBuilder();
+            message.append("Application ").append(applicationId)
+                    .append(" should be running but is ").append(finalStatus.name().toLowerCase())
+                    .append(". ");
+
+            if (Status.ERROR.equals(finalStatus) || Status.UNKNOWN.equals(finalStatus)) {
+                String result = getTaskResult(api, taskId);
+                message.append("\nThe result of the task on the server was:\n")
+                        .append(result);
+            }
+            throw new IllegalStateException(message.toString());
+        }
+    }
+
+    /**
+     * Polls Brooklyn until the given application has the given status. Quits early if the
+     * application's status is {@link org.apache.brooklyn.rest.domain.Status#ERROR} or
+     * {@link org.apache.brooklyn.rest.domain.Status#UNKNOWN} and desiredStatus is something else.
+     *
+     * @return The final polled status.
+     */
+    public static Status waitForAppStatus(final BrooklynApi api, final String application, final Status desiredStatus,
+            Duration timeout, Duration pollPeriod) {
+        final AtomicReference<Status> appStatus = new AtomicReference<>(Status.UNKNOWN);
+        final boolean shortcutOnError = !Status.ERROR.equals(desiredStatus) && !Status.UNKNOWN.equals(desiredStatus);
+        LOG.info("Waiting " + timeout + " from " + new Date() + " for application " + application + " to be " + desiredStatus);
+        boolean finalAppStatusKnown = Repeater.create("Waiting for application " + application + " status to be " + desiredStatus)
+                .every(pollPeriod)
+                .limitTimeTo(timeout)
+                .rethrowExceptionImmediately()
+                .until(new Callable<Boolean>() {
+                    @Override
+                    public Boolean call() throws Exception {
+                        Status status = api.getApplicationApi().get(application).getStatus();
+                        LOG.debug("Application " + application + " status is: " + status);
+                        appStatus.set(status);
+                        return desiredStatus.equals(status) || (shortcutOnError &&
+                                (Status.ERROR.equals(status) || Status.UNKNOWN.equals(status)));
+                    }
+                })
+                .run();
+        if (appStatus.get().equals(desiredStatus)) {
+            LOG.info("Application " + application + " is " + desiredStatus.name());
+        } else {
+            LOG.warn("Application is not " + desiredStatus.name() + " within " + timeout +
+                    ". Status is: " + appStatus.get());
+        }
+        return appStatus.get();
+    }
+
+    /**
+     * Use the {@link EffectorApi effector API} to invoke the stop effector on the given application.
+     */
+    public static void attemptStop(BrooklynApi api, String application, Duration timeout) {
+        api.getEffectorApi().invoke(application, application, "stop", String.valueOf(timeout.toMilliseconds()),
+                ImmutableMap.<String, Object>of());
+    }
+
+    /**
+     * @return The result of the task with the given id, or "unknown" if it could not be found.
+     */
+    public static String getTaskResult(BrooklynApi api, String taskId) {
+        checkNotNull(taskId, "taskId");
+        TaskSummary summary = api.getActivityApi().get(taskId);
+        return summary == null || summary.getResult() == null ? "unknown" : summary.getResult().toString();
+    }
+
+    /**
+     * @return true if response's status code is not between 200 and 299 inclusive.
+     */
+    public static boolean isUnhealthyResponse(Response response) {
+        return response.getStatus() < 200 || response.getStatus() >= 300;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java b/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
new file mode 100644
index 0000000..d011172
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.client.util.http;
+
+import java.lang.annotation.Annotation;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.jboss.resteasy.client.core.BaseClientResponse;
+import org.jboss.resteasy.core.Headers;
+import org.jboss.resteasy.specimpl.BuiltResponse;
+
+/** 
+ * Allows wrapping a {@link Response} with the stream fully read and closed so that the client can be re-used.
+ * <p>
+ * The entity may be stored as a string as type info is not available when it is deserialized, 
+ * and that's a relatively convenient common format.
+ *  
+ * TODO It would be nice to support other parsing, storing the byte array.
+ */
+public class BuiltResponsePreservingError extends BuiltResponse {
+
+    private Throwable error;
+
+    public BuiltResponsePreservingError(int status, Headers<Object> headers, Object entity, Annotation[] annotations, Throwable error) {
+        super(status, headers, entity, annotations);
+        this.error = error;
+    }
+    
+    @SuppressWarnings("deprecation")
+    public static <T> Response copyResponseAndClose(Response source, Class<T> type) {
+        int status = -1;
+        Headers<Object> headers = new Headers<Object>();
+        Object entity = null;
+        try {
+            status = source.getStatus();
+            if (source instanceof BaseClientResponse)
+                headers.putAll(((BaseClientResponse<?>)source).getMetadata());
+            if (source instanceof org.jboss.resteasy.client.ClientResponse) {
+                entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type);
+            } else {
+                entity = source.getEntity();
+            }
+            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], null);
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e);
+        } finally {
+            if (source instanceof BaseClientResponse)
+                ((BaseClientResponse<?>)source).close();
+        }
+    }
+    
+    @Override
+    public Object getEntity() {
+        if (error!=null) {
+            throw new IllegalStateException("getEntity called on BuiltResponsePreservingError, where an Error had been preserved", error);
+        }
+        return super.getEntity();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
new file mode 100644
index 0000000..81d789f
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.client;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.util.Collection;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.StartableApplication;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.location.BasicLocationRegistry;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.domain.EntitySummary;
+import org.apache.brooklyn.rest.domain.SensorSummary;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.time.Duration;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import org.eclipse.jetty.server.NetworkConnector;
+
+@Test(singleThreaded = true)
+public class ApplicationResourceIntegrationTest {
+
+    private static final Logger log = LoggerFactory.getLogger(ApplicationResourceIntegrationTest.class);
+
+    private static final Duration LONG_WAIT = Duration.minutes(10);
+    
+    private final String redisSpec = "{\"name\": \"redis-app\", \"type\": \"org.apache.brooklyn.entity.nosql.redis.RedisStore\", \"locations\": [ \"localhost\"]}";
+    
+    private final ApplicationSpec legacyRedisSpec = ApplicationSpec.builder().name("redis-legacy-app")
+            .entities(ImmutableSet.of(new EntitySpec("redis-ent", "org.apache.brooklyn.entity.nosql.redis.RedisStore")))
+            .locations(ImmutableSet.of("localhost"))
+            .build();
+
+    private ManagementContext manager;
+
+    protected synchronized ManagementContext getManagementContext() throws Exception {
+        if (manager == null) {
+            manager = new LocalManagementContext();
+            BrooklynRestApiLauncherTest.forceUseOfDefaultCatalogWithJavaClassPath(manager);
+            BasicLocationRegistry.addNamedLocationLocalhost(manager);
+            BrooklynRestApiLauncherTest.enableAnyoneLogin(manager);
+        }
+        return manager;
+    }
+
+    BrooklynApi api;
+
+    @BeforeClass(groups = "Integration")
+    public void setUp() throws Exception {
+        Server server = BrooklynRestApiLauncher.launcher()
+                .managementContext(getManagementContext())
+                .start();
+
+        api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/");
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        for (Application app : getManagementContext().getApplications()) {
+            try {
+                ((StartableApplication) app).stop();
+            } catch (Exception e) {
+                log.warn("Error stopping app " + app + " during test teardown: " + e);
+            }
+        }
+    }
+
+    @Test(groups = "Integration")
+    public void testDeployRedisApplication() throws Exception {
+        Response response = api.getApplicationApi().createPoly(redisSpec.getBytes());
+        assertEquals(response.getStatus(), 201);
+        assertEquals(getManagementContext().getApplications().size(), 1);
+        final String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+        assertServiceStateEventually("redis-app", entityId, Lifecycle.RUNNING, LONG_WAIT);
+    }
+    
+    @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+    public void testDeployLegacyRedisApplication() throws Exception {
+        @SuppressWarnings("deprecation")
+        Response response = api.getApplicationApi().create(legacyRedisSpec);
+        assertEquals(response.getStatus(), 201);
+        assertEquals(getManagementContext().getApplications().size(), 2);
+        assertServiceStateEventually("redis-legacy-app", "redis-ent", Lifecycle.RUNNING, LONG_WAIT);
+        
+        // Tear the app down so it doesn't interfere with other tests 
+        Response deleteResponse = api.getApplicationApi().delete("redis-legacy-app");
+        assertEquals(deleteResponse.getStatus(), 202);
+        assertEquals(getManagementContext().getApplications().size(), 1);
+    }
+
+    @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+    public void testListEntities() {
+        Collection<EntitySummary> entities = api.getEntityApi().list("redis-app");
+        Assert.assertFalse(entities.isEmpty());
+    }
+
+    @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+    public void testListSensorsRedis() throws Exception {
+        String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+        Collection<SensorSummary> sensors = api.getSensorApi().list("redis-app", entityId);
+        assertTrue(sensors.size() > 0);
+        SensorSummary uptime = Iterables.find(sensors, new Predicate<SensorSummary>() {
+            @Override
+            public boolean apply(SensorSummary sensorSummary) {
+                return sensorSummary.getName().equals("redis.uptime");
+            }
+        });
+        assertEquals(uptime.getType(), "java.lang.Integer");
+    }
+
+    @Test(groups = "Integration", dependsOnMethods = {"testListSensorsRedis", "testListEntities"})
+    public void testTriggerRedisStopEffector() throws Exception {
+        final String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+        Response response = api.getEffectorApi().invoke("redis-app", entityId, "stop", "5000", ImmutableMap.<String, Object>of());
+
+        assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+        assertServiceStateEventually("redis-app", entityId, Lifecycle.STOPPED, LONG_WAIT);
+    }
+
+    @Test(groups = "Integration", dependsOnMethods = "testTriggerRedisStopEffector")
+    public void testDeleteRedisApplication() throws Exception {
+        int size = getManagementContext().getApplications().size();
+        Response response = api.getApplicationApi().delete("redis-app");
+        Assert.assertNotNull(response);
+        try {
+            Asserts.succeedsEventually(ImmutableMap.of("timeout", Duration.minutes(1)), new Runnable() {
+                public void run() {
+                    try {
+                        ApplicationSummary summary = api.getApplicationApi().get("redis-app");
+                        fail("Redis app failed to disappear: summary="+summary);
+                    } catch (Exception failure) {
+                        // expected -- it will be a ClientResponseFailure but that class is deprecated so catching all
+                        // and asserting contains the word 404
+                        Assert.assertTrue(failure.toString().indexOf("404") >= 0, "wrong failure, got: "+failure);
+                    }
+                }});
+        } catch (Exception failure) {
+            // expected -- as above
+            Assert.assertTrue(failure.toString().indexOf("404") >= 0, "wrong failure, got: "+failure);
+        }
+
+        assertEquals(getManagementContext().getApplications().size(), size - 1);
+    }
+
+    private void assertServiceStateEventually(final String app, final String entity, final Lifecycle state, Duration timeout) {
+        Asserts.succeedsEventually(ImmutableMap.of("timeout", timeout), new Runnable() {
+            public void run() {
+                Object status = api.getSensorApi().get(app, entity, "service.state", false);
+                assertTrue(state.toString().equalsIgnoreCase(status.toString()), "status="+status);
+            }});
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
new file mode 100644
index 0000000..96c898e
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.client;
+
+import static org.testng.Assert.assertEquals;
+
+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;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.BrooklynVersion;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.StartableApplication;
+import org.apache.brooklyn.core.location.BasicLocationRegistry;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.CatalogLocationSummary;
+import org.apache.brooklyn.rest.security.provider.TestSecurityProvider;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.http.HttpAsserts;
+import org.eclipse.jetty.server.NetworkConnector;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@Test
+public class BrooklynApiRestClientTest {
+
+    private static final Logger log = LoggerFactory.getLogger(BrooklynApiRestClientTest.class);
+
+    private ManagementContext manager;
+    private Server server;
+    private BrooklynApi api;
+
+    protected synchronized ManagementContext getManagementContext() throws Exception {
+        if (manager == null) {
+            manager = new LocalManagementContext();
+            BrooklynRestApiLauncherTest.forceUseOfDefaultCatalogWithJavaClassPath(manager);
+            BasicLocationRegistry.addNamedLocationLocalhost(manager);
+            BrooklynRestApiLauncherTest.enableAnyoneLogin(manager);
+        }
+        return manager;
+    }
+
+    @BeforeClass
+    public void setUp() throws Exception {
+        server = BrooklynRestApiLauncher.launcher()
+                .managementContext(manager)
+                .securityProvider(TestSecurityProvider.class)
+                .start();
+
+        api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/v1",
+                TestSecurityProvider.USER, TestSecurityProvider.PASSWORD);
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void tearDown() throws Exception {
+        for (Application app : getManagementContext().getApplications()) {
+            try {
+                ((StartableApplication) app).stop();
+            } catch (Exception e) {
+                log.warn("Error stopping app " + app + " during test teardown: " + e);
+            }
+        }
+        Entities.destroyAll(getManagementContext());
+        server.stop();
+    }
+
+    public void testNoV1InUrl() {
+        api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort(),
+                TestSecurityProvider.USER, TestSecurityProvider.PASSWORD);
+
+        assertEquals(api.getServerApi().getVersion().getVersion(), BrooklynVersion.get());
+    }
+
+    public void testLocationApi() throws Exception {
+        log.info("Testing location API");
+        Map<String, Map<String, Object>> locations = api.getLocationApi().getLocatedLocations();
+        log.info("locations located are: "+locations);
+    }
+
+    public void testCatalogApiLocations() throws Exception {
+        List<CatalogLocationSummary> locations = api.getCatalogApi().listLocations(".*", null, false);
+        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);
+        Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat:1.0");
+    }
+
+
+
+    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()+" } ]");
+        HttpAsserts.assertHealthyStatusCode(r1.getStatus());
+        log.info("creation result: "+r1.getEntity());
+        List<ApplicationSummary> apps = api.getApplicationApi().list(null);
+        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(),
+            "invalid plan", "no services");
+        Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(),
+            "format could not be recognized", "Unrecognized application blueprint format");
+    }
+
+    public void testApplicationApiThrownError() throws Exception {
+        try {
+            ApplicationSummary summary = api.getApplicationApi().get("test-5678");
+            Asserts.shouldHaveFailedPreviously("got "+summary);
+        } catch (Exception e) {
+            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/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
new file mode 100644
index 0000000..9cae021
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.rest.client;
+
+import static org.apache.brooklyn.test.Asserts.assertEquals;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.util.collections.Jsonya;
+import org.apache.brooklyn.util.core.http.BetterMockWebServer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Joiner;
+import com.google.mockwebserver.MockResponse;
+import com.google.mockwebserver.RecordedRequest;
+
+public class BrooklynApiUtilTest {
+
+    private static final String APP_ID = "fedcba";
+
+    private static final String YAML = Joiner.on("\n").join(
+            "name: test-blueprint",
+            "location: localhost",
+            "services:",
+            "- type: brooklyn.entity.basic.EmptySoftwareProcess");
+
+    private BetterMockWebServer server;
+
+    @BeforeMethod(alwaysRun = true)
+    public void newMockWebServer() {
+        server = BetterMockWebServer.newInstanceLocalhost();
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void shutDownServer() throws Exception {
+        if (server != null) server.shutdown();
+    }
+
+    @Test
+    public void testDeployBlueprint() throws Exception {
+        server.enqueue(taskSummaryResponse());
+        server.play();
+
+        BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+        BrooklynApiUtil.deployBlueprint(api, YAML);
+
+        RecordedRequest request = server.takeRequest();
+        assertEquals(request.getPath(), "/v1/applications");
+        assertEquals(request.getMethod(), "POST");
+        assertEquals(new String(request.getBody()), YAML);
+    }
+
+    @Test
+    public void testWaitForRunningExitsCleanlyWhenAppRunning() throws Exception {
+        server.enqueue(applicationStatusResponse("RUNNING"));
+        server.play();
+
+        BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+        BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+        // i.e. no exception
+    }
+
+    @Test(expectedExceptions = {IllegalStateException.class})
+    public void testWaitForRunningFailsWhenAppStatusError() throws Exception {
+        server.enqueue(applicationStatusResponse("ERROR"));
+        // Method checks for status of task.
+        server.enqueue(taskSummaryResponse());
+        server.play();
+
+        BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+        BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+    }
+
+    @Test(expectedExceptions = {IllegalStateException.class})
+    public void testWaitForRunningFailsWhenAppStatusUnknown() throws Exception {
+        server.enqueue(applicationStatusResponse("UNKNOWN"));
+        // Method checks for status of task.
+        server.enqueue(taskSummaryResponse());
+        server.play();
+
+        BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+        BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+    }
+
+    /** @return a response whose Content-Type header is application/json. */
+    private MockResponse newJsonResponse() {
+        return new MockResponse()
+                .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+    }
+
+    private MockResponse taskSummaryResponse() {
+        String body = Jsonya.newInstance()
+                .put("id", "taskid")
+                .put("entityId", APP_ID)
+                .toString();
+        return newJsonResponse().setBody(body);
+    }
+
+    private MockResponse applicationStatusResponse(String status) {
+        String body = Jsonya.newInstance()
+                .put("status", status)
+                .at("spec", "locations").list().add("localhost")
+                .root()
+                .toString();
+        return newJsonResponse()
+                .setBody(body);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/resources/catalog/test-catalog.bom
----------------------------------------------------------------------
diff --git a/java/src/test/resources/catalog/test-catalog.bom b/java/src/test/resources/catalog/test-catalog.bom
new file mode 100644
index 0000000..698bcf2
--- /dev/null
+++ b/java/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


Mime
View raw message