You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2017/06/06 13:41:44 UTC

[4/5] brooklyn-server git commit: address @geomacy comments

address @geomacy comments


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

Branch: refs/heads/master
Commit: 4e64e5435a9d38d1d5f816680e959451e895897a
Parents: f843ac8
Author: Andrea Turli <an...@gmail.com>
Authored: Tue Jun 6 15:16:18 2017 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Tue Jun 6 15:16:18 2017 +0200

----------------------------------------------------------------------
 .../brooklyn/core/effector/http/HttpCommandEffector.java  | 10 +++++++---
 .../core/effector/http/HttpCommandEffectorTest.java       |  9 ++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4e64e543/core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java b/core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java
index 8bef573..12a847a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java
+++ b/core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java
@@ -42,6 +42,7 @@ import org.apache.brooklyn.core.effector.AddEffector;
 import org.apache.brooklyn.core.effector.EffectorBody;
 import org.apache.brooklyn.core.effector.Effectors.EffectorBuilder;
 import org.apache.brooklyn.core.entity.EntityInitializers;
+import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.util.collections.Jsonya;
 import org.apache.brooklyn.util.core.config.ConfigBag;
@@ -75,7 +76,6 @@ import com.jayway.jsonpath.JsonPath;
  * In the latter case, a map payload will be URLEncoded in a single string
  * 
  * With optional JSON_PATH config key, the effector will extract a section of the json response. 
- * Notice if both JSON_PATH and JSON_PATHS_AND_SENSORS are both defined, JSON_PATH will take precedence. 
  * 
  * Using JSON_PATHS_AND_SENSORS, it is possible to extract one or more values from a json response, and publish them in sensors
  */
@@ -91,9 +91,13 @@ public final class HttpCommandEffector extends AddEffector {
     public static final ConfigKey<Map<String, String>> EFFECTOR_HTTP_HEADERS = new MapConfigKey(String.class, "headers");
     public static final ConfigKey<Object> EFFECTOR_HTTP_PAYLOAD = ConfigKeys.newConfigKey(Object.class, "httpPayload");
     public static final ConfigKey<String> JSON_PATH = ConfigKeys.newStringConfigKey("jsonPath", "JSON path to select in HTTP response");
-    @Deprecated 
+    public static final ConfigKey<Map<String, String>> JSON_PATHS_AND_SENSORS = new MapConfigKey(String.class, "jsonPathAndSensors", "json path selector and corresponding sensor name that will publish the json path extracted value");
+
+    /**
+     * @deprecated since 0.12.0
+     */
+    @Deprecated
     public static final ConfigKey<String> PUBLISH_SENSOR = ConfigKeys.newStringConfigKey("publishSensor", "Sensor name where to store json path extracted value");
-    public static final ConfigKey<Map<String, String>> JSON_PATHS_AND_SENSORS = new MapConfigKey(String.class, "jsonPathAndSensors", "json path selector and correspondant sensor name that will publish the json path extracted value");
 
     public static final String APPLICATION_JSON = "application/json";
     public static final String APPLICATION_X_WWW_FORM_URLENCODE = "application/x-www-form-urlencoded";

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4e64e543/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorTest.java b/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorTest.java
index 75d1e03..7951e65 100644
--- a/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorTest.java
@@ -261,12 +261,15 @@ public class HttpCommandEffectorTest extends BrooklynAppUnitTestSupport {
       );
       assertNotNull(httpCommandEffector);
       TestEntity testEntity = app.createAndManageChild(buildEntitySpec(httpCommandEffector));
-      Object output = testEntity.invoke(EFFECTOR_HTTP_COMMAND, ImmutableMap.of()).getUnchecked(Duration.seconds(1));
+      Object output = testEntity.invoke(EFFECTOR_HTTP_COMMAND, ImmutableMap.of()).getUnchecked(Duration.seconds(5));
       assertEquals(output, "{\"key\", \"%3Cimg%3E\"}");
       
       assertEquals(server.getRequestCount(), 1);
-      assertSent(server, "POST", "/post");
-   }
+      RecordedRequest recordedRequest = assertSent(server, "POST", "/post");
+      assertEquals("POST", recordedRequest.getMethod());
+      assertEquals("key=%3Cimg%3E", recordedRequest.getUtf8Body());
+      assertEquals("13", recordedRequest.getHeader("Content-Length"));
+      assertEquals(HttpCommandEffector.APPLICATION_X_WWW_FORM_URLENCODE, recordedRequest.getHeader("Content-Type"));   }
    
    @Test
    public void testHappyPath() throws InterruptedException {