[jboss-svn-commits] JBL Code SVN: r12216 - labs/jbossforums/branches/tests/main/src.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue May 29 11:26:36 EDT 2007


Author: adamw
Date: 2007-05-29 11:26:36 -0400 (Tue, 29 May 2007)
New Revision: 12216

Modified:
   labs/jbossforums/branches/tests/main/src/create_new_post.py
   labs/jbossforums/branches/tests/main/src/globals.py
   labs/jbossforums/branches/tests/main/src/main.py
Log:
Creating post cntd

Modified: labs/jbossforums/branches/tests/main/src/create_new_post.py
===================================================================
--- labs/jbossforums/branches/tests/main/src/create_new_post.py	2007-05-29 15:18:10 UTC (rev 12215)
+++ labs/jbossforums/branches/tests/main/src/create_new_post.py	2007-05-29 15:26:36 UTC (rev 12216)
@@ -10,6 +10,9 @@
 
 from globals import *
 
+new_topic_id_regexp_string = """notified_post_id=(\d+)"""
+new_topic_id_regexp = re.compile(new_post_id_regexp_string)
+
 create_headers0= \
   ( NVPair('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'), )
 
@@ -120,26 +123,22 @@
 create_request503 = Test(3503, 'GET post.gif').wrap(create_request503)
 
 create_request601 = HTTPRequest(url=url0, headers=create_headers7)
-#TODO
-f = open('/home/adamw/jboss/forums-test/main/src/create_new_post_bis_data_0.dat')
+f = open(dat_files_dir + 'create_new_post_data_0.dat')
 try:
   create_request601_data = f.read()
 finally:
-  f.close()
-create_request601.setDataFromFile('/home/adamw/jboss/forums-test/main/src/create_new_post_bis_data_0.dat')  
+  f.close() 
 create_request601 = Test(3601, 'POST JBossForumsWindow').wrap(create_request601)
 
 create_request602 = HTTPRequest(url=url0, headers=create_headers7)
 create_request602 = Test(3602, 'GET JBossForumsWindow').wrap(create_request602)
 
 create_request701 = HTTPRequest(url=url0, headers=create_headers8)
-#TODO
-f = open('/home/adamw/jboss/forums-test/main/src/create_new_post_bis_data_1.dat')
+f = open(dat_files_dir + 'create_new_post_data_1.dat')
 try:
   create_request701_data = f.read()
 finally:
   f.close()
-create_request701.setDataFromFile('/home/adamw/jboss/forums-test/main/src/create_new_post_bis_data_1.dat')  
 create_request701 = Test(3701, 'POST JBossForumsWindow').wrap(create_request701)
 
 create_request702 = HTTPRequest(url=url0, headers=create_headers8)
@@ -284,17 +283,21 @@
       self.transform_data(create_request701_data, forum_id),
       ( NVPair('Content-Type', 'multipart/form-data; boundary=---------------------------138154116718923521241857332179'), ))
     
-    for header in result.listHeaders():
-        print header + ": " + result.getHeader(header)
+    topic_id_match_object = new_topic_id_regexp.search(result.getHeader("Location"))
+    if topic_id_match_object == None:
+        grinder.logger.output("CREATE_NEW_POST: Cannot find new post id.")
+        grinder.statistics.forCurrentTest.success = 0
+    else:
+        topic_id = post_id_match_object.group(1)
 
     result = create_request702.GET('/portal/auth/portal/default/forums/JBossForumsWindow' +
       '?action=2' +
       '&f=' + forum_id +
       '&notified_watch_type=0' +
-      '&notified_post_id=' + str(0) + #TODO
+      '&notified_post_id=' + topic_id +
       '&v=f')
 
-    return result
+    return topic_id
 
   def page8(self):
     """GET signout (create_requests 801-808)."""
@@ -338,14 +341,16 @@
     self.page6(forum_id)
     
     # Submitting the post
-    self.page7(forum_id)
+    topic_id = self.page7(forum_id)
     
     # Logging out
     self.page8()
+    
+    return topic_id
 
   def __call__(self, forum_id):
     """This method is called for every run performed by the worker thread."""
-    self.all(forum_id)
+    return self.all(forum_id)
 
 def instrumentMethod(test, method_name, c=CreateNewPost):
   """Instrument a method with the given Test."""

Modified: labs/jbossforums/branches/tests/main/src/globals.py
===================================================================
--- labs/jbossforums/branches/tests/main/src/globals.py	2007-05-29 15:18:10 UTC (rev 12215)
+++ labs/jbossforums/branches/tests/main/src/globals.py	2007-05-29 15:26:36 UTC (rev 12216)
@@ -14,4 +14,7 @@
 url0 = 'http://localhost:8080'
 
 # How many times (max.) the "next page" link will be clicked when viewing a post
-next_clicks_range = 1
\ No newline at end of file
+next_clicks_range = 1
+
+# Where the .dat files are stored
+dat_files_dir = "/home/adamw/jboss/forums-test/main/src/"
\ No newline at end of file

Modified: labs/jbossforums/branches/tests/main/src/main.py
===================================================================
--- labs/jbossforums/branches/tests/main/src/main.py	2007-05-29 15:18:10 UTC (rev 12215)
+++ labs/jbossforums/branches/tests/main/src/main.py	2007-05-29 15:26:36 UTC (rev 12216)
@@ -17,9 +17,12 @@
 
 start = time.time()
 
-class TestRunner:
+class TestRunner:        
     def __call__(self):
+        for key in grinder.properties.keySet():
+            print key + " = " + grinder.properties.getProperty(key)
+        
         forum_id = viewMain()
         #topic_id = viewPost(forum_id)
-        createNewPost("2")
+        new_topic_id = createNewPost(forum_id)
         
\ No newline at end of file




More information about the jboss-svn-commits mailing list