You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/03/30 22:28:15 UTC

svn commit: r1462854 - in /jena/trunk/jena-arq/src: main/java/org/apache/jena/riot/web/HttpOp.java main/java/org/apache/jena/riot/web/HttpResponseLib.java test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java

Author: andy
Date: Sat Mar 30 21:28:15 2013
New Revision: 1462854

URL: http://svn.apache.org/r1462854
Log:
Fix warnings on javadoc in build and Eclipse-detected warnings on casts and imports.
Isolate state of global context changes for TestService (just in case).

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpResponseLib.java
    jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java?rev=1462854&r1=1462853&r2=1462854&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java Sat Mar 30 21:28:15 2013
@@ -39,7 +39,6 @@ import org.apache.http.StatusLine ;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient ;
 import org.apache.http.client.entity.UrlEncodedFormEntity ;
 import org.apache.http.client.methods.HttpGet ;
 import org.apache.http.client.methods.HttpPost ;
@@ -274,7 +273,7 @@ public class HttpOp
                              
     /** POST with response body.
      * <p>The content for the POST body comes from the HttpEntity.
-     * <p>The response is handled by the handler map, as per {@link #execHttpGet(String, String, Map)}
+     * <p>The response is handled by the handler map, as per {@link #execHttpGet(String, String, Map, HttpContext)}
      * <p>Additional headers e.g. for authentication can be injected through an {@link HttpContext}
      */
     public static void execHttpPost(String url, HttpEntity provider, String acceptType,

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpResponseLib.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpResponseLib.java?rev=1462854&r1=1462853&r2=1462854&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpResponseLib.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/web/HttpResponseLib.java Sat Mar 30 21:28:15 2013
@@ -25,6 +25,7 @@ import java.util.Map ;
 
 import org.apache.http.HttpEntity ;
 import org.apache.http.HttpResponse ;
+import org.apache.http.protocol.HttpContext ;
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.web.MediaType ;
 import org.apache.jena.riot.RiotReader ;
@@ -40,7 +41,7 @@ import com.hp.hpl.jena.sparql.graph.Grap
 import com.hp.hpl.jena.sparql.resultset.ResultsFormat ;
 
 /** A collection of handlers for response handling.
- * @see HttpOp#execHttpGet(String, String, java.util.Map)
+ * @see HttpOp#execHttpGet(String, String, java.util.Map, HttpContext)
  * @see HttpOp#execHttpPost(String, String, ContentProducer, String, java.util.Map)
  * 
  */

Modified: jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java?rev=1462854&r1=1462853&r2=1462854&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java (original)
+++ jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/engine/http/TestService.java Sat Mar 30 21:28:15 2013
@@ -18,31 +18,38 @@
 
 package com.hp.hpl.jena.sparql.engine.http;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.HashMap ;
+import java.util.Map ;
 
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.NodeFactory;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.query.ARQ;
-import com.hp.hpl.jena.query.Query;
-import com.hp.hpl.jena.query.QueryExecutionFactory;
-import com.hp.hpl.jena.query.QueryFactory;
-import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
-import com.hp.hpl.jena.sparql.algebra.op.OpService;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.sparql.modify.UpdateProcessRemoteBase;
-import com.hp.hpl.jena.sparql.util.Context;
-import com.hp.hpl.jena.update.UpdateExecutionFactory;
-import com.hp.hpl.jena.update.UpdateFactory;
-import com.hp.hpl.jena.update.UpdateRequest;
+import org.junit.AfterClass ;
+import org.junit.Assert ;
+import org.junit.BeforeClass ;
+import org.junit.Test ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.NodeFactory ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.query.ARQ ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryExecutionFactory ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.sparql.algebra.op.OpBGP ;
+import com.hp.hpl.jena.sparql.algebra.op.OpService ;
+import com.hp.hpl.jena.sparql.core.BasicPattern ;
+import com.hp.hpl.jena.sparql.modify.UpdateProcessRemoteBase ;
+import com.hp.hpl.jena.sparql.util.Context ;
+import com.hp.hpl.jena.update.UpdateExecutionFactory ;
+import com.hp.hpl.jena.update.UpdateFactory ;
+import com.hp.hpl.jena.update.UpdateRequest ;
 
 public class TestService {
     private static final String SERVICE = "http://example.com:40000";
 
+    private static Object value ;
+    
+    @BeforeClass public static void recordContextState() { value = ARQ.getContext().get(Service.serviceContext) ; }
+    @AfterClass public static void restoreContextState() { ARQ.getContext().set(Service.serviceContext, value) ; }
+    
     @Test
     public void testNumericTimeout() {
         BasicPattern basicPattern = new BasicPattern();
@@ -129,7 +136,7 @@ public class TestService {
         }
 
         Query q = QueryFactory.create("ASK { }");
-        QueryEngineHTTP engine = (QueryEngineHTTP) QueryExecutionFactory.createServiceRequest(SERVICE, q);
+        QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
         Assert.assertNotNull(engine);
 
         // Check that no settings were changed
@@ -153,13 +160,13 @@ public class TestService {
         if (serviceContextMap.get(SERVICE) == null) {
             serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
         }
-        Context serviceContext = (Context) serviceContextMap.get(SERVICE);
+        Context serviceContext = serviceContextMap.get(SERVICE);
         try {
             serviceContext.put(Service.queryAuthUser, "user");
             serviceContext.put(Service.queryAuthPwd, "password");
 
             Query q = QueryFactory.create("ASK { }");
-            QueryEngineHTTP engine = (QueryEngineHTTP) QueryExecutionFactory.createServiceRequest(SERVICE, q);
+            QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
             Assert.assertNotNull(engine);
 
             // Check that no settings were changed
@@ -187,12 +194,12 @@ public class TestService {
         if (serviceContextMap.get(SERVICE) == null) {
             serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
         }
-        Context serviceContext = (Context) serviceContextMap.get(SERVICE);
+        Context serviceContext = serviceContextMap.get(SERVICE);
         try {
             serviceContext.put(Service.queryTimeout, "10");
 
             Query q = QueryFactory.create("ASK { }");
-            QueryEngineHTTP engine = (QueryEngineHTTP) QueryExecutionFactory.createServiceRequest(SERVICE, q);
+            QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
             Assert.assertNotNull(engine);
 
             // Check that no settings were changed
@@ -218,12 +225,12 @@ public class TestService {
         if (serviceContextMap.get(SERVICE) == null) {
             serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
         }
-        Context serviceContext = (Context) serviceContextMap.get(SERVICE);
+        Context serviceContext = serviceContextMap.get(SERVICE);
         try {
             serviceContext.put(Service.queryTimeout, "10,20");
 
             Query q = QueryFactory.create("ASK { }");
-            QueryEngineHTTP engine = (QueryEngineHTTP) QueryExecutionFactory.createServiceRequest(SERVICE, q);
+            QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
             Assert.assertNotNull(engine);
 
             // Check that no settings were changed
@@ -249,13 +256,13 @@ public class TestService {
         if (serviceContextMap.get(SERVICE) == null) {
             serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
         }
-        Context serviceContext = (Context) serviceContextMap.get(SERVICE);
+        Context serviceContext = serviceContextMap.get(SERVICE);
         try {
             serviceContext.put(Service.queryGzip, false);
             serviceContext.put(Service.queryDeflate, false);
 
             Query q = QueryFactory.create("ASK { }");
-            QueryEngineHTTP engine = (QueryEngineHTTP) QueryExecutionFactory.createServiceRequest(SERVICE, q);
+            QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
             Assert.assertNotNull(engine);
 
             // Check that no settings were changed
@@ -287,10 +294,10 @@ public class TestService {
         Assert.assertFalse(engine.isUsingAuthentication());
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void update_service_context_application_02() {
         // This test requires no service context to be set
-        @SuppressWarnings("unchecked")
         Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
         if (serviceContextMap == null) {
             ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>());
@@ -299,7 +306,7 @@ public class TestService {
         if (serviceContextMap.get(SERVICE) == null) {
             serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
         }
-        Context serviceContext = (Context) serviceContextMap.get(SERVICE);
+        Context serviceContext = serviceContextMap.get(SERVICE);
         try {
             serviceContext.put(Service.queryAuthUser, "user");
             serviceContext.put(Service.queryAuthPwd, "password");