incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1182439 - /incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java
Date Wed, 12 Oct 2011 15:40:11 GMT
Author: kwright
Date: Wed Oct 12 15:40:10 2011
New Revision: 1182439

URL: http://svn.apache.org/viewvc?rev=1182439&view=rev
Log:
Finish writing the mock wiki service, for tests

Modified:
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java

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=1182439&r1=1182438&r2=1182439&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 15:40:10 2011
@@ -53,17 +53,33 @@ public class MockWikiService
     server.stop();
   }
 
-  public void setResources(Map<String,String> listResources,
+  public void setResources(Map<String,String> checkResources,
+    Map<String,String> listResources,
     Map<String,String> timestampQueryResources,
     Map<String,String> docInfoQueryResources)
   {
-    servlet.setResources(listResources,timestampQueryResources,docInfoQueryResources);
+    servlet.setResources(checkResources,listResources,timestampQueryResources,docInfoQueryResources);
+  }
+  
+  protected static String sortStuff(String input)
+  {
+    String[] ids = input.split("\\|");
+    java.util.Arrays.sort(ids);
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0 ; i < ids.length ; i++)
+    {
+      if (i == 0)
+        sb.append("|");
+      sb.append(ids[i]);
+    }
+    return sb.toString();
   }
   
   public static class WikiAPIServlet extends HttpServlet
   {
     protected Class theResourceClass;
     
+    protected Map<String,String> checkResources = null;
     protected Map<String,String> listResources = null;
     protected Map<String,String> timestampQueryResources = null;
     protected Map<String,String> docInfoQueryResources = null;
@@ -73,10 +89,12 @@ public class MockWikiService
       this.theResourceClass = theResourceClass;
     }
     
-    public void setResources(Map<String,String> listResources,
+    public void setResources(Map<String,String> checkResources,
+      Map<String,String> listResources,
       Map<String,String> timestampQueryResources,
       Map<String,String> docInfoQueryResources)
     {
+      this.checkResources = checkResources;
       this.listResources = listResources;
       this.timestampQueryResources = timestampQueryResources;
       this.docInfoQueryResources = docInfoQueryResources;
@@ -105,15 +123,46 @@ public class MockWikiService
         String pageIds = req.getParameter("pageids");
         String rvprop = req.getParameter("rvprop");
         String inprop = req.getParameter("inprop");
-        // MHL
+        if (rvprop != null && rvprop.equals("timestamp"))
+        {
+          // Version query
+          if (prop == null || !prop.equals("revisions"))
+            throw new IOException("prop parameter incorrect for version query: "+prop);
+          if (pageIds == null)
+            throw new IOException("missing pageids parameter, required for version query");
+          // Sort the pageIds
+          pageIds = sortStuff(pageIds);
+          resourceName = timestampQueryResources.get(pageIds);
+        }
+	else if (rvprop != null && rvprop.equals("user|comment|content"))
+	{
+          // Doc info query
+          if (prop == null || !prop.equals("revisions"))
+            throw new IOException("prop parameter incorrect for docinfo query: "+prop);
+          if (pageIds == null)
+            throw new IOException("missing pageids parameter, required for docinfo query");
+          if (pageIds.indexOf("|") != -1)
+            throw new IOException("cannot do more than one docinfo request at once");
+          resourceName = docInfoQueryResources.get(pageIds);
+        }
+        else
+          throw new IOException("rvprop parameter missing or incorrect: "+rvprop);
       }
       else if (list != null)
       {
         if (!list.equals("allpages"))
           throw new IOException("List parameter incorrect: "+list);
         String apfrom = req.getParameter("apfrom");
+        if (apfrom == null)
+          apfrom = "";
         String aplimit = req.getParameter("aplimit");
-        // MHL
+        // Only two legal values for aplimit here: 1 and 500.
+        if (aplimit.equals("1"))
+          resourceName = checkResources.get(apfrom);
+        else if (aplimit.equals("500"))
+          resourceName = listResources.get(apfrom);
+        else
+          throw new IOException("aplimit parameter incorrect: "+aplimit);
       }
 
       // Select the resource



Mime
View raw message