You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/18 16:47:39 UTC

[21/34] brooklyn-server git commit: REST API optional Jersey compatibility

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
new file mode 100644
index 0000000..f0c65e4
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.util;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.location.AbstractLocation;
+import org.apache.brooklyn.core.location.geo.HostGeoInfo;
+import org.apache.brooklyn.core.location.internal.LocationInternal;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+
+import com.google.common.collect.ImmutableList;
+
+public class EntityLocationUtilsTest extends BrooklynAppUnitTestSupport {
+
+    private static final Logger log = LoggerFactory.getLogger(EntityLocationUtilsTest.class);
+    
+    private Location loc;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        loc = mgmt.getLocationRegistry().resolve("localhost");
+        ((AbstractLocation)loc).setHostGeoInfo(new HostGeoInfo("localhost", "localhost", 50, 0));
+    }
+    
+    @Test
+    public void testCount() {
+        @SuppressWarnings("unused")
+        SoftwareProcess r1 = app.createAndManageChild(EntitySpec.create(SoftwareProcess.class, RestMockSimpleEntity.class));
+        SoftwareProcess r2 = app.createAndManageChild(EntitySpec.create(SoftwareProcess.class, RestMockSimpleEntity.class));
+        Entities.start(app, Arrays.<Location>asList(loc));
+
+        Entities.dumpInfo(app);
+
+        log.info("r2loc: "+r2.getLocations());
+        log.info("props: "+((LocationInternal)r2.getLocations().iterator().next()).config().getBag().getAllConfig());
+
+        Map<Location, Integer> counts = new EntityLocationUtils(mgmt).countLeafEntitiesByLocatedLocations();
+        log.info("count: "+counts);
+        assertEquals(ImmutableList.copyOf(counts.values()), ImmutableList.of(2), "counts="+counts);
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
new file mode 100644
index 0000000..80e9c46
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
@@ -0,0 +1,38 @@
+/*
+ * 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.util;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.rest.filter.HaHotStateRequired;
+
+@Path("/ha/class")
+@Produces(MediaType.APPLICATION_JSON)
+@HaHotStateRequired
+public class HaHotStateCheckClassResource {
+
+    @GET
+    @Path("fail")
+    public String fail() {
+        return "FAIL";
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
new file mode 100644
index 0000000..5c9d4d1
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
@@ -0,0 +1,44 @@
+/*
+ * 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.util;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.rest.filter.HaHotStateRequired;
+
+@Path("/ha/method")
+@Produces(MediaType.APPLICATION_JSON)
+public class HaHotStateCheckResource {
+
+    @GET
+    @Path("ok")
+    public String ok() {
+        return "OK";
+    }
+
+    @GET
+    @Path("fail")
+    @HaHotStateRequired
+    public String fail() {
+        return "FAIL";
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NoOpRecordingShutdownHandler.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NoOpRecordingShutdownHandler.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NoOpRecordingShutdownHandler.java
new file mode 100644
index 0000000..a99d3d9
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NoOpRecordingShutdownHandler.java
@@ -0,0 +1,39 @@
+/*
+ * 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.util;
+
+import org.apache.brooklyn.rest.util.ShutdownHandler;
+
+public class NoOpRecordingShutdownHandler implements ShutdownHandler {
+    private volatile boolean isRequested;
+
+    @Override
+    public void onShutdownRequest() {
+        isRequested = true;
+    }
+
+    public boolean isRequested() {
+        return isRequested;
+    }
+
+    public void reset() {
+        isRequested = false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
new file mode 100644
index 0000000..7a24f31
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
@@ -0,0 +1,46 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Type;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+
+import com.sun.jersey.core.spi.component.ComponentContext;
+import com.sun.jersey.core.spi.component.ComponentScope;
+import com.sun.jersey.spi.inject.Injectable;
+import com.sun.jersey.spi.inject.InjectableProvider;
+
+@Provider
+public class NullHttpServletRequestProvider implements InjectableProvider<Context, Type> { 
+    public Injectable<HttpServletRequest> getInjectable(ComponentContext ic, 
+            Context a, Type c) { 
+        if (HttpServletRequest.class == c) { 
+            return new Injectable<HttpServletRequest>() {
+                public HttpServletRequest getValue() { return null; }
+            }; 
+        } else 
+            return null; 
+    } 
+    public ComponentScope getScope() { 
+        return ComponentScope.Singleton; 
+    } 
+} 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
new file mode 100644
index 0000000..106780d
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
@@ -0,0 +1,51 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Type;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+
+import com.sun.jersey.core.spi.component.ComponentContext;
+import com.sun.jersey.core.spi.component.ComponentScope;
+import com.sun.jersey.spi.container.servlet.WebConfig;
+import com.sun.jersey.spi.inject.Injectable;
+import com.sun.jersey.spi.inject.InjectableProvider;
+
+@Provider
+public class NullServletConfigProvider implements InjectableProvider<Context, Type> { 
+    public Injectable<ServletContext> getInjectable(ComponentContext ic, 
+            Context a, Type c) { 
+        if (ServletContext.class == c) { 
+            return new Injectable<ServletContext>() {
+                public ServletContext getValue() { return null; }
+            }; 
+        } else if (WebConfig.class == c) {
+            return new Injectable<ServletContext>() {
+                public ServletContext getValue() { return null; }
+            }; 
+        } else 
+            return null; 
+    } 
+    public ComponentScope getScope() { 
+        return ComponentScope.Singleton; 
+    } 
+} 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/RestApiTestUtils.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/RestApiTestUtils.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/RestApiTestUtils.java
new file mode 100644
index 0000000..36ad69c
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/RestApiTestUtils.java
@@ -0,0 +1,58 @@
+/*
+ * 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.util;
+
+import java.io.InputStream;
+
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.stream.Streams;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RestApiTestUtils {
+
+    public static <T> T fromJson(String text, Class<T> type) {
+        try {
+            return new ObjectMapper().readValue(text, type);
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        }
+    }
+    public static String asJson(Object x) {
+        try {
+            return new ObjectMapper().writeValueAsString(x);
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        }
+    }
+    public static String jsonFixture(String path) {
+        InputStream stream = RestApiTestUtils.class.getClassLoader().getResourceAsStream(path);
+        if (stream==null) throw new IllegalStateException("Cannot find resource: "+path);
+        return asJson(fromJson(Streams.readFullyString(stream), Object.class));
+    }
+
+    public static <T> T fromJson(String text, TypeReference<T> type) {
+        try {
+            return new ObjectMapper().readValue(text, type);
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/ServerStoppingShutdownHandler.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/ServerStoppingShutdownHandler.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/ServerStoppingShutdownHandler.java
new file mode 100644
index 0000000..fc3bbc4
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/ServerStoppingShutdownHandler.java
@@ -0,0 +1,75 @@
+/*
+ * 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.util;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
+import org.apache.brooklyn.util.time.Duration;
+import org.apache.brooklyn.util.time.Time;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/* not the cleanest way to enforce a clean shutdown, but a simple and effective way;
+ * usage is restricted to BrooklynRestApiLauncher and subclasses, to stop it inline.
+ * the main app stops the server in a more principled way using callbacks. */
+public class ServerStoppingShutdownHandler implements ShutdownHandler {
+
+    private static final Logger log = LoggerFactory.getLogger(ServerStoppingShutdownHandler.class);
+    
+    private final ManagementContext mgmt;
+    private Server server;
+    
+    public ServerStoppingShutdownHandler(ManagementContext mgmt) {
+        this.mgmt = mgmt;
+    }
+
+    @Override
+    public void onShutdownRequest() {
+        log.info("Shutting down server (when running in rest-api dev mode, using background thread)");
+
+        // essentially same as BrooklynLauncher.terminate() but cut down ...
+        // NB: this is only used in dev mode use of BrooklynJavascriptGuiLauncher
+        new Thread(new Runnable() {
+            public void run() {
+                Time.sleep(Duration.millis(250));
+                log.debug("Shutting down server in background thread, closing "+server+" and "+mgmt);
+                if (server!=null) {
+                    try {
+                        server.stop();
+                        server.join();
+                    } catch (Exception e) {
+                        log.debug("Stopping server gave an error (not usually a concern): "+e);
+                        /* NPE may be thrown e.g. if threadpool not started */
+                    }
+                }
+
+                if (mgmt instanceof ManagementContextInternal) {
+                    ((ManagementContextInternal)mgmt).terminate();
+                }
+            }
+        }).start();
+    }
+
+    /** Expect this to be injected; typically it is not known when this is created, but we need it to trigger shutdown. */
+    public void setServer(Server server) {
+        this.server = server;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
new file mode 100644
index 0000000..9542eda
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
@@ -0,0 +1,399 @@
+/*
+ * 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.util.json;
+
+import java.io.NotSerializableException;
+import java.net.URI;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.utils.URIBuilder;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.http.HttpTool;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.text.Strings;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.MultimapBuilder;
+import com.google.gson.Gson;
+import org.eclipse.jetty.server.NetworkConnector;
+
+public class BrooklynJacksonSerializerTest {
+
+    private static final Logger log = LoggerFactory.getLogger(BrooklynJacksonSerializerTest.class);
+    
+    public static class SillyClassWithManagementContext {
+        @JsonProperty
+        ManagementContext mgmt;
+        @JsonProperty
+        String id;
+        
+        public SillyClassWithManagementContext() { }
+        
+        public SillyClassWithManagementContext(String id, ManagementContext mgmt) {
+            this.id = id;
+            this.mgmt = mgmt;
+        }
+
+        @Override
+        public String toString() {
+            return super.toString()+"[id="+id+";mgmt="+mgmt+"]";
+        }
+    }
+
+    @Test
+    public void testCustomSerializerWithSerializableSillyManagementExample() throws Exception {
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
+        try {
+
+            ObjectMapper mapper = BrooklynJacksonJsonProvider.newPrivateObjectMapper(mgmt);
+
+            SillyClassWithManagementContext silly = new SillyClassWithManagementContext("123", mgmt);
+            log.info("silly is: "+silly);
+
+            String sillyS = mapper.writeValueAsString(silly);
+
+            log.info("silly json is: "+sillyS);
+
+            SillyClassWithManagementContext silly2 = mapper.readValue(sillyS, SillyClassWithManagementContext.class);
+            log.info("silly2 is: "+silly2);
+
+            Assert.assertEquals(silly.id, silly2.id);
+            
+        } finally {
+            Entities.destroyAll(mgmt);
+        }
+    }
+    
+    public static class SelfRefNonSerializableClass {
+        @JsonProperty
+        Object bogus = this;
+    }
+
+    @Test
+    public void testSelfReferenceFailsWhenStrict() {
+        checkNonSerializableWhenStrict(new SelfRefNonSerializableClass());
+    }
+    @Test
+    public void testSelfReferenceGeneratesErrorMapObject() throws Exception {
+        checkSerializesAsMapWithErrorAndToString(new SelfRefNonSerializableClass());
+    }
+    @Test
+    public void testNonSerializableInListIsShownInList() throws Exception {
+        List<?> result = checkSerializesAs(MutableList.of(1, new SelfRefNonSerializableClass()), List.class);
+        Assert.assertEquals( result.get(0), 1 );
+        Assert.assertEquals( ((Map<?,?>)result.get(1)).get("errorType"), NotSerializableException.class.getName() );
+    }
+    @Test
+    public void testNonSerializableInMapIsShownInMap() throws Exception {
+        Map<?,?> result = checkSerializesAs(MutableMap.of("x", new SelfRefNonSerializableClass()), Map.class);
+        Assert.assertEquals( ((Map<?,?>)result.get("x")).get("errorType"), NotSerializableException.class.getName() );
+    }
+    static class TupleWithNonSerializable {
+        String good = "bon";
+        SelfRefNonSerializableClass bad = new SelfRefNonSerializableClass();
+    }
+    @Test
+    public void testNonSerializableInObjectIsShownInMap() throws Exception {
+        String resultS = checkSerializesAs(new TupleWithNonSerializable(), null);
+        log.info("nested non-serializable json is "+resultS);
+        Assert.assertTrue(resultS.startsWith("{\"good\":\"bon\",\"bad\":{"), "expected a nested map for the error field, not "+resultS);
+        
+        Map<?,?> result = checkSerializesAs(new TupleWithNonSerializable(), Map.class);
+        Assert.assertEquals( result.get("good"), "bon" );
+        Assert.assertTrue( result.containsKey("bad"), "Should have had a key for field 'bad'" );
+        Assert.assertEquals( ((Map<?,?>)result.get("bad")).get("errorType"), NotSerializableException.class.getName() );
+    }
+    
+    public static class EmptyClass {
+    }
+
+    @Test
+    public void testEmptySerializesAsEmpty() throws Exception {
+        // deliberately, a class with no fields and no annotations serializes as an error,
+        // because the alternative, {}, is useless.  however if it *is* annotated, as below, then it will serialize fine.
+        checkSerializesAsMapWithErrorAndToString(new SelfRefNonSerializableClass());
+    }
+    @Test
+    public void testEmptyNonSerializableFailsWhenStrict() {
+        checkNonSerializableWhenStrict(new EmptyClass());
+    }
+
+    @JsonSerialize
+    public static class EmptyClassWithSerialize {
+    }
+
+    @Test
+    public void testEmptyAnnotatedSerializesAsEmptyEvenWhenStrict() throws Exception {
+        try {
+            BidiSerialization.setStrictSerialization(true);
+            testEmptyAnnotatedSerializesAsEmpty();
+        } finally {
+            BidiSerialization.clearStrictSerialization();
+        }
+    }
+    
+    @Test
+    public void testEmptyAnnotatedSerializesAsEmpty() throws Exception {
+        Map<?, ?> map = checkSerializesAs( new EmptyClassWithSerialize(), Map.class );
+        Assert.assertTrue(map.isEmpty(), "Expected an empty map; instead got: "+map);
+
+        String result = checkSerializesAs( MutableList.of(new EmptyClassWithSerialize()), null );
+        result = result.replaceAll(" ", "").trim();
+        Assert.assertEquals(result, "[{}]");
+    }
+
+    @Test
+    public void testSensorFailsWhenStrict() {
+        checkNonSerializableWhenStrict(MutableList.of(Attributes.HTTP_PORT));
+    }
+    @Test
+    public void testSensorSensible() throws Exception {
+        Map<?,?> result = checkSerializesAs(Attributes.HTTP_PORT, Map.class);
+        log.info("SENSOR json is: "+result);
+        Assert.assertFalse(result.toString().contains("error"), "Shouldn't have had an error, instead got: "+result);
+    }
+
+    @Test
+    public void testLinkedListSerialization() throws Exception {
+        LinkedList<Object> ll = new LinkedList<Object>();
+        ll.add(1); ll.add("two");
+        String result = checkSerializesAs(ll, null);
+        log.info("LLIST json is: "+result);
+        Assert.assertFalse(result.contains("error"), "Shouldn't have had an error, instead got: "+result);
+        Assert.assertEquals(Strings.collapseWhitespace(result, ""), "[1,\"two\"]");
+    }
+
+    @Test
+    public void testMultiMapSerialization() throws Exception {
+        Multimap<String, Integer> m = MultimapBuilder.hashKeys().arrayListValues().build();
+        m.put("bob", 24);
+        m.put("bob", 25);
+        String result = checkSerializesAs(m, null);
+        log.info("multimap serialized as: " + result);
+        Assert.assertFalse(result.contains("error"), "Shouldn't have had an error, instead got: "+result);
+        Assert.assertEquals(Strings.collapseWhitespace(result, ""), "{\"bob\":[24,25]}");
+    }
+
+    @Test
+    public void testSupplierSerialization() throws Exception {
+        String result = checkSerializesAs(Strings.toStringSupplier(Streams.byteArrayOfString("x")), null);
+        log.info("SUPPLIER json is: "+result);
+        Assert.assertFalse(result.contains("error"), "Shouldn't have had an error, instead got: "+result);
+    }
+
+    @Test
+    public void testWrappedStreamSerialization() throws Exception {
+        String result = checkSerializesAs(BrooklynTaskTags.tagForStream("TEST", Streams.byteArrayOfString("x")), null);
+        log.info("WRAPPED STREAM json is: "+result);
+        Assert.assertFalse(result.contains("error"), "Shouldn't have had an error, instead got: "+result);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T checkSerializesAs(Object x, Class<T> type) {
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
+        try {
+            ObjectMapper mapper = BrooklynJacksonJsonProvider.newPrivateObjectMapper(mgmt);
+            String tS = mapper.writeValueAsString(x);
+            log.debug("serialized "+x+" as "+tS);
+            Assert.assertTrue(tS.length() < 1000, "Data too long, size "+tS.length()+" for "+x);
+            if (type==null) return (T) tS;
+            return mapper.readValue(tS, type);
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        } finally {
+            Entities.destroyAll(mgmt);
+        }
+    }
+    protected Map<?,?> checkSerializesAsMapWithErrorAndToString(Object x) {
+        Map<?,?> rt = checkSerializesAs(x, Map.class);
+        Assert.assertEquals(rt.get("toString"), x.toString());
+        Assert.assertEquals(rt.get("error"), Boolean.TRUE);
+        return rt;
+    }
+    protected void checkNonSerializableWhenStrict(Object x) {
+        checkNonSerializable(x, true);
+    }
+    protected void checkNonSerializable(Object x, boolean strict) {
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
+        try {
+            ObjectMapper mapper = BrooklynJacksonJsonProvider.newPrivateObjectMapper(mgmt);
+            if (strict)
+                BidiSerialization.setStrictSerialization(true);
+            
+            String tS = mapper.writeValueAsString(x);
+            Assert.fail("Should not have serialized "+x+"; instead gave: "+tS);
+            
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            log.info("Got expected error, when serializing "+x+": "+e);
+            
+        } finally {
+            if (strict)
+                BidiSerialization.clearStrictSerialization();
+            Entities.destroyAll(mgmt);
+        }
+    }
+    
+    // Ensure TEXT_PLAIN just returns toString for ManagementContext instance.
+    // Strangely, testWithLauncherSerializingListsContainingEntitiesAndOtherComplexStuff ended up in the 
+    // EntityConfigResource.getPlain code, throwing a ClassCastException.
+    // 
+    // TODO This tests the fix for that ClassCastException, but does not explain why 
+    // testWithLauncherSerializingListsContainingEntitiesAndOtherComplexStuff was calling it.
+    @Test(groups="Integration") //because of time
+    public void testWithAcceptsPlainText() throws Exception {
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
+        Server server = null;
+        try {
+            server = BrooklynRestApiLauncher.launcher().managementContext(mgmt).start();
+            HttpClient client = HttpTool.httpClientBuilder().build();
+
+            TestApplication app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
+
+            String serverAddress = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
+            String appUrl = serverAddress + "/v1/applications/" + app.getId();
+            String entityUrl = appUrl + "/entities/" + app.getId();
+            URI configUri = new URIBuilder(entityUrl + "/config/" + TestEntity.CONF_OBJECT.getName())
+                    .addParameter("raw", "true")
+                    .build();
+
+            // assert config here is just mgmt.toString()
+            app.config().set(TestEntity.CONF_OBJECT, mgmt);
+            String content = get(client, configUri, ImmutableMap.of("Accept", MediaType.TEXT_PLAIN));
+            log.info("CONFIG MGMT is:\n"+content);
+            Assert.assertEquals(content, mgmt.toString(), "content="+content);
+            
+        } finally {
+            try {
+                if (server != null) server.stop();
+            } catch (Exception e) {
+                log.warn("failed to stop server: "+e);
+            }
+            Entities.destroyAll(mgmt);
+        }
+    }
+        
+    @Test(groups="Integration") //because of time
+    public void testWithLauncherSerializingListsContainingEntitiesAndOtherComplexStuff() throws Exception {
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
+        Server server = null;
+        try {
+            server = BrooklynRestApiLauncher.launcher().managementContext(mgmt).start();
+            HttpClient client = HttpTool.httpClientBuilder().build();
+
+            TestApplication app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
+
+            String serverAddress = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
+            String appUrl = serverAddress + "/v1/applications/" + app.getId();
+            String entityUrl = appUrl + "/entities/" + app.getId();
+            URI configUri = new URIBuilder(entityUrl + "/config/" + TestEntity.CONF_OBJECT.getName())
+                    .addParameter("raw", "true")
+                    .build();
+
+            // assert config here is just mgmt
+            app.config().set(TestEntity.CONF_OBJECT, mgmt);
+            String content = get(client, configUri, ImmutableMap.of("Accept", MediaType.APPLICATION_JSON));
+            log.info("CONFIG MGMT is:\n"+content);
+            @SuppressWarnings("rawtypes")
+            Map values = new Gson().fromJson(content, Map.class);
+            Assert.assertEquals(values, ImmutableMap.of("type", LocalManagementContextForTests.class.getCanonicalName()), "values="+values);
+
+            // assert normal API returns the same, containing links
+            content = get(client, entityUrl, ImmutableMap.of("Accept", MediaType.APPLICATION_JSON));
+            log.info("ENTITY is: \n"+content);
+            values = new Gson().fromJson(content, Map.class);
+            Assert.assertTrue(values.size()>=3, "Map is too small: "+values);
+            Assert.assertTrue(values.size()<=6, "Map is too big: "+values);
+            Assert.assertEquals(values.get("type"), TestApplication.class.getCanonicalName(), "values="+values);
+            Assert.assertNotNull(values.get("links"), "Map should have contained links: values="+values);
+
+            // but config etc returns our nicely json serialized
+            app.config().set(TestEntity.CONF_OBJECT, app);
+            content = get(client, configUri, ImmutableMap.of("Accept", MediaType.APPLICATION_JSON));
+            log.info("CONFIG ENTITY is:\n"+content);
+            values = new Gson().fromJson(content, Map.class);
+            Assert.assertEquals(values, ImmutableMap.of("type", Entity.class.getCanonicalName(), "id", app.getId()), "values="+values);
+
+            // and self-ref gives error + toString
+            SelfRefNonSerializableClass angry = new SelfRefNonSerializableClass();
+            app.config().set(TestEntity.CONF_OBJECT, angry);
+            content = get(client, configUri, ImmutableMap.of("Accept", MediaType.APPLICATION_JSON));
+            log.info("CONFIG ANGRY is:\n"+content);
+            assertErrorObjectMatchingToString(content, angry);
+            
+            // as does Server
+            app.config().set(TestEntity.CONF_OBJECT, server);
+            content = get(client, configUri, ImmutableMap.of("Accept", MediaType.APPLICATION_JSON));
+            // NOTE, if using the default visibility / object mapper, the getters of the object are invoked
+            // resulting in an object which is huge, 7+MB -- and it wreaks havoc w eclipse console regex parsing!
+            // (but with our custom VisibilityChecker server just gives us the nicer error!)
+            log.info("CONFIG SERVER is:\n"+content);
+            assertErrorObjectMatchingToString(content, server);
+            Assert.assertTrue(content.contains(NotSerializableException.class.getCanonicalName()), "server should have contained things which are not serializable");
+            Assert.assertTrue(content.length() < 1024, "content should not have been very long; instead was: "+content.length());
+            
+        } finally {
+            try {
+                if (server != null) server.stop();
+            } catch (Exception e) {
+                log.warn("failed to stop server: "+e);
+            }
+            Entities.destroyAll(mgmt);
+        }
+    }
+
+    private void assertErrorObjectMatchingToString(String content, Object expected) {
+        Object value = new Gson().fromJson(content, Object.class);
+        Assert.assertTrue(value instanceof Map, "Expected map, got: "+value);
+        Assert.assertEquals(((Map<?,?>)value).get("toString"), expected.toString());
+    }
+
+    private String get(HttpClient client, String uri, Map<String, String> headers) {
+        return get(client, URI.create(uri), headers);
+    }
+
+    private String get(HttpClient client, URI uri, Map<String, String> headers) {
+        return HttpTool.httpGet(client, uri, headers).getContentAsString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/brooklyn/scanning.catalog.bom
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/brooklyn/scanning.catalog.bom b/rest/rest-server-jersey/src/test/resources/brooklyn/scanning.catalog.bom
new file mode 100644
index 0000000..cddb832
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/brooklyn/scanning.catalog.bom
@@ -0,0 +1,19 @@
+# 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:
+  scanJavaAnnotations: true

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/api-error-basic.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/api-error-basic.json b/rest/rest-server-jersey/src/test/resources/fixtures/api-error-basic.json
new file mode 100644
index 0000000..7634c50
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/api-error-basic.json
@@ -0,0 +1,4 @@
+{
+    "message": "explanatory message",
+    "details": "accompanying details"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/api-error-no-details.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/api-error-no-details.json b/rest/rest-server-jersey/src/test/resources/fixtures/api-error-no-details.json
new file mode 100644
index 0000000..5762f6f
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/api-error-no-details.json
@@ -0,0 +1,3 @@
+{
+    "message": "explanatory message"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/application-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/application-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/application-list.json
new file mode 100644
index 0000000..029cf68
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/application-list.json
@@ -0,0 +1,44 @@
+[
+    {
+        "spec":{
+            "name":"tesr",
+            "entities":[
+                {
+                    "name":"tomcat",
+                    "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+                    "config":{ }
+                }
+            ],
+            "locations":[
+                "/v1/locations/0"
+            ]
+        },
+        "status":"STARTING",
+        "links":{
+            "self":"/v1/applications/tesr",
+            "entities":"fixtures/entity-summary-list.json"
+        }
+    },
+    {
+        "spec":{
+            "name":"myapp",
+            "entities":[
+                {
+                    "name":"Vanilla Java App",
+                    "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
+                    "config":{
+                        "initialSize":"1",
+                        "creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
+                    }
+                }
+            ],
+            "locations":["/v1/locations/1"]
+        },
+        "status":"STARTING",
+        "links":{
+            "self":"/v1/applications/myapp",
+            "entities":"fixtures/entity-summary-list.json"
+        }
+    }
+]
+

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/application-spec.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/application-spec.json b/rest/rest-server-jersey/src/test/resources/fixtures/application-spec.json
new file mode 100644
index 0000000..9f042c6
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/application-spec.json
@@ -0,0 +1,16 @@
+{
+    "name":"myapp",
+    "entities":[
+        {
+            "name":"Vanilla Java App",
+            "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
+            "config":{
+                "initialSize":"1",
+                "creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
+            }
+        }
+    ],
+    "locations":[
+        "/v1/locations/1"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/application-tree.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/application-tree.json b/rest/rest-server-jersey/src/test/resources/fixtures/application-tree.json
new file mode 100644
index 0000000..e4ce29f
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/application-tree.json
@@ -0,0 +1,43 @@
+[
+    {
+        "name":"test",
+        "id":"riBZUjMq",
+        "type":null,
+        "children":[
+            {
+                "name":"tomcat1",
+                "id":"fXyyQ7Ap",
+                "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer"
+            }
+        ]
+    },
+    {
+        "name":"test2",
+        "id":"app-002",
+        "type":null,
+        "children":[
+            {
+                "name":"tomcat1",
+                "id":"child-01",
+                "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer"
+            },
+            {
+                "name":"tomcat2",
+                "id":"child-02",
+                "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+                "children":[
+                    {
+                        "name":"tomcat03",
+                        "id":"child-03",
+                        "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer"
+                    },
+                    {
+                        "name":"tomcat04",
+                        "id":"child-04",
+                        "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer"
+                    }
+                ]
+            }
+        ]
+    }
+]

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/application.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/application.json b/rest/rest-server-jersey/src/test/resources/fixtures/application.json
new file mode 100644
index 0000000..cd6a21a
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/application.json
@@ -0,0 +1,22 @@
+{
+    "id":"myapp_id",
+    "spec":{
+        "name":"myapp",
+        "entities":[
+            {
+                "name":"Vanilla Java App",
+                "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
+                "config":{
+                    "initialSize":"1",
+                    "creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
+                }
+            }
+        ],
+        "locations":["/v1/locations/1"]
+    },
+    "status":"STARTING",
+    "links":{
+        "self":"/v1/applications/myapp",
+        "entities":"fixtures/entity-summary-list.json"
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application-list.json
new file mode 100644
index 0000000..c4757be
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application-list.json
@@ -0,0 +1,29 @@
+[
+    {
+        "id": "com.example.app:1.1",
+        "type": "com.example.app",
+        "name": "My example application",
+        "version": "1.1",
+        "description": "My awesome example application, as a catalog item",
+        "planYaml": "services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n  launch.command: echo \"Launch application\"\n  checkRunning.command: echo \"Check running application\"",
+        "iconUrl": "http://my.example.com/icon.png"
+    },
+    {
+        "id": "com.example.app:2.0",
+        "type": "com.example.app",
+        "name": "My example application",
+        "version": "2.0",
+        "description": "My awesome example application, as a catalog item",
+        "planYaml": "services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n  launch.command: echo \"Launch application\"\n  checkRunning.command: echo \"Check running application\"",
+        "iconUrl": "http://my.example.com/icon.png"
+    },
+    {
+        "id": "com.example.other.app:1.0",
+        "type": "com.example.other.app",
+        "name": "Another example application",
+        "version": "1.0",
+        "description": "Another awesome example application, as a catalog item",
+        "planYaml": "services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n  launch.command: echo \"Launch other application\"\n  checkRunning.command: echo \"Check running other application\"",
+        "iconUrl": "http://my.other.example.com/icon.png"
+    }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application.json b/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application.json
new file mode 100644
index 0000000..7c72270
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/catalog-application.json
@@ -0,0 +1,9 @@
+{
+    "id": "com.example.app:1.1",
+    "type": "com.example.app",
+    "name": "My example application",
+    "version": "1.1",
+    "description": "My awesome example application, as a catalog item",
+    "planYaml": "services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n  launch.command: echo \"Launch application\"\n  checkRunning.command: echo \"Check running application\"",
+    "iconUrl": "http://my.example.com/icon.png"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary-list.json
new file mode 100644
index 0000000..fe2828c
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary-list.json
@@ -0,0 +1,47 @@
+[
+    {
+        "name":"start",
+        "description":"Start the process/service represented by an entity",
+        "returnType":"void",
+        "parameters":[
+            {
+                "name":"locations",
+                "type":"java.util.Collection",
+                "description":"A list of locations"
+            },
+            {
+                "name":"booleanValue",
+                "type":"java.lang.Boolean",
+                "description":"True or false",
+                "defaultValue": true
+            }
+        ],
+        "links":{
+            "self":"/v1/applications/tesr/entities/ZgoDhGQA/effectors/start",
+            "entity":"/v1/applications/tesr/entities/ZgoDhGQA",
+            "application":"/v1/applications/tesr"
+        }
+    },
+    {
+        "name":"restart",
+        "description":"Restart the process/service represented by an entity",
+        "returnType":"void",
+        "parameters":[ ],
+        "links":{
+            "self":"/v1/applications/tesr/entities/ZgoDhGQA/effectors/restart",
+            "entity":"/v1/applications/tesr/entities/ZgoDhGQA",
+            "application":"/v1/applications/tesr"
+        }
+    },
+    {
+        "name":"stop",
+        "description":"Stop the process/service represented by an entity",
+        "returnType":"void",
+        "parameters":[ ],
+        "links":{
+            "self":"/v1/applications/tesr/entities/ZgoDhGQA/effectors/stop",
+            "entity":"/v1/applications/tesr/entities/ZgoDhGQA",
+            "application":"/v1/applications/tesr"
+        }
+    }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary.json b/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary.json
new file mode 100644
index 0000000..eda97dd
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/effector-summary.json
@@ -0,0 +1,9 @@
+{
+    "name":"stop",
+    "returnType":"void",
+    "parameters":[],
+    "description":"Effector description",
+    "links":{
+        "self":"/v1/applications/redis-app/entities/redis-ent/effectors/stop"
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/entity-only-type.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/entity-only-type.json b/rest/rest-server-jersey/src/test/resources/fixtures/entity-only-type.json
new file mode 100644
index 0000000..e932ab1
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/entity-only-type.json
@@ -0,0 +1,3 @@
+{
+    "type":"org.apache.brooklyn.entity.java.VanillaJavaApp"
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary-list.json
new file mode 100644
index 0000000..6e2dc4e
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary-list.json
@@ -0,0 +1,14 @@
+[
+    {
+        "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+        "links":{
+            "self":"/v1/applications/tesr/entities/zQsqdXzi",
+            "catalog":"/v1/catalog/entities/org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+            "application":"/v1/applications/tesr",
+            "children":"/v1/applications/tesr/entities/zQsqdXzi/entities",
+            "effectors":"fixtures/effector-summary-list.json",
+            "sensors":"fixtures/sensor-summary-list.json",
+            "activities":"fixtures/task-summary-list.json"
+        }
+    }
+]

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary.json b/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary.json
new file mode 100644
index 0000000..05d2e8f
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/entity-summary.json
@@ -0,0 +1,13 @@
+{"id":"zQsqdXzi",
+ "name":"MyTomcat",
+ "type":"org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+ "links":{
+   "self":"/v1/applications/tesr/entities/zQsqdXzi",
+   "catalog":"/v1/catalog/entities/org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
+   "application":"/v1/applications/tesr",
+   "children":"/v1/applications/tesr/entities/zQsqdXzi/children",
+   "effectors":"fixtures/effector-summary-list.json",
+   "sensors":"fixtures/sensor-summary-list.json",
+   "activities":"fixtures/task-summary-list.json"
+ }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/entity.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/entity.json b/rest/rest-server-jersey/src/test/resources/fixtures/entity.json
new file mode 100644
index 0000000..dac0509
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/entity.json
@@ -0,0 +1,7 @@
+[
+    {
+        "name":"Vanilla Java App",
+        "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
+        "config":{}
+    }
+]

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/ha-summary.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/ha-summary.json b/rest/rest-server-jersey/src/test/resources/fixtures/ha-summary.json
new file mode 100644
index 0000000..3c3eb7c
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/ha-summary.json
@@ -0,0 +1,19 @@
+{
+    "links": {},
+    "masterId": "kDp39gAv",
+    "nodes": {
+        "kDp39gAv": {
+            "nodeId": "kDp39gAv",
+            "nodeUri": "http://10.30.40.50:8081/",
+            "status": "MASTER",
+            "timestampUtc": 1400257858796
+        },
+        "lHNCTtZ4": {
+            "nodeId": "lHNCTtZ4",
+            "nodeUri": "http://10.30.40.60:8081/",
+            "status": "STANDBY",
+            "timestampUtc": 1400257858796
+        }
+    },
+    "ownId": "kDp39gAv"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/location-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/location-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/location-list.json
new file mode 100644
index 0000000..c4e05de
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/location-list.json
@@ -0,0 +1,10 @@
+[
+    {
+        "id":"123",
+        "name":"localhost",
+        "spec":"localhost",
+        "links":{
+            "self":"/v1/locations/123"
+        }
+    }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/location-summary.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/location-summary.json b/rest/rest-server-jersey/src/test/resources/fixtures/location-summary.json
new file mode 100644
index 0000000..d1d0573
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/location-summary.json
@@ -0,0 +1,8 @@
+{
+    "id":"123",
+    "name":"localhost",
+    "spec":"localhost",
+    "links":{
+        "self":"/v1/locations/123"
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/location-without-credential.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/location-without-credential.json b/rest/rest-server-jersey/src/test/resources/fixtures/location-without-credential.json
new file mode 100644
index 0000000..af8051d
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/location-without-credential.json
@@ -0,0 +1,5 @@
+{
+    "name":"localhost",
+    "spec":"localhost",
+    "config":{"identity":"bob"}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/location.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/location.json b/rest/rest-server-jersey/src/test/resources/fixtures/location.json
new file mode 100644
index 0000000..a2670cd
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/location.json
@@ -0,0 +1,4 @@
+{
+    "name":"localhost",
+    "spec":"localhost"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/sensor-current-state.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/sensor-current-state.json b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-current-state.json
new file mode 100644
index 0000000..e8084e0
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-current-state.json
@@ -0,0 +1,6 @@
+{
+    "service.state":"running",
+    "jmx.context":"jmx/context",
+    "tomcat.shutdownport":"8081",
+    "service.isUp":"true"
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary-list.json
new file mode 100644
index 0000000..6ab457b
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary-list.json
@@ -0,0 +1,42 @@
+[
+    {
+        "name":"service.state",
+        "type":"org.apache.brooklyn.entity.lifecycle.Lifecycle",
+        "description":"Service lifecycle state",
+        "links":{
+            "self":"fixtures/service-state.json",
+            "application":"/v1/applications/tesr",
+            "entity":"/v1/applications/tesr/entities/zQsqdXzi"
+        }
+    },
+    {
+        "name":"jmx.context",
+        "type":"java.lang.String",
+        "description":"JMX context path",
+        "links":{
+            "self":"fixtures/service-state.json",
+            "application":"/v1/applications/tesr",
+            "entity":"/v1/applications/tesr/entities/zQsqdXzi"
+        }
+    },
+    {
+        "name":"tomcat.shutdownport",
+        "type":"java.lang.Integer",
+        "description":"Suggested shutdown port",
+        "links":{
+            "self":"fixtures/service-state.json",
+            "application":"/v1/applications/tesr",
+            "entity":"/v1/applications/tesr/entities/zQsqdXzi"
+        }
+    },
+    {
+        "name":"service.isUp",
+        "type":"java.lang.Boolean",
+        "description":"Service has been started successfully and is running",
+        "links":{
+            "self":"fixtures/service-state.json",
+            "application":"/v1/applications/tesr",
+            "entity":"/v1/applications/tesr/entities/zQsqdXzi"
+        }
+    }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary.json b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary.json
new file mode 100644
index 0000000..0803b37
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/sensor-summary.json
@@ -0,0 +1,8 @@
+{
+    "name":"redis.uptime",
+    "type":"Integer",
+    "description":"Description",
+    "links":{
+        "self":"/v1/applications/redis-app/entities/redis-ent/sensors/redis.uptime"
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/server-version.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/server-version.json b/rest/rest-server-jersey/src/test/resources/fixtures/server-version.json
new file mode 100644
index 0000000..affd707
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/server-version.json
@@ -0,0 +1,14 @@
+{
+    "version": "0.7.0-SNAPSHOT",
+    "buildSha1": "cb4f0a3af2f5042222dd176edc102bfa64e7e0b5",
+    "buildBranch":"versions",
+    "features":[
+        {
+          "name": "Sample Brooklyn Project com.acme.sample:brooklyn-sample v0.1.0-SNAPSHOT",
+          "symbolicName":"com.acme.sample.brooklyn-sample",
+          "version":"0.1.0.SNAPSHOT",
+          "lastModified":"523305000",
+          "Brooklyn-Feature-Build-Id":"e0fee1adf795c84eec4735f039503eb18d9c35cc"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/service-state.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/service-state.json b/rest/rest-server-jersey/src/test/resources/fixtures/service-state.json
new file mode 100644
index 0000000..61d5e33
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/service-state.json
@@ -0,0 +1 @@
+running
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/resources/fixtures/task-summary-list.json
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/resources/fixtures/task-summary-list.json b/rest/rest-server-jersey/src/test/resources/fixtures/task-summary-list.json
new file mode 100644
index 0000000..25b3193
--- /dev/null
+++ b/rest/rest-server-jersey/src/test/resources/fixtures/task-summary-list.json
@@ -0,0 +1,15 @@
+[
+    {
+        "entityId":"VzK45RFC",
+        "entityDisplayName":"tomcat",
+        "displayName":"start",
+        "description":"invoking start on tomcat",
+        "id":"n24NC63Nsu",
+        "rawSubmitTimeUtc":1348663165550,
+        "submitTimeUtc":"2012-09-26 12:39:25",
+        "startTimeUtc":"2012-09-26 12:39:25",
+        "endTimeUtc":"2012-09-26 12:39:33",
+        "currentStatus":"Ended normally",
+        "detailedStatus":"Ended normally after 7940 ms\nResult: null"
+    }
+]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
index 2a43aa1..d868a77 100644
--- a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
+++ b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
@@ -26,8 +26,10 @@ import javax.servlet.DispatcherType;
 import javax.servlet.Filter;
 
 import org.apache.brooklyn.rest.apidoc.RestApiResourceScanner;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
-import org.eclipse.jetty.server.handler.ContextHandler;
+import org.apache.cxf.transport.common.gzip.GZIPInInterceptor;
+import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 
@@ -35,19 +37,21 @@ import io.swagger.config.ScannerFactory;
 
 public class RestApiSetup {
 
-    public static ContextHandler installRestServlet(ServletContextHandler context, Object... providers) {
+    public static void installRest(ServletContextHandler context, Object... providers) {
         initSwagger();
 
         BrooklynRestApp app = new BrooklynRestApp();
         for (Object o : providers) {
             app.singleton(o);
         }
-
         CXFNonSpringJaxrsServlet servlet = new CXFNonSpringJaxrsServlet(app);
+        servlet.setBus(BusFactory.newInstance().createBus());
+        servlet.getBus().getInInterceptors().add(new GZIPInInterceptor());
+        servlet.getBus().getInFaultInterceptors().add(new GZIPInInterceptor());
+        servlet.getBus().getOutInterceptors().add(new GZIPOutInterceptor());
         final ServletHolder servletHolder = new ServletHolder(servlet);
 
         context.addServlet(servletHolder, "/v1/*");
-        return context;
     }
 
     @SafeVarargs

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server/src/main/resources/not-a-jar-file.txt
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/main/resources/not-a-jar-file.txt b/rest/rest-server/src/main/resources/not-a-jar-file.txt
deleted file mode 100644
index fbc22fe..0000000
--- a/rest/rest-server/src/main/resources/not-a-jar-file.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-
-Test loading of malformed jar file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server/src/main/resources/reset-catalog.xml
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/main/resources/reset-catalog.xml b/rest/rest-server/src/main/resources/reset-catalog.xml
deleted file mode 100644
index adef40a..0000000
--- a/rest/rest-server/src/main/resources/reset-catalog.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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.
--->
-<catalog>
-    <name>Brooklyn Demos</name>
-
-    <template type="org.apache.brooklyn.entity.stock.BasicApplication" name="Basic application" />
-    <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
-        <libraries>
-            <bundle>${bundle-location}</bundle>
-        </libraries>
-    </template>
-    <catalog>
-        <name>Nested catalog</name>
-        <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
-            <libraries>
-                <bundle>${bundle-location}</bundle>
-            </libraries>
-        </template>
-    </catalog>
-</catalog>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
index 0fe421e..8d71dcb 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
@@ -220,7 +220,7 @@ public class BrooklynRestApiLauncher {
         context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext);
 
         installWar(context);
-        RestApiSetup.installRestServlet(context,
+        RestApiSetup.installRest(context,
                 new ManagementContextProvider(managementContext),
                 new ShutdownHandlerProvider(shutdownListener));
         RestApiSetup.installServletFilters(context, this.filters);
@@ -246,22 +246,6 @@ public class BrooklynRestApiLauncher {
                 : createTempWebDirWithIndexHtml("Brooklyn REST API <p> (gui not available)"));
     }
 
-    private ContextHandler servletContextHandler(ManagementContext managementContext) {
-        ResourceConfig config = new DefaultResourceConfig();
-        for (Object r: BrooklynRestApi.getAllResources())
-            config.getSingletons().add(r);
-        addShutdownListener(config, mgmt);
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext);
-        ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
-        context.addServlet(servletHolder, "/*");
-        context.setContextPath("/");
-
-        installBrooklynFilters(context, this.filters);
-        return context;
-    }
-
     /** NB: not fully supported; use one of the other {@link StartMode}s */
     private ContextHandler webXmlContextHandler(ManagementContext mgmt) {
         RestApiSetup.initSwagger();
@@ -344,49 +328,6 @@ public class BrooklynRestApiLauncher {
                 .start();
     }
 
-    public void installAsServletFilter(ServletContextHandler context) {
-        installAsServletFilter(context, DEFAULT_FILTERS);
-    }
-
-    private void installAsServletFilter(ServletContextHandler context, List<Class<? extends Filter>> filters) {
-        installBrooklynFilters(context, filters);
-
-        // now set up the REST servlet resources
-        ResourceConfig config = new DefaultResourceConfig();
-        // load all our REST API modules, JSON, and Swagger
-        for (Object r: BrooklynRestApi.getAllResources())
-            config.getSingletons().add(r);
-
-        // disable caching for dynamic content
-        config.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, NoCacheFilter.class.getName());
-        // Checks if appropriate request given HA status
-        config.getProperties().put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, org.apache.brooklyn.rest.filter.HaHotCheckResourceFilter.class.getName());
-        // configure to match empty path, or any thing which looks like a file path with /assets/ and extension html, css, js, or png
-        // and treat that as static content
-        config.getProperties().put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "(/?|[^?]*/assets/[^?]+\\.[A-Za-z0-9_]+)");
-        // and anything which is not matched as a servlet also falls through (but more expensive than a regex check?)
-        config.getFeatures().put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, true);
-        // finally create this as a _filter_ which falls through to a web app or something (optionally)
-        FilterHolder filterHolder = new FilterHolder(new ServletContainer(config));
-        context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class));
-
-        ManagementContext mgmt = OsgiCompat.getManagementContext(context);
-        config.getSingletons().add(new ManagementContextProvider(mgmt));
-        addShutdownListener(config, mgmt);
-    }
-
-    protected synchronized void addShutdownListener(ResourceConfig config, ManagementContext mgmt) {
-        if (shutdownListener!=null) throw new IllegalStateException("Can only retrieve one shutdown listener");
-        shutdownListener = new ServerStoppingShutdownHandler(mgmt);
-        config.getSingletons().add(new ShutdownHandlerProvider(shutdownListener));
-    }
-
-    private static void installBrooklynFilters(ServletContextHandler context, List<Class<? extends Filter>> filters) {
-        for (Class<? extends Filter> filter : filters) {
-            context.addFilter(filter, "/*", EnumSet.allOf(DispatcherType.class));
-        }
-    }
-
     /**
      * Starts the server on all nics (even if security not enabled).
      * @deprecated since 0.6.0; use {@link #launcher()} and set a custom context

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/utils/rest-swagger/src/main/java/org/apache/brooklyn/rest/apidoc/ApiListingResource.java
----------------------------------------------------------------------
diff --git a/utils/rest-swagger/src/main/java/org/apache/brooklyn/rest/apidoc/ApiListingResource.java b/utils/rest-swagger/src/main/java/org/apache/brooklyn/rest/apidoc/ApiListingResource.java
deleted file mode 100644
index 2d08329..0000000
--- a/utils/rest-swagger/src/main/java/org/apache/brooklyn/rest/apidoc/ApiListingResource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 The Apache Software Foundation.
- *
- * Licensed 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.apidoc;
-
-public class ApiListingResource extends io.swagger.jaxrs.listing.ApiListingResource {
-
-}