manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1407942 - in /manifoldcf/branches/CONNECTORS-120: framework/pull-agent/ framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ tests/alfresco/ tests...
Date Sun, 11 Nov 2012 11:41:02 GMT
Author: kwright
Date: Sun Nov 11 11:41:00 2012
New Revision: 1407942

URL: http://svn.apache.org/viewvc?rev=1407942&view=rev
Log:
Make framework tests depend only on httpcomponents

Modified:
    manifoldcf/branches/CONNECTORS-120/framework/pull-agent/pom.xml
    manifoldcf/branches/CONNECTORS-120/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
    manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java
    manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java
    manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
    manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
    manifoldcf/branches/CONNECTORS-120/tests/alfresco/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/cmis/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/elasticsearch/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/filesystem/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/rss/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/sharepoint/pom.xml
    manifoldcf/branches/CONNECTORS-120/tests/wiki/pom.xml

Modified: manifoldcf/branches/CONNECTORS-120/framework/pull-agent/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/pull-agent/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/pull-agent/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/framework/pull-agent/pom.xml Sun Nov 11 11:41:00 2012
@@ -134,9 +134,9 @@
     </dependency>
 
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: manifoldcf/branches/CONNECTORS-120/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
(original)
+++ manifoldcf/branches/CONNECTORS-120/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
Sun Nov 11 11:41:00 2012
@@ -33,8 +33,25 @@ import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.apache.http.client.HttpClient;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpEntity;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.util.EntityUtils;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.ContentType;
+
 
 /** Tests that run the "agents daemon" should be derived from this */
 public class ManifoldCFInstance
@@ -253,7 +270,46 @@ public class ManifoldCFInstance
   {
     return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
   }
-  
+
+  public static String convertToString(HttpResponse httpResponse)
+    throws IOException
+  {
+    HttpEntity entity = httpResponse.getEntity();
+    if (entity != null)
+    {
+      InputStream is = entity.getContent();
+      try
+      {
+        String charSet = EntityUtils.getContentCharSet(entity);
+        if (charSet == null)
+          charSet = "utf-8";
+        char[] buffer = new char[65536];
+        Reader r = new InputStreamReader(is,charSet);
+        Writer w = new StringWriter();
+        try
+        {
+          while (true)
+          {
+            int amt = r.read(buffer);
+            if (amt == -1)
+              break;
+            w.write(buffer,0,amt);
+          }
+        }
+        finally
+        {
+          w.flush();
+        }
+        return w.toString();
+      }
+      finally
+      {
+        is.close();
+      }
+    }
+    return "";
+  }
+
   /** Perform an json API GET operation.
   *@param apiURL is the operation.
   *@param expectedResponse is the expected response code.
@@ -262,15 +318,21 @@ public class ManifoldCFInstance
   public String performAPIGetOperation(String apiURL, int expectedResponse)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    GetMethod method = new GetMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpGet method = new HttpGet(apiURL);
+    try
+    {
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(responseCode)+": "+responseString);
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API DELETE operation.
@@ -281,15 +343,22 @@ public class ManifoldCFInstance
   public String performAPIDeleteOperation(String apiURL, int expectedResponse)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    DeleteMethod method = new DeleteMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpDelete method = new HttpDelete(apiURL);
+    try
+    {
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API PUT operation.
@@ -301,17 +370,23 @@ public class ManifoldCFInstance
   public String performAPIPutOperation(String apiURL, int expectedResponse, String input)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    PutMethod method = new PutMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpPut method = new HttpPut(apiURL);
+    try
+    {
+      method.setEntity(new StringEntity(input,ContentType.create("text/plain","UTF-8")));
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform an json API POST operation.
@@ -323,17 +398,23 @@ public class ManifoldCFInstance
   public String performAPIPostOperation(String apiURL, int expectedResponse, String input)
     throws Exception
   {
-    HttpClient client = new HttpClient();
-    PostMethod method = new PostMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
+    DefaultHttpClient client = new DefaultHttpClient();
+    HttpPost method = new HttpPost(apiURL);
+    try
+    {
+      method.setEntity(new StringEntity(input,ContentType.create("text/plain","UTF-8")));
+      HttpResponse response = client.execute(method);
+      int responseCode = response.getStatusLine().getStatusCode();
+      String responseString = convertToString(response);
+      if (responseCode != expectedResponse)
+        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+",
saw "+Integer.toString(responseCode)+": "+responseString);
+      // We presume that the data is utf-8, since that's what the API uses throughout.
+      return responseString;
+    }
+    finally
+    {
+      method.abort();
+    }
   }
 
   /** Perform a json GET API operation, using Configuration structures to represent the json.
 This is for testing convenience,

Modified: manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java
(original)
+++ manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/DELETECommand.java
Sun Nov 11 11:41:00 2012
@@ -31,7 +31,6 @@ import org.apache.http.params.CoreConnec
 import org.apache.http.util.EntityUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import java.io.*;
 
 /** DELETE command.  This performs a REST-style DELETE operation, designed to work

Modified: manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java
(original)
+++ manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/GETCommand.java
Sun Nov 11 11:41:00 2012
@@ -31,7 +31,6 @@ import org.apache.http.params.CoreConnec
 import org.apache.http.util.EntityUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import java.io.*;
 
 /** GET command.  This performs a REST-style GET operation, designed to work

Modified: manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
(original)
+++ manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
Sun Nov 11 11:41:00 2012
@@ -33,7 +33,6 @@ import org.apache.http.params.CoreConnec
 import org.apache.http.util.EntityUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import java.io.*;
 
 /** POST command.  This performs a REST-style POST operation, designed to work

Modified: manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
(original)
+++ manifoldcf/branches/CONNECTORS-120/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
Sun Nov 11 11:41:00 2012
@@ -33,7 +33,6 @@ import org.apache.http.params.CoreConnec
 import org.apache.http.util.EntityUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import java.io.*;
 
 /** PUT command.  This performs a REST-style PUT operation, designed to work

Modified: manifoldcf/branches/CONNECTORS-120/tests/alfresco/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/alfresco/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/alfresco/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/alfresco/pom.xml Sun Nov 11 11:41:00 2012
@@ -325,6 +325,11 @@
       <version>${commons-httpclient.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>${commons-logging.version}</version>

Modified: manifoldcf/branches/CONNECTORS-120/tests/cmis/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/cmis/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/cmis/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/cmis/pom.xml Sun Nov 11 11:41:00 2012
@@ -314,6 +314,11 @@
       <version>${commons-httpclient.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>${commons-logging.version}</version>

Modified: manifoldcf/branches/CONNECTORS-120/tests/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/elasticsearch/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/elasticsearch/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/elasticsearch/pom.xml Sun Nov 11 11:41:00 2012
@@ -329,6 +329,11 @@
       <version>${commons-httpclient.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>${commons-logging.version}</version>

Modified: manifoldcf/branches/CONNECTORS-120/tests/filesystem/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/filesystem/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/filesystem/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/filesystem/pom.xml Sun Nov 11 11:41:00 2012
@@ -280,9 +280,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/branches/CONNECTORS-120/tests/rss/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/rss/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/rss/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/rss/pom.xml Sun Nov 11 11:41:00 2012
@@ -274,9 +274,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/branches/CONNECTORS-120/tests/sharepoint/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/sharepoint/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/sharepoint/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/sharepoint/pom.xml Sun Nov 11 11:41:00 2012
@@ -92,9 +92,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>${commons-httpclient.version}</version>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-logging</groupId>

Modified: manifoldcf/branches/CONNECTORS-120/tests/wiki/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/tests/wiki/pom.xml?rev=1407942&r1=1407941&r2=1407942&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/tests/wiki/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-120/tests/wiki/pom.xml Sun Nov 11 11:41:00 2012
@@ -285,6 +285,11 @@
       <version>${commons-httpclient.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>${commons-logging.version}</version>



Mime
View raw message