Browse Source

verify Added in json validation attempt

Mike Smith 11 years ago
parent
commit
8cec97c5a8
2 changed files with 17 additions and 19 deletions
  1. 0 11
      toolset/benchmark/JSONValidator.py
  2. 17 8
      toolset/benchmark/framework_test.py

+ 0 - 11
toolset/benchmark/JSONValidator.py

@@ -2,14 +2,3 @@ import json
 
 class JSONValidator():
 
-  def validate(self, jsonString):
-    obj = json.loads(jsonString)
-
-    if not obj
-      return false
-    else if not obj.message
-      return false
-    else if not obj.message.lower() == "hello, world!"
-      return false
-
-    return true

+ 17 - 8
toolset/benchmark/framework_test.py

@@ -109,6 +109,16 @@ class FrameworkTest:
   ##########################################################################################
   # Public Methods
   ##########################################################################################
+  def validateJson(self, jsonString):
+    obj = json.loads(jsonString)
+
+    if not obj
+      return false
+    else if not obj.message
+      return false
+    else if not obj.message.lower() == "hello, world!"
+      return false
+  return true
 
   ############################################################
   # start(benchmarker)
@@ -144,12 +154,10 @@ class FrameworkTest:
       out.flush()
       url = self.benchmarker.generate_url(self.json_url, self.port)
       output = self.__curl_url(url, self.JSON, out, err)
-      print "\nTest Output Start"
-      print "\n"
-      print output
-      print "\n"
-      print "Test Output End\n"
-      self.json_url_passed = True
+      if self.validateJson(output):
+        self.json_url_passed = True
+      else:
+        self.json_url_passed = False
     except (AttributeError, subprocess.CalledProcessError) as e:
       self.json_url_passed = False
 
@@ -563,8 +571,9 @@ class FrameworkTest:
     # HTTP output may not end in a newline, so add that here.
     out.write( "\n" )
     out.flush()
-    # We have the response body - return it
-    return output
+    if output:
+      # We have the response body - return it
+      return output[0]
   ##############################################################
   # End __curl_url
   ##############################################################