brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Adds getConfig method to server R...
Date Fri, 13 Feb 2015 14:07:17 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/509#discussion_r24665503
  
    --- Diff: usage/rest-server/src/test/java/brooklyn/rest/resources/ServerResourceTest.java
---
    @@ -97,5 +103,38 @@ public void testShutdown() throws Exception {
                     assertFalse(getManagementContext().isRunning());
                 }});
         }
    -    
    +
    +    @Test
    +    void testGetConfig() throws Exception {
    +        ((ManagementContextInternal)getManagementContext()).getBrooklynProperties().put("foo.bar.baz",
"quux");
    +        try {
    +            assertEquals(client().resource("/v1/server/config/foo.bar.baz").get(String.class),
"quux");
    +        } finally {
    +            ((ManagementContextInternal)getManagementContext()).getBrooklynProperties().remove("foo.bar.baz");
    +        }
    +    }
    +
    +    @Test
    +    void testGetMissingConfigThrowsException() throws Exception {
    +        final String key = "foo.bar.baz";
    +        BrooklynProperties properties = ((ManagementContextInternal)getManagementContext()).getBrooklynProperties();
    +        Object existingValue = null;
    +        boolean keyAlreadyPresent = false;
    +        String response = null;
    +        if (properties.containsKey(key)) {
    +            existingValue = properties.remove(key);
    +            keyAlreadyPresent = true;
    +        }
    +        try {
    +            response = client().resource("/v1/server/config/" + key).get(String.class);
    +        } catch (UniformInterfaceException e) {
    +            assertEquals(e.getResponse().getStatus(), 204);
    --- End diff --
    
    jenkins shows:
    
        2015-02-10 10:44:28,237 INFO  TESTNG INVOKING: "Surefire test" - brooklyn.rest.resources.ServerResourceTest.testGetMissingConfigThrowsException()
        2015-02-10 10:44:28,237 INFO  3 * Server in-bound request
        3 > GET /v1/server/config/foo.bar.baz
        3 > 
    
        2015-02-10 10:44:28,237 INFO  3 * Server out-bound response
        3 < 204
        3 < Content-Type: application/json
        3 < 
    
    We either want to fix comments to say it will be a 204, or fix the impl so it throws a
404 (see stuff like `BrooklynRestResourceUtils.getApplication`, where it does `throw notFound("Application
'%s' not found", application)`).
    
    It looks to me like `EntityConfigResource.get(...)` is going to behave the same as your
code if the config key isn't known. Maybe we just want to update the annotations in `EntityConfigApi.get(...)`
etc to say it gives a 404 if "Could not find application or entity" instead of "Could not
find application, entity or config key".
    
    Thoughts?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message