incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1227925 - in /incubator/lcf/trunk: ./ framework/core/src/test/java/org/apache/manifoldcf/core/tests/ tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/
Date Fri, 06 Jan 2012 01:25:27 GMT
Author: kwright
Date: Fri Jan  6 01:25:27 2012
New Revision: 1227925

URL: http://svn.apache.org/viewvc?rev=1227925&view=rev
Log:
First cut of wiki UI test.  Part of CONNECTORS-339.

Added:
    incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
  (with props)
Modified:
    incubator/lcf/trunk/build.xml
    incubator/lcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
    incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseUIDerby.java
    incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java

Modified: incubator/lcf/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/build.xml?rev=1227925&r1=1227924&r2=1227925&view=diff
==============================================================================
--- incubator/lcf/trunk/build.xml (original)
+++ incubator/lcf/trunk/build.xml Fri Jan  6 01:25:27 2012
@@ -2627,11 +2627,12 @@
 	      <fileset dir="connectors/nulloutput/build/test-jar">
 		<include name="*.jar"/>
 	      </fileset>
-                <pathelement location="build/webcrawler-tests/classes"/>
+                <pathelement location="build/wiki-tests/classes"/>
+                <pathelement location="tests/wiki/src/test/resource"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
-            <!--test name="org.apache.manifoldcf.webcrawler_tests.NavigationDerbyUI" todir="test-derby-output/wiki"/
-->
+            <test name="org.apache.manifoldcf.wiki_tests.NavigationDerbyUI" todir="test-derby-output/wiki"/>
             <!-- MHL -->
         </junit>
     </target>

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=1227925&r1=1227924&r2=1227925&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
Fri Jan  6 01:25:27 2012
@@ -372,6 +372,14 @@ public class HTMLTester
       return new StringDescription(varName);
     }
 
+    /** If the match is not found, the test will error out.
+    */
+    public void checkMatch(StringDescription regularExpression)
+      throws Exception
+    {
+      emitLine(windowVar+".find_match("+regularExpression.getVarName()+")");
+    }
+    
     /** If the match is found, the test will error out.
     */
     public void checkNoMatch(StringDescription regularExpression)

Modified: incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseUIDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseUIDerby.java?rev=1227925&r1=1227924&r2=1227925&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseUIDerby.java
(original)
+++ incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseUIDerby.java
Fri Jan  6 01:25:27 2012
@@ -58,7 +58,7 @@ public class BaseUIDerby extends org.apa
   public void createWikiService()
     throws Exception
   {
-    wikiService = new MockWikiService(getClass());
+    wikiService = new MockWikiService(BaseUIDerby.class);
     wikiService.start();
   }
   

Modified: incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java?rev=1227925&r1=1227924&r2=1227925&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
(original)
+++ incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
Fri Jan  6 01:25:27 2012
@@ -200,6 +200,8 @@ public class MockWikiService
       try
       {
         InputStream is = theResourceClass.getResourceAsStream(resourceName);
+        if (is == null)
+          throw new IOException("Can't locate resource '"+resourceName+"' in class '"+theResourceClass.getName()+"'");
         try
         {
           byte[] bytes = new byte[65536];

Added: incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java?rev=1227925&view=auto
==============================================================================
--- incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
(added)
+++ incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
Fri Jan  6 01:25:27 2012
@@ -0,0 +1,249 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.wiki_tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+import org.apache.manifoldcf.core.tests.HTMLTester;
+
+/** Basic UI navigation tests */
+public class NavigationDerbyUI extends BaseUIDerby
+{
+
+  protected static Map<String,String> initialCheckResources;
+  protected static Map<String,String> initialListResources;
+  protected static Map<String,String> initialTimestampQueryResources;
+  protected static Map<String,String> initialURLQueryResources;
+  protected static Map<String,String> initialDocInfoQueryResources;
+  
+  static
+  {
+    initialCheckResources = new HashMap<String,String>();
+    initialCheckResources.put("","list_one.xml");
+    
+    initialListResources = new HashMap<String,String>();
+    
+    initialTimestampQueryResources = new HashMap<String,String>();
+    
+    initialURLQueryResources = new HashMap<String,String>();
+    
+    initialDocInfoQueryResources = new HashMap<String,String>();
+  }
+
+  @Test
+  public void createConnectionsAndJob()
+    throws Exception
+  {
+    // Initialize the mock service
+    wikiService.setResources(initialCheckResources,
+      initialListResources,
+      initialTimestampQueryResources,
+      initialURLQueryResources,
+      initialDocInfoQueryResources);
+
+    testerInstance.newTest(Locale.US);
+    
+    HTMLTester.Window window;
+    HTMLTester.Link link;
+    HTMLTester.Form form;
+    HTMLTester.Textarea textarea;
+    HTMLTester.Selectbox selectbox;
+    HTMLTester.Button button;
+    HTMLTester.Radiobutton radiobutton;
+    HTMLTester.Checkbox checkbox;
+    HTMLTester.Loop loop;
+    
+    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"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Add an output connection"));
+    link.click();
+    // Fill in a name
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editconnection"));
+    textarea = form.findTextarea(testerInstance.createStringDescription("connname"));
+    textarea.setValue(testerInstance.createStringDescription("MyOutputConnection"));
+    link = window.findLink(testerInstance.createStringDescription("Type tab"));
+    link.click();
+    // Select a type
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editconnection"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("classname"));
+    selectbox.selectValue(testerInstance.createStringDescription("org.apache.manifoldcf.agents.output.nullconnector.NullConnector"));
+    button = window.findButton(testerInstance.createStringDescription("Continue to next page"));
+    button.click();
+    // Visit the Throttling tab
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Throttling tab"));
+    link.click();
+    // Go back to the Name tab
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Name tab"));
+    link.click();
+    // Now save the connection.
+    window = testerInstance.findWindow(null);
+    button = window.findButton(testerInstance.createStringDescription("Save this output connection"));
+    button.click();
+    
+    // Define a repository connection via the UI
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("List repository connections"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Add a connection"));
+    link.click();
+    // Fill in a name
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editconnection"));
+    textarea = form.findTextarea(testerInstance.createStringDescription("connname"));
+    textarea.setValue(testerInstance.createStringDescription("MyRepositoryConnection"));
+    link = window.findLink(testerInstance.createStringDescription("Type tab"));
+    link.click();
+    // Select a type
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editconnection"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("classname"));
+    selectbox.selectValue(testerInstance.createStringDescription("org.apache.manifoldcf.crawler.connectors.wiki.WikiConnector"));
+    button = window.findButton(testerInstance.createStringDescription("Continue to next page"));
+    button.click();
+    // Visit the Throttling tab
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Throttling tab"));
+    link.click();
+    // Visit the Server tab
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Server tab"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editconnection"));
+    // Fill in the server name
+    textarea = form.findTextarea(testerInstance.createStringDescription("servername"));
+    textarea.setValue(testerInstance.createStringDescription("localhost"));
+    // Fill in the port
+    textarea = form.findTextarea(testerInstance.createStringDescription("serverport"));
+    textarea.setValue(testerInstance.createStringDescription("8089"));
+    // Go back to the Name tab
+    link = window.findLink(testerInstance.createStringDescription("Name tab"));
+    link.click();
+    // Now save the connection.
+    window = testerInstance.findWindow(null);
+    button = window.findButton(testerInstance.createStringDescription("Save this connection"));
+    button.click();
+    // Look for "connection working"
+    window = testerInstance.findWindow(null);
+    window.checkMatch(testerInstance.createStringDescription("Connection working"));
+    
+    // Create a job
+    link = window.findLink(testerInstance.createStringDescription("List jobs"));
+    link.click();
+    // Add a job
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Add a job"));
+    link.click();
+    // Fill in a name
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editjob"));
+    textarea = form.findTextarea(testerInstance.createStringDescription("description"));
+    textarea.setValue(testerInstance.createStringDescription("MyJob"));
+    link = window.findLink(testerInstance.createStringDescription("Connection tab"));
+    link.click();
+    // Select the connections
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editjob"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("outputname"));
+    selectbox.selectValue(testerInstance.createStringDescription("MyOutputConnection"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("connectionname"));
+    selectbox.selectValue(testerInstance.createStringDescription("MyRepositoryConnection"));
+    button = window.findButton(testerInstance.createStringDescription("Continue to next screen"));
+    button.click();
+    // Visit all the tabs.  Scheduling tab first
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Scheduling tab"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    form = window.findForm(testerInstance.createStringDescription("editjob"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("dayofweek"));
+    selectbox.selectValue(testerInstance.createStringDescription("0"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("hourofday"));
+    selectbox.selectValue(testerInstance.createStringDescription("1"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("minutesofhour"));
+    selectbox.selectValue(testerInstance.createStringDescription("30"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("monthofyear"));
+    selectbox.selectValue(testerInstance.createStringDescription("11"));
+    selectbox = form.findSelectbox(testerInstance.createStringDescription("dayofmonth"));
+    selectbox.selectValue(testerInstance.createStringDescription("none"));
+    textarea = form.findTextarea(testerInstance.createStringDescription("duration"));
+    textarea.setValue(testerInstance.createStringDescription("120"));
+    button = window.findButton(testerInstance.createStringDescription("Add new schedule record"));
+    button.click();
+    window = testerInstance.findWindow(null);
+    // MHL for the wiki job tabs
+    
+    // Save the job
+    button = window.findButton(testerInstance.createStringDescription("Save this job"));
+    button.click();
+
+    // Delete the job
+    window = testerInstance.findWindow(null);
+    HTMLTester.StringDescription jobID = window.findMatch(testerInstance.createStringDescription("<!--jobid=(.*?)-->"),0);
+    testerInstance.printValue(jobID);
+    link = window.findLink(testerInstance.createStringDescription("Delete this job"));
+    link.click();
+    
+    // Wait for the job to go away
+    loop = testerInstance.beginLoop(120);
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Manage jobs"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    HTMLTester.StringDescription isJobNotPresent = window.isNotPresent(jobID);
+    testerInstance.printValue(isJobNotPresent);
+    loop.breakWhenTrue(isJobNotPresent);
+    loop.endLoop();
+    
+    // Delete the repository connection
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("List repository connections"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Delete MyRepositoryConnection"));
+    link.click();
+    
+    // Delete the output connection
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("List output connections"));
+    link.click();
+    window = testerInstance.findWindow(null);
+    link = window.findLink(testerInstance.createStringDescription("Delete MyOutputConnection"));
+    link.click();
+    
+    testerInstance.executeTest();
+  }
+  
+}

Propchange: incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/NavigationDerbyUI.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message