incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1225267 - in /incubator/lcf/trunk: framework/core/src/test/java/org/apache/manifoldcf/core/tests/ framework/core/src/test/resource/org/apache/manifoldcf/core/tests/ tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/
Date Wed, 28 Dec 2011 18:40:55 GMT
Author: kwright
Date: Wed Dec 28 18:40:55 2011
New Revision: 1225267

URL: http://svn.apache.org/viewvc?rev=1225267&view=rev
Log:
Add locale support for html tester.  Part of CONNECTORS-339.

Modified:
    incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
    incubator/lcf/trunk/framework/core/src/test/resource/org/apache/manifoldcf/core/tests/VirtualBrowser.py
    incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/NavigationUI.java

Modified: incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java?rev=1225267&r1=1225266&r2=1225267&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
(original)
+++ incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
Wed Dec 28 18:40:55 2011
@@ -115,7 +115,7 @@ public class HTMLTester
   public void TesterTest()
     throws Exception
   {
-    newTest();
+    newTest(Locale.US);
     executeTest();
   }
   
@@ -138,7 +138,7 @@ public class HTMLTester
   
   /** Begin a new test.  Call this when we're ready to start building a new UI test.
   */
-  public void newTest()
+  public void newTest(Locale desiredLocale)
     throws Exception
   {
     currentTestFile = new File("test.py");
@@ -154,7 +154,7 @@ public class HTMLTester
     emitLine("if __name__ == '__main__':");
     currentIndentLevel++;
     emitLine("print 'Starting test'");
-    emitLine(virtualBrowserVarName + " = VirtualBrowser.VirtualBrowser()");
+    emitLine(virtualBrowserVarName + " = VirtualBrowser.VirtualBrowser("+quotePythonString(desiredLocale.toString().replace("_","-"))+")");
   }
   
   /** Execute the test.  The virtual browser will be called and will perform the sequence
of
@@ -205,10 +205,9 @@ public class HTMLTester
   
   /** Open virtual browser window, and send it to a specified URL.
   *@param url is the desired URL.
-  *@param desiredLocale is the desired locale (which the browser will communicated to the
site).
   *@return the window handle.  Use this whenever a window argument is required later.
   */
-  public Window openMainWindow(String url, Locale desiredLocale)
+  public Window openMainWindow(String url)
     throws Exception
   {
     emitLine(virtualBrowserVarName + ".load_main_window(" + quotePythonString(url) + ")");
@@ -618,11 +617,11 @@ public class HTMLTester
         byte[] buffer = new byte[63356];
         while (true)
         {
-          if (abortSignal)
-            break;
           int amt = inputStream.read(buffer);
           if (amt == -1)
           {
+            if (abortSignal)
+              break;
             Thread.yield();
             continue;
           }

Modified: incubator/lcf/trunk/framework/core/src/test/resource/org/apache/manifoldcf/core/tests/VirtualBrowser.py
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/test/resource/org/apache/manifoldcf/core/tests/VirtualBrowser.py?rev=1225267&r1=1225266&r2=1225267&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/test/resource/org/apache/manifoldcf/core/tests/VirtualBrowser.py
(original)
+++ incubator/lcf/trunk/framework/core/src/test/resource/org/apache/manifoldcf/core/tests/VirtualBrowser.py
Wed Dec 28 18:40:55 2011
@@ -963,11 +963,12 @@ class VirtualWindow:
 # alerts/popups
 class VirtualBrowser:
 
-    def __init__( self, username=None, password=None, win_host=None ):
+    def __init__( self, username=None, password=None, win_host=None, language="en-US" ):
         self.window_set = { }
         self.username = username
         self.password = password
         self.win_host = win_host
+        self.language = language
         if win_host == None and username != None:
             # Set up basic auth
             self.urllibopener = urllib2.build_opener( urllib2.HTTPHandler ( ) )
@@ -1063,6 +1064,8 @@ class VirtualBrowser:
     def fetch_data_with_get( self, url ):
         print >> sys.stderr, "Getting url '%s'..." % url
         req = urllib2.Request( url )
+        if self.language != None:
+            req.add_header("Accept-Language", self.language)
         if self.username != None:
             base64string = base64.encodestring('%s:%s' % (self.username, self.password))[:-1]
             req.add_header("Authorization", "Basic %s" % base64string)
@@ -1074,8 +1077,10 @@ class VirtualBrowser:
     # Read a url with post.  Pass the parameters as an array of ( name, value ) tuples.
     def fetch_data_with_post( self, parameters, url ):
         paramstring = urllib.urlencode( parameters, doseq=True )
-        print "Posting url '%s' with parameters '%s'..." % (url, paramstring)
+        print >> sys.stderr, "Posting url '%s' with parameters '%s'..." % (url, paramstring)
         req = urllib2.Request( url, paramstring )
+        if self.language != None:
+            req.add_header("Accept-Language", self.language)
         if self.username != None:
             base64string = base64.encodestring('%s:%s' % (self.username, self.password))[:-1]
             req.add_header("Authorization", "Basic %s" % base64string)
@@ -1090,7 +1095,7 @@ class VirtualBrowser:
         filecount = 0
         if files != None:
             filecount = len(files)
-        print "Multipart posting url '%s' with parameters '%s' and %d files..." % (url, paramstring,
filecount)
+        print >> sys.stderr, "Multipart posting url '%s' with parameters '%s' and %d
files..." % (url, paramstring, filecount)
 
         # Turn URL into protocol, host, and selector
         urlpieces = url.split("://")
@@ -1129,6 +1134,9 @@ class VirtualBrowser:
             # Add cookies by domain
             # MHL
 
+            if self.language != None:
+                h.putheader("Accept-Language", self.language)
+
             # Add basic auth credentials, if needed.
             if self.username != None:
                 base64string = base64.encodestring("%s:%s" % (self.username, self.password))[:-1]

Modified: incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/NavigationUI.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/NavigationUI.java?rev=1225267&r1=1225266&r2=1225267&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/NavigationUI.java
(original)
+++ incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/NavigationUI.java
Wed Dec 28 18:40:55 2011
@@ -37,7 +37,7 @@ public class NavigationUI extends BaseUI
   public void createConnectionsAndJob()
     throws Exception
   {
-    testerInstance.newTest();
+    testerInstance.newTest(Locale.US);
     
     HTMLTester.Window window;
     HTMLTester.Link link;
@@ -46,7 +46,7 @@ public class NavigationUI extends BaseUI
     HTMLTester.Selectbox selectbox;
     HTMLTester.Button button;
     
-    window = testerInstance.openMainWindow("http://localhost:8346/mcf-crawler-ui/index.jsp",Locale.US);
+    window = testerInstance.openMainWindow("http://localhost:8346/mcf-crawler-ui/index.jsp");
     
     // Define an output connection via the UI
     link = window.findLink(testerInstance.createStringDescription("List output connections"));



Mime
View raw message