Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1044 3c60c49a1 -> 2778f0a0b


USERGRID-1044: transform payload to empty JSON if non-json


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2778f0a0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2778f0a0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2778f0a0

Branch: refs/heads/USERGRID-1044
Commit: 2778f0a0b196bfc09e914033392ccb49271136e0
Parents: 3c60c49
Author: Mike Dunker <mdun...@apigee.com>
Authored: Tue Oct 27 10:49:44 2015 -0700
Committer: Mike Dunker <mdun...@apigee.com>
Committed: Tue Oct 27 10:49:44 2015 -0700

----------------------------------------------------------------------
 .../org/apache/usergrid/helpers/Extractors.scala   |  2 +-
 .../scenarios/EntityCollectionScenarios.scala      | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2778f0a0/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git 
a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala 
b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
index b21f9d7..4c6ac8d 100644
--- 
a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
+++ 
b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -85,7 +85,7 @@ object Extractors {
   def extractAuditEntity(saveAsName: String) = {
     
jsonPath("$.entities[0]").ofType[Map[String,Any]].findAll.transformOption(extract
 => {
       extract.orElse(Some(Seq.empty))
-    }).optional.saveAs(saveAsName)
+    }).saveAs(saveAsName)
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2778f0a0/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
----------------------------------------------------------------------
diff --git 
a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
 
b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
index ecd0c21..bcdb49a 100644
--- 
a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
+++ 
b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
@@ -16,9 +16,13 @@
  */
 package org.apache.usergrid.scenarios
 
+import java.nio.charset.StandardCharsets
+
 import io.gatling.core.Predef._
 import io.gatling.core.feeder.RecordSeqFeederBuilder
 import io.gatling.http.Predef._
+import io.gatling.http.response.ResponseWrapper
+import io.gatling.http.response.StringResponseBody
 import org.apache.usergrid.datagenerators.FeederGenerator
 import org.apache.usergrid.enums.{CsvFeedPatternType, EndConditionType, 
AuthType}
 import org.apache.usergrid.helpers.Extractors._
@@ -216,6 +220,19 @@ object EntityCollectionScenarios {
         .headers(Headers.authToken)
         .headers(Headers.usergridRegionHeaders)
         .body(StringBody("""${entity}"""))
+        .transformResponse {
+          case response if response.isReceived =>
+            new ResponseWrapper(response) {
+              override val body = {
+                val contentType = 
response.header("content-type").getOrElse("").toLowerCase
+                if (contentType.contains("json")) {
+                  StringResponseBody(response.body.string, response.charset)
+                } else {
+                  StringResponseBody("{}", StandardCharsets.UTF_8)
+                }
+              }
+          }
+        }
         // 200 for success, 400 if already exists
         .check(status.saveAs(SessionVarStatus), 
extractEntityUuid(SessionVarUuid), extractEntityModified(SessionVarModified)))
         .exec(session => {

Reply via email to