brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [07/13] incubator-brooklyn git commit: fix and test better rest client
Date Fri, 29 May 2015 10:36:07 GMT
fix and test better rest client

other misc rest cleanups


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

Branch: refs/heads/master
Commit: dbd0cdc40912c60c69c7bf41eb5dfb3170dbc646
Parents: 42e9aad
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed May 27 19:10:37 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu May 28 13:07:29 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/basic/EntityInternal.java   |  3 ++-
 .../java/brooklyn/rest/api/ApplicationApi.java  |  7 ++++--
 usage/rest-client/pom.xml                       |  1 -
 .../java/brooklyn/rest/client/BrooklynApi.java  | 25 ++++++++++----------
 .../rest/client/BrooklynApiRestClientTest.java  | 23 +++++++++++++-----
 .../rest/resources/ApplicationResource.java     |  5 ----
 .../rest/resources/CatalogResource.java         |  1 +
 .../rest/resources/EntityConfigResource.java    | 14 +++++------
 .../rest/resources/PolicyConfigResource.java    |  2 +-
 .../provider/DelegatingSecurityProvider.java    | 11 ++++++++-
 .../rest/transform/LocationTransformer.java     | 11 +++++----
 .../rest/util/BrooklynRestResourceUtils.java    |  5 ++--
 .../rest/util/json/MultimapSerializer.java      |  4 ++--
 .../BrooklynRestApiLauncherTestFixture.java     |  1 -
 .../brooklyn/rest/domain/ApplicationTest.java   |  2 +-
 .../rest/domain/LocationSummaryTest.java        |  1 +
 .../ApplicationResourceIntegrationTest.java     |  1 -
 .../resources/EntityConfigResourceTest.java     |  4 ++--
 .../rest/resources/LocationResourceTest.java    |  6 +++--
 .../rest/resources/ServerResourceTest.java      | 10 ++++----
 .../rest/testing/mocks/EverythingGroupImpl.java |  2 +-
 .../testing/mocks/NameMatcherGroupImpl.java     |  2 +-
 .../json/BrooklynJacksonSerializerTest.java     | 10 ++++----
 23 files changed, 85 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/core/src/main/java/brooklyn/entity/basic/EntityInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityInternal.java b/core/src/main/java/brooklyn/entity/basic/EntityInternal.java
index ba8df78..b0e517e 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityInternal.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityInternal.java
@@ -66,7 +66,8 @@ public interface EntityInternal extends BrooklynObjectInternal, EntityLocal,
Reb
     /**
      * @return a read-only copy of all the config key/value pairs on this entity.
      * 
-     * @deprecated since 0.7.0; instead just use methods on {@link ConfigurationSupportInternal}
returned by {@link #config()}
+     * @deprecated since 0.7.0; instead just use methods on {@link ConfigurationSupportInternal}
returned by {@link #config()},
+     * e.g. getBag().getAllConfigAsConfigKeyMap().
      */
     @Deprecated
     @Beta

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
index 865024a..7da543b 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
@@ -81,8 +81,11 @@ public interface ApplicationApi {
             @DefaultValue(".*")
             @QueryParam("typeRegex") String typeRegex);
 
-    /** As {@link #list(String)}, filtering for <code>.*</code>. */
-    public List<ApplicationSummary> list();
+    // would be nice to have this on the API so default type regex not needed, but
+    // not yet implemented, as per: https://issues.jboss.org/browse/RESTEASY-798
+    // (this method was added to this class, but it breaks the rest client)
+//    /** As {@link #list(String)}, filtering for <code>.*</code>. */
+//    public List<ApplicationSummary> list();
 
     @GET
     @Path("/{application}")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-client/pom.xml
----------------------------------------------------------------------
diff --git a/usage/rest-client/pom.xml b/usage/rest-client/pom.xml
index f39903c..70c48e2 100644
--- a/usage/rest-client/pom.xml
+++ b/usage/rest-client/pom.xml
@@ -148,7 +148,6 @@
         <plugins>
             <plugin>
                 <artifactId>maven-dependency-plugin</artifactId>
-                <version>${maven-dependency-plugin.version}</version>
                 <executions>
                     <execution>
                         <id>prep-server</id>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java b/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java
index 7bcff46..c813864 100644
--- a/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java
+++ b/usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java
@@ -22,9 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.net.MalformedURLException;
 import java.net.URL;
+
+import javax.annotation.Nullable;
 import javax.ws.rs.core.Response;
 
-import org.apache.commons.codec.binary.Base64;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.jboss.resteasy.client.ClientExecutor;
 import org.jboss.resteasy.client.ClientRequest;
@@ -33,8 +37,6 @@ import org.jboss.resteasy.client.ProxyFactory;
 import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
 import org.jboss.resteasy.util.GenericType;
 
-import com.google.common.base.Charsets;
-
 import brooklyn.rest.api.AccessApi;
 import brooklyn.rest.api.ActivityApi;
 import brooklyn.rest.api.ApplicationApi;
@@ -50,9 +52,6 @@ import brooklyn.rest.api.SensorApi;
 import brooklyn.rest.api.ServerApi;
 import brooklyn.rest.api.UsageApi;
 import brooklyn.rest.api.VersionApi;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
 
 /**
  * @author Adam Lowe
@@ -68,7 +67,8 @@ public class BrooklynApi {
     }
 
     public BrooklynApi(String endpoint) {
-        this(endpoint, null, null);
+        // username/password cannot be null, but credentials can
+        this(endpoint, null);
     }
 
     public BrooklynApi(URL endpoint, String username, String password) {
@@ -79,14 +79,13 @@ public class BrooklynApi {
         this(endpoint, new UsernamePasswordCredentials(username, password));
     }
 
-    public BrooklynApi(URL endpoint, Credentials credentials) {
+    public BrooklynApi(URL endpoint, @Nullable Credentials credentials) {
         this(endpoint.toString(), credentials);
     }
 
-    public BrooklynApi(String endpoint, Credentials credentials) {
-        URL target = null;
+    public BrooklynApi(String endpoint, @Nullable Credentials credentials) {
         try {
-            target = new URL(checkNotNull(endpoint, "endpoint"));
+            new URL(checkNotNull(endpoint, "endpoint"));
         } catch (MalformedURLException e) {
             throw new IllegalArgumentException(e);
         }
@@ -170,7 +169,7 @@ public class BrooklynApi {
         return proxy(AccessApi.class);
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> T getEntity(Response response, Class<T> type) {
         if (!(response instanceof ClientResponse)) {
             throw new IllegalArgumentException("Response should be instance of ClientResponse,
is: " + response.getClass());
@@ -179,7 +178,7 @@ public class BrooklynApi {
         return (T) clientResponse.getEntity(type);
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> T getEntityGeneric(Response response, GenericType type) {
         if (!(response instanceof ClientResponse)) {
             throw new IllegalArgumentException("Response should be instance of ClientResponse,
is: " + response.getClass());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java
b/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java
index b67b972..9e5fbb3 100644
--- a/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java
+++ b/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java
@@ -19,6 +19,7 @@
 package brooklyn.rest.client;
 
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
@@ -37,9 +38,8 @@ import brooklyn.management.ManagementContext;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.rest.BrooklynRestApiLauncher;
 import brooklyn.rest.BrooklynRestApiLauncherTest;
-import brooklyn.rest.domain.LocationSummary;
-import brooklyn.rest.security.provider.ExplicitUsersSecurityProvider;
-import brooklyn.rest.security.provider.SecurityProvider;
+import brooklyn.rest.domain.ApplicationSummary;
+import brooklyn.rest.domain.CatalogLocationSummary;
 import brooklyn.rest.security.provider.TestSecurityProvider;
 
 @Test
@@ -92,9 +92,20 @@ public class BrooklynApiRestClientTest {
         Entities.destroyAll(getManagementContext());
     }
 
-    public void testListLocations() throws Exception {
-        List<LocationSummary> locations = api.getLocationApi().list();
-        log.info("locations are: "+locations);
+    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 testApplicationApiList() throws Exception {
+        List<ApplicationSummary> apps = api.getApplicationApi().list(null);
+        log.info("apps are: "+apps);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
index 0144d56..89d59e5 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
@@ -218,11 +218,6 @@ public class ApplicationResource extends AbstractBrooklynRestResource
implements
     }
 
     @Override
-    public List<ApplicationSummary> list() {
-        return list(".*");
-    }
-
-    @Override
     public List<ApplicationSummary> list(String typeRegex) {
         if (Strings.isBlank(typeRegex)) {
             typeRegex = ".*";

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
index 5332bb0..1e1bc28 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
@@ -126,6 +126,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements
Cat
         return Response.status(Status.CREATED).entity(result).build();
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public Response resetXml(String xml, boolean ignoreErrors) {
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM,
null) ||

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
index 2c3ceb6..0984ebf 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
@@ -72,9 +72,9 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     public Map<String, Object> batchConfigRead(String application, String entityToken,
Boolean raw) {
         // TODO: add test
         EntityLocal entity = brooklyn().getEntity(application, entityToken);
-        Map<ConfigKey<?>, Object> source = ((EntityInternal) entity).getAllConfig();
+        Map<ConfigKey<?>, ?> source = ((EntityInternal) entity).config().getBag().getAllConfigAsConfigKeyMap();
         Map<String, Object> result = Maps.newLinkedHashMap();
-        for (Map.Entry<ConfigKey<?>, Object> ek : source.entrySet()) {
+        for (Map.Entry<ConfigKey<?>, ?> ek : source.entrySet()) {
             Object value = ek.getValue();
             if (Boolean.FALSE.equals(raw)) {
                 value = RendererHints.applyDisplayValueHint(ek.getKey(), value);
@@ -97,7 +97,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     public Object get(boolean preferJson, String application, String entityToken, String
configKeyName, Boolean raw) {
         EntityLocal entity = brooklyn().getEntity(application, entityToken);
         ConfigKey<?> ck = findConfig(entity, configKeyName);
-        Object value = entity.getConfigRaw(ck, true).orNull();
+        Object value = ((EntityInternal)entity).config().getRaw(ck).orNull();
         if (Boolean.FALSE.equals(raw)) {
             value = RendererHints.applyDisplayValueHint(ck, value);
         }
@@ -127,10 +127,10 @@ public class EntityConfigResource extends AbstractBrooklynRestResource
implement
             Object newValue = ((Map.Entry) entry).getValue();
 
             ConfigKey ck = findConfig(entity, configName);
-            ((EntityInternal) entity).setConfig(ck, TypeCoercions.coerce(newValue, ck.getTypeToken()));
+            ((EntityInternal) entity).config().set(ck, TypeCoercions.coerce(newValue, ck.getTypeToken()));
             if (Boolean.TRUE.equals(recurse)) {
                 for (Entity e2 : Entities.descendants(entity, Predicates.alwaysTrue(), false))
{
-                    ((EntityInternal) e2).setConfig(ck, newValue);
+                    ((EntityInternal) e2).config().set(ck, newValue);
                 }
             }
         }
@@ -147,10 +147,10 @@ public class EntityConfigResource extends AbstractBrooklynRestResource
implement
 
         ConfigKey ck = findConfig(entity, configName);
         LOG.debug("REST setting config " + configName + " on " + entity + " to " + newValue);
-        ((EntityInternal) entity).setConfig(ck, TypeCoercions.coerce(newValue, ck.getTypeToken()));
+        ((EntityInternal) entity).config().set(ck, TypeCoercions.coerce(newValue, ck.getTypeToken()));
         if (Boolean.TRUE.equals(recurse)) {
             for (Entity e2 : Entities.descendants(entity, Predicates.alwaysTrue(), false))
{
-                ((EntityInternal) e2).setConfig(ck, newValue);
+                ((EntityInternal) e2).config().set(ck, newValue);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
index f9493ea..471cd22 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
@@ -98,7 +98,7 @@ public class PolicyConfigResource extends AbstractBrooklynRestResource implement
         ConfigKey<?> ck = policy.getPolicyType().getConfigKey(configKeyName);
         if (ck == null) throw WebResourceUtils.notFound("Cannot find config key '%s' in policy
'%s' of entity '%s'", configKeyName, policy, entityToken);
 
-        policy.setConfig((ConfigKey) ck, TypeCoercions.coerce(value, ck.getTypeToken()));
+        policy.config().set((ConfigKey) ck, TypeCoercions.coerce(value, ck.getTypeToken()));
 
         return Response.status(Response.Status.OK).build();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
b/usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
index e7669ba..f4307ac 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
@@ -20,6 +20,7 @@ package brooklyn.rest.security.provider;
 
 import java.lang.reflect.Constructor;
 import java.util.concurrent.atomic.AtomicLong;
+
 import javax.servlet.http.HttpSession;
 
 import org.slf4j.Logger;
@@ -44,6 +45,8 @@ public class DelegatingSecurityProvider implements SecurityProvider {
     private final AtomicLong modCount = new AtomicLong();
 
     private class PropertiesListener implements ManagementContext.PropertiesReloadListener
{
+        private static final long serialVersionUID = 8148722609022378917L;
+
         @Override
         public void reloaded() {
             log.debug("{} reloading security provider", DelegatingSecurityProvider.this);
@@ -94,10 +97,16 @@ public class DelegatingSecurityProvider implements SecurityProvider {
                 delegate = constructor.newInstance(mgmt);
             } catch (Exception e) {
                 constructor = clazz.getConstructor();
-                delegate = constructor.newInstance();
+                Object delegateO = constructor.newInstance();
+                if (!(delegateO instanceof SecurityProvider)) {
+                    // if classloaders get mangled it will be a different CL's SecurityProvider
+                    throw new ClassCastException("Delegate is either not a security provider
or has an incompatible classloader: "+delegateO);
+                }
+                delegate = (SecurityProvider) delegateO;
             }
         } catch (Exception e) {
             log.warn("REST unable to instantiate security provider " + className + "; all
logins are being disallowed", e);
+            e.printStackTrace();
             delegate = new BlackholeSecurityProvider();
         }
         return delegate;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
index fbf0b7d..6df1d4f 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
@@ -24,14 +24,13 @@ import java.util.Map;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.Sanitizer;
 import brooklyn.location.Location;
 import brooklyn.location.LocationDefinition;
 import brooklyn.location.basic.BasicLocationDefinition;
 import brooklyn.location.basic.LocationConfigKeys;
 import brooklyn.location.basic.LocationInternal;
 import brooklyn.management.ManagementContext;
-import brooklyn.rest.domain.LocationSpec;
 import brooklyn.rest.domain.LocationSummary;
 import brooklyn.rest.util.WebResourceUtils;
 import brooklyn.util.collections.MutableMap;
@@ -43,16 +42,18 @@ import com.google.common.collect.ImmutableMap;
 
 public class LocationTransformer {
 
+    @SuppressWarnings("unused")
     private static final Logger log = LoggerFactory.getLogger(LocationTransformer.LocationDetailLevel.class);
     
     public static enum LocationDetailLevel { NONE, LOCAL_EXCLUDING_SECRET, FULL_EXCLUDING_SECRET,
FULL_INCLUDING_SECRET }
     
     /** @deprecated since 0.7.0 use method taking management context and detail specifier
*/
     @Deprecated
-    public static LocationSummary newInstance(String id, LocationSpec locationSpec) {
+    public static LocationSummary newInstance(String id, brooklyn.rest.domain.LocationSpec
locationSpec) {
         return newInstance(null, id, locationSpec, LocationDetailLevel.LOCAL_EXCLUDING_SECRET);
     }
-    public static LocationSummary newInstance(ManagementContext mgmt, String id, LocationSpec
locationSpec, LocationDetailLevel level) {
+    @SuppressWarnings("deprecation")
+    public static LocationSummary newInstance(ManagementContext mgmt, String id, brooklyn.rest.domain.LocationSpec
locationSpec, LocationDetailLevel level) {
         // TODO: Remove null checks on mgmt when newInstance(String, LocationSpec) is deleted
         Map<String, ?> config = locationSpec.getConfig();
         if (mgmt != null && (level==LocationDetailLevel.FULL_EXCLUDING_SECRET ||
level==LocationDetailLevel.FULL_INCLUDING_SECRET)) {
@@ -123,7 +124,7 @@ public class LocationTransformer {
         ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
         if (level!=LocationDetailLevel.NONE) {
             for (Map.Entry<String,?> entry : entries.entrySet()) {
-                if (level==LocationDetailLevel.FULL_INCLUDING_SECRET || !Entities.isSecret(entry.getKey()))
{
+                if (level==LocationDetailLevel.FULL_INCLUDING_SECRET || !Sanitizer.IS_SECRET_PREDICATE.apply(entry.getKey()))
{
                     builder.put(entry.getKey(), WebResourceUtils.getValueForDisplay(entry.getValue(),
true, false));
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
b/usage/rest-server/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
index c3499b8..eef55f2 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
@@ -205,7 +205,7 @@ public class BrooklynRestResourceUtils {
         return null;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "deprecation" })
     public Application create(ApplicationSpec spec) {
         log.debug("REST creating application instance for {}", spec);
         
@@ -332,7 +332,7 @@ public class BrooklynRestResourceUtils {
         return locations;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "deprecation" })
     private brooklyn.entity.proxying.EntitySpec<? extends Entity> toCoreEntitySpec(brooklyn.rest.domain.EntitySpec
spec) {
         String type = spec.getType();
         String name = spec.getName();
@@ -466,6 +466,7 @@ public class BrooklynRestResourceUtils {
     @SuppressWarnings({ "rawtypes" })
     public Response createCatalogEntryFromGroovyCode(String groovyCode) {
         ClassLoader parent = getCatalog().getRootClassLoader();
+        @SuppressWarnings("resource")
         GroovyClassLoader loader = new GroovyClassLoader(parent);
 
         Class clazz = loader.parseClass(groovyCode);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/main/java/brooklyn/rest/util/json/MultimapSerializer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/util/json/MultimapSerializer.java
b/usage/rest-server/src/main/java/brooklyn/rest/util/json/MultimapSerializer.java
index 7ab36c5..b0778b9 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/util/json/MultimapSerializer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/util/json/MultimapSerializer.java
@@ -23,12 +23,11 @@ import java.util.Collection;
 import java.util.Map;
 
 import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.map.JsonSerializer;
 import org.codehaus.jackson.map.SerializerProvider;
 import org.codehaus.jackson.map.ser.std.SerializerBase;
 
-import com.google.common.collect.Lists;
 import com.google.common.annotations.Beta;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 
 /**
@@ -41,6 +40,7 @@ import com.google.common.collect.Multimap;
 @Beta
 public class MultimapSerializer extends SerializerBase<Multimap<?, ?>> {
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     protected MultimapSerializer() {
         super((Class<Multimap<?, ?>>) (Class) Multimap.class);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
index 1778786..c9aa4f0 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
@@ -30,7 +30,6 @@ import brooklyn.config.BrooklynServiceAttributes;
 import brooklyn.entity.basic.Entities;
 import brooklyn.management.ManagementContext;
 import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.rest.security.provider.AnyoneSecurityProvider;
 import brooklyn.util.exceptions.Exceptions;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/domain/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/domain/ApplicationTest.java b/usage/rest-server/src/test/java/brooklyn/rest/domain/ApplicationTest.java
index cb98129..f905ed9 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/domain/ApplicationTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/domain/ApplicationTest.java
@@ -21,7 +21,6 @@ package brooklyn.rest.domain;
 import static brooklyn.rest.util.RestApiTestUtils.asJson;
 import static brooklyn.rest.util.RestApiTestUtils.fromJson;
 import static brooklyn.rest.util.RestApiTestUtils.jsonFixture;
-
 import static org.testng.Assert.assertEquals;
 
 import java.io.IOException;
@@ -53,6 +52,7 @@ public class ApplicationTest {
 
     final ApplicationSummary application = new ApplicationSummary(null, applicationSpec,
Status.STARTING, null);
 
+    @SuppressWarnings("serial")
     @Test
     public void testSerializeToJSON() throws IOException {
         ApplicationSummary application1 = new ApplicationSummary("myapp_id", applicationSpec,
Status.STARTING, null) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/domain/LocationSummaryTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/domain/LocationSummaryTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/domain/LocationSummaryTest.java
index 061dde7..ebfd004 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/domain/LocationSummaryTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/domain/LocationSummaryTest.java
@@ -34,6 +34,7 @@ import brooklyn.rest.transform.LocationTransformer;
 
 public class LocationSummaryTest {
 
+    @SuppressWarnings("deprecation")
     final LocationSummary summary = LocationTransformer.newInstance("123", LocationSpec.localhost());
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
index 88b7b8d..0eda001 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
@@ -23,7 +23,6 @@ import static org.testng.Assert.assertTrue;
 
 import java.net.URI;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/resources/EntityConfigResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/EntityConfigResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/EntityConfigResourceTest.java
index af8ca5d..1d35716 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/EntityConfigResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/EntityConfigResourceTest.java
@@ -149,7 +149,7 @@ public class EntityConfigResourceTest extends BrooklynRestResourceTest
{
             String value = client().resource(uri).accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
             assertEquals(value, "\"hello world\"");
 
-        } finally { entity.setConfig(RestMockSimpleEntity.SAMPLE_CONFIG, RestMockSimpleEntity.SAMPLE_CONFIG.getDefaultValue());
}
+        } finally { entity.config().set(RestMockSimpleEntity.SAMPLE_CONFIG, RestMockSimpleEntity.SAMPLE_CONFIG.getDefaultValue());
}
     }
 
     @Test
@@ -167,7 +167,7 @@ public class EntityConfigResourceTest extends BrooklynRestResourceTest
{
             String value = client().resource(uri+"/"+RestMockSimpleEntity.SAMPLE_CONFIG.getName()).accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
             assertEquals(value, "\"hello world\"");
 
-        } finally { entity.setConfig(RestMockSimpleEntity.SAMPLE_CONFIG, RestMockSimpleEntity.SAMPLE_CONFIG.getDefaultValue());
}
+        } finally { entity.config().set(RestMockSimpleEntity.SAMPLE_CONFIG, RestMockSimpleEntity.SAMPLE_CONFIG.getDefaultValue());
}
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
index aab0a43..4ff3a5d 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java
@@ -36,7 +36,6 @@ import org.testng.annotations.Test;
 
 import brooklyn.location.jclouds.JcloudsLocation;
 import brooklyn.rest.domain.CatalogLocationSummary;
-import brooklyn.rest.domain.LocationSpec;
 import brooklyn.rest.domain.LocationSummary;
 import brooklyn.rest.testing.BrooklynRestResourceTest;
 import brooklyn.test.Asserts;
@@ -67,7 +66,7 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
                 "credential", "CR3dential");
         ClientResponse response = client().resource("/v1/locations")
                 .type(MediaType.APPLICATION_JSON_TYPE)
-                .post(ClientResponse.class, new LocationSpec(legacyLocationName, "aws-ec2:us-east-1",
expectedConfig));
+                .post(ClientResponse.class, new brooklyn.rest.domain.LocationSpec(legacyLocationName,
"aws-ec2:us-east-1", expectedConfig));
 
         URI addedLegacyLocationUri = response.getLocation();
         log.info("added legacy, at: " + addedLegacyLocationUri);
@@ -83,6 +82,7 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
         Assert.assertEquals(l.getCredential(), "CR3dential");
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testAddNewLocationDefinition() {
         String yaml = Joiner.on("\n").join(ImmutableList.of(
@@ -122,6 +122,7 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
         Assert.assertEquals(l.getCredential(), "CR3dential");
     }
 
+    @SuppressWarnings("deprecation")
     @Test(dependsOnMethods = { "testAddNewLocationDefinition" })
     public void testListAllLocationDefinitions() {
         Set<LocationSummary> locations = client().resource("/v1/locations")
@@ -139,6 +140,7 @@ public class LocationResourceTest extends BrooklynRestResourceTest {
         Assert.assertEquals(location.getLinks().get("self"), expectedLocationUri);
     }
 
+    @SuppressWarnings("deprecation")
     @Test(dependsOnMethods = { "testListAllLocationDefinitions" })
     public void testGetSpecificLocation() {
         URI expectedLocationUri = URI.create("/v1/locations/"+locationName);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
index 26491b3..ed5c1b4 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
@@ -21,28 +21,25 @@ package brooklyn.rest.resources;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
-import brooklyn.config.BrooklynProperties;
-import brooklyn.management.internal.ManagementContextInternal;
-import com.google.common.collect.ImmutableMap;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
 
 import brooklyn.BrooklynVersion;
+import brooklyn.config.BrooklynProperties;
 import brooklyn.management.ManagementContext;
+import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.rest.domain.HighAvailabilitySummary;
 import brooklyn.rest.domain.VersionSummary;
 import brooklyn.rest.testing.BrooklynRestResourceTest;
 import brooklyn.test.Asserts;
 
 import com.google.common.collect.ImmutableSet;
+import com.sun.jersey.api.client.UniformInterfaceException;
 
 @Test(singleThreaded = true)
 public class ServerResourceTest extends BrooklynRestResourceTest {
@@ -80,6 +77,7 @@ public class ServerResourceTest extends BrooklynRestResourceTest {
         assertEquals(summary.getNodes().get(ownNodeId).getLocalTimestamp(), summary.getNodes().get(ownNodeId).getRemoteTimestamp());
     }
 
+    @SuppressWarnings("serial")
     @Test
     public void testReloadsBrooklynProperties() throws Exception {
         final AtomicInteger reloadCount = new AtomicInteger();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/EverythingGroupImpl.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/EverythingGroupImpl.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/EverythingGroupImpl.java
index 8f66682..b9e1667 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/EverythingGroupImpl.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/EverythingGroupImpl.java
@@ -26,7 +26,7 @@ public class EverythingGroupImpl extends DynamicGroupImpl implements EverythingG
 
     public EverythingGroupImpl() {
         super();
-        setConfig(ENTITY_FILTER, Predicates.alwaysTrue());
+        config().set(ENTITY_FILTER, Predicates.alwaysTrue());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/NameMatcherGroupImpl.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/NameMatcherGroupImpl.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/NameMatcherGroupImpl.java
index b0b5854..f0b482d 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/NameMatcherGroupImpl.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/NameMatcherGroupImpl.java
@@ -27,7 +27,7 @@ public class NameMatcherGroupImpl extends DynamicGroupImpl implements NameMatche
     @Override
     public void init() {
         super.init();
-        setConfig(ENTITY_FILTER, EntityPredicates.displayNameSatisfies(StringPredicates.matchesRegex(getConfig(NAME_REGEX))));
+        config().set(ENTITY_FILTER, EntityPredicates.displayNameSatisfies(StringPredicates.matchesRegex(getConfig(NAME_REGEX))));
         rescanEntities();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dbd0cdc4/usage/rest-server/src/test/java/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
index 552999f..8437ae3 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
@@ -299,7 +299,7 @@ public class BrooklynJacksonSerializerTest {
                     .build();
 
             // assert config here is just mgmt.toString()
-            app.setConfig(TestEntity.CONF_OBJECT, mgmt);
+            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);
@@ -332,7 +332,7 @@ public class BrooklynJacksonSerializerTest {
                     .build();
 
             // assert config here is just mgmt
-            app.setConfig(TestEntity.CONF_OBJECT, 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")
@@ -349,7 +349,7 @@ public class BrooklynJacksonSerializerTest {
             Assert.assertNotNull(values.get("links"), "Map should have contained links: values="+values);
 
             // but config etc returns our nicely json serialized
-            app.setConfig(TestEntity.CONF_OBJECT, app);
+            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);
@@ -357,13 +357,13 @@ public class BrooklynJacksonSerializerTest {
 
             // and self-ref gives error + toString
             SelfRefNonSerializableClass angry = new SelfRefNonSerializableClass();
-            app.setConfig(TestEntity.CONF_OBJECT, angry);
+            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.setConfig(TestEntity.CONF_OBJECT, 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!



Mime
View raw message