incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1182298 - in /incubator/lcf/branches/CONNECTORS-256: ./ connectors/opensearchserver/ tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/ tests/wiki/src/test/resources/ tests/wiki/src/test/resources/org/ tests/wiki/src/test/resources...
Date Wed, 12 Oct 2011 10:16:25 GMT
Author: kwright
Date: Wed Oct 12 10:16:25 2011
New Revision: 1182298

URL: http://svn.apache.org/viewvc?rev=1182298&view=rev
Log:
More testing infrastructure

Added:
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/resources/
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/resources/org/
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/resources/org/apache/
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/resources/org/apache/manifoldcf/
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/resources/org/apache/manifoldcf/wiki_tests/
Modified:
    incubator/lcf/branches/CONNECTORS-256/build.xml
    incubator/lcf/branches/CONNECTORS-256/connectors/opensearchserver/pom.xml
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java

Modified: incubator/lcf/branches/CONNECTORS-256/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/build.xml?rev=1182298&r1=1182297&r2=1182298&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-256/build.xml Wed Oct 12 10:16:25 2011
@@ -2276,6 +2276,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-tests/classes"/>
+                <pathelement location="tests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
@@ -2309,6 +2310,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-loadtests/classes"/>
+                <pathelement location="loadtests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
@@ -2553,6 +2555,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-tests/classes"/>
+                <pathelement location="tests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
@@ -2586,6 +2589,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-loadtests/classes"/>
+                <pathelement location="loadtests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
@@ -2762,6 +2766,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-tests/classes"/>
+                <pathelement location="tests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 
@@ -2795,6 +2800,7 @@
 		<include name="*.jar"/>
 	      </fileset>
                 <pathelement location="build/wiki-loadtests/classes"/>
+                <pathelement location="loadtests/wiki/src/test/resources"/>
             </classpath>
             <formatter type="brief" usefile="false"/>
 

Modified: incubator/lcf/branches/CONNECTORS-256/connectors/opensearchserver/pom.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/opensearchserver/pom.xml?rev=1182298&r1=1182297&r2=1182298&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/opensearchserver/pom.xml (original)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/opensearchserver/pom.xml Wed Oct 12 10:16:25
2011
@@ -40,6 +40,11 @@
   <build>
     <sourceDirectory>${basedir}/connector/src/main/java</sourceDirectory>
     <testSourceDirectory>${basedir}/connector/src/test/java</testSourceDirectory>
+    <resources>
+      <resource>
+        <directory>${basedir}/connector/src/main/resources</directory>
+      </resource>
+    </resources>
   </build>
 
   <dependencies>

Modified: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java?rev=1182298&r1=1182297&r2=1182298&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
(original)
+++ incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
Wed Oct 12 10:16:25 2011
@@ -33,12 +33,14 @@ import java.util.*;
 public class MockWikiService
 {
   Server server;
+  WikiAPIServlet servlet;
     
-  public MockWikiService()
+  public MockWikiService(Class theResourceClass)
   {
     server = new Server(8089);
+    servlet = new WikiAPIServlet(theResourceClass);
     Context asContext = new Context(server,"/w",Context.SESSIONS);
-    asContext.addServlet(new ServletHolder(new WikiAPIServlet()), "/api.php");
+    asContext.addServlet(new ServletHolder(servlet), "/api.php");
   }
     
   public void start() throws Exception
@@ -51,12 +53,41 @@ public class MockWikiService
     server.stop();
   }
 
+  public void setResources(Map<String,String> listResources,
+    Map<String,String> timestampQueryResources,
+    Map<String,String> docInfoQueryResources)
+  {
+    servlet.setResources(listResources,timestampQueryResources,docInfoQueryResources);
+  }
+  
   public static class WikiAPIServlet extends HttpServlet
   {
+    protected Class theResourceClass;
+    
+    protected Map<String,String> listResources = null;
+    protected Map<String,String> timestampQueryResources = null;
+    protected Map<String,String> docInfoQueryResources = null;
+    
+    public WikiAPIServlet(Class theResourceClass)
+    {
+      this.theResourceClass = theResourceClass;
+    }
+    
+    public void setResources(Map<String,String> listResources,
+      Map<String,String> timestampQueryResources,
+      Map<String,String> docInfoQueryResources)
+    {
+      this.listResources = listResources;
+      this.timestampQueryResources = timestampQueryResources;
+      this.docInfoQueryResources = docInfoQueryResources;
+    }
+    
     @Override
     public void service(HttpServletRequest req, HttpServletResponse res)
       throws IOException
     {
+      String resourceName = null;
+      
       String format = req.getParameter("format");
       if (!format.equals("xml"))
         throw new IOException("Format parameter incorrect: "+format);
@@ -84,16 +115,37 @@ public class MockWikiService
         String aplimit = req.getParameter("aplimit");
         // MHL
       }
-        
-      // MHL
-      String user = req.getParameter("username");
+
+      // Select the resource
+      if (resourceName == null)
+        throw new IOException("Could not find a matching resource for the parameters");
+      
       res.setStatus(HttpServletResponse.SC_OK);
-      if(user.equals("user1") || user.equals("user2") || user.equals("user3"))
-        res.getWriter().printf("TOKEN:token1\n");
-      if(user.equals("user2") || user.equals("user3"))
-        res.getWriter().printf("TOKEN:token2\n");
-      if(user.equals("user3"))
-        res.getWriter().printf("TOKEN:token3\n");
+      
+      OutputStream os = res.getOutputStream();
+      try
+      {
+        InputStream is = theResourceClass.getResourceAsStream(resourceName);
+        try
+        {
+          byte[] bytes = new byte[65536];
+          while (true)
+          {
+            int amt = is.read(bytes,0,bytes.length);
+            if (amt == -1)
+              break;
+            os.write(bytes,0,amt);
+          }
+        }
+        finally
+        {
+          is.close();
+        }
+      }
+      finally
+      {
+        os.close();
+      }
     }
   }
 }



Mime
View raw message