Author: andy
Date: Sun Jun 30 16:09:32 2013
New Revision: 1498146
URL: http://svn.apache.org/r1498146
Log:
protocol level tests
Removed:
jena/trunk/jena-arq/src/main/java/org/apache/jena/web/impl/
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/BaseServerTest.java
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/web/DatasetGraphAccessorHTTP.java
jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/ServerTest.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestAuth.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestProtocol.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestQuery.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestUpdate.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetAccessorHTTP.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.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=1498146&r1=1498145&r2=1498146&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 Sun
Jun 30 16:09:32 2013
@@ -96,8 +96,10 @@ public class HttpOp {
// See also:
// Fluent API in HttpClient from v4.2
+
static private Logger log = LoggerFactory.getLogger(HttpOp.class);
+ /** System wide HTTP operation counter for log messages */
static private AtomicLong counter = new AtomicLong(0);
/**
@@ -105,9 +107,12 @@ public class HttpOp {
*/
static private HttpAuthenticator defaultAuthenticator = new
ServiceAuthenticator();
+ /**
+ * "Do nothing" response handler.
+ */
static private HttpResponseHandler nullHandler =
HttpResponseLib.nullResponse ;
- /** Response as a string (UTF-8 assumed) */
+ /** Capture response as a string (UTF-8 assumed) */
public static class CaptureString implements HttpCaptureResponse<String> {
String result ;
@@ -159,10 +164,6 @@ public class HttpOp {
}
//---- HTTP GET
- // -- Handler for results
- // -- TypeInsputStream
- // -- String
-
/**
* Executes a HTTP Get request, handling the response with given handler.
* <p>
@@ -231,7 +232,7 @@ public class HttpOp {
}
/**
- * Executes a HTTP GET and return a typed input stream.
+ * Executes a HTTP GET and return a TypedInputStream.
* The stream must be closed after use.
* <p>
* The acceptHeader string is any legal value for HTTP Accept: field.
@@ -239,7 +240,7 @@ public class HttpOp {
*
* @param url
* URL
- * @return Typed Input Stream
+ * @return TypedInputStream
*/
public static TypedInputStream execHttpGet(String url) {
HttpCaptureResponse<TypedInputStream> handler = new CaptureInput() ;
@@ -248,7 +249,7 @@ public class HttpOp {
}
/**
- * Executes a HTTP GET and return a typed input stream.
+ * Executes a HTTP GET and return a TypedInputStream.
* The stream must be closed after use.
* <p>
* The acceptHeader string is any legal value for HTTP Accept: field.
@@ -258,7 +259,7 @@ public class HttpOp {
* URL
* @param acceptHeader
* Accept Header
- * @return Typed Input Stream
+ * @return TypedInputStream or null if the URL returns 404.
*/
public static TypedInputStream execHttpGet(String url, String
acceptHeader) {
HttpCaptureResponse<TypedInputStream> handler = new CaptureInput() ;
@@ -267,27 +268,7 @@ public class HttpOp {
}
/**
- * Executes a HTTP GET and return a typed input stream.
- * The stream must be closed after use.
- * <p>
- * The acceptHeader string is any legal value for HTTP Accept: field.
- * </p>
- *
- * @param url
- * URL
- * @param acceptHeader
- * Accept Header
- * @param authenticator
- * HTTP Authenticator
- * @return Typed Input Stream
- */
- public static TypedInputStream execHttpGet(String url, String
acceptHeader, HttpAuthenticator authenticator) {
- return execHttpGet(url, acceptHeader, null, null, authenticator);
- }
-
-
- /**
- * Executes a HTTP GET and returns a typed input stream
+ * Executes a HTTP GET and returns a TypedInputStream
* <p>
* A 404 will result in a null stream being returned, any other error code
* results in an exception.
@@ -319,7 +300,7 @@ public class HttpOp {
}
/**
- * Convenience operation to execute a GET with no content
negtotiationreturn
+ * Convenience operation to execute a GET with no content negtotiation and
return
* the response as a string.
*
* @param url URL
@@ -351,12 +332,8 @@ public class HttpOp {
}
//---- HTTP POST
- // -- Pass in a string
- // -- Pass in an InoputStream
- // -- Pass in Entity (see org.apache.http.entityContentProducer)
-
/**
- * Executes a HTTP POST with the given string as the request body and
throws
+ * Executes a HTTP POST with the given contentype/string as the request
body and throws
* away success responses, failure responses will throw an error.
*
* @param url
@@ -367,47 +344,47 @@ public class HttpOp {
* Content to POST
*/
public static void execHttpPost(String url, String contentType, String
content) {
- execHttpPost(url, contentType, content, null, null,
defaultAuthenticator);
- }
-
- /**
- * Executes a simple POST with the given string as the request body and
- * throws away success responses, failure responses will throw an error.
- *
- * @param url
- * URL
- * @param contentType
- * Content Type to POST
- * @param content
- * Content to POST
- * @param authenticator
- * HTTP Authenticator
- */
- public static void execHttpPost(String url, String contentType, String
content, HttpAuthenticator authenticator) {
- execHttpPost(url, contentType, content, null, null, authenticator);
+ execHttpPost(url, contentType, content, null, null, null, null,
defaultAuthenticator);
}
- /**
- * Executes a HTTP POST with a string as the request body and response
- * handling
- *
- * @param url
- * URL
- * @param contentType
- * Content Type to POST
- * @param content
- * Content to POST
- * @param acceptType
- * Accept Type
- * @param handler
- * Response handler called to process the response
- * @param authenticator
- * HTTP Authenticator
- */
- public static void execHttpPost(String url, String contentType, String
content, String acceptType,
- HttpResponseHandler handler,
HttpAuthenticator authenticator) {
- execHttpPost(url, contentType, content, acceptType, handler, null,
null, authenticator) ;
- }
+// /**
+// * Executes a simple POST with the given string as the request body and
+// * throws away success responses, failure responses will throw an error.
+// *
+// * @param url
+// * URL
+// * @param contentType
+// * Content Type to POST
+// * @param content
+// * Content to POST
+// * @param authenticator
+// * HTTP Authenticator
+// */
+// public static void execHttpPost(String url, String contentType, String
content, HttpAuthenticator authenticator) {
+// execHttpPost(url, contentType, content, null, null, authenticator);
+// }
+//
+// /**
+// * Executes a HTTP POST with a string as the request body and response
+// * handling
+// *
+// * @param url
+// * URL
+// * @param contentType
+// * Content Type to POST
+// * @param content
+// * Content to POST
+// * @param acceptType
+// * Accept Type
+// * @param handler
+// * Response handler called to process the response
+// * @param authenticator
+// * HTTP Authenticator
+// */
+// public static void execHttpPost(String url, String contentType, String
content, String acceptType,
+// HttpResponseHandler handler,
HttpAuthenticator authenticator) {
+// execHttpPost(url, contentType, content, acceptType, handler, null,
null, authenticator) ;
+// }
/**
* Executes a HTTP POST with a string as the request body and response
@@ -460,26 +437,26 @@ public class HttpOp {
execHttpPost(url, contentType, input, length, null, null, null, null,
defaultAuthenticator);
}
- /**
- * Executes a HTTP POST with a request body from an input stream without
- * response body with no response handling
- *
- * @param url
- * URL
- * @param contentType
- * Content Type to POST
- * @param input
- * Input Stream to POST from
- * @param length
- * Amount of content to POST
- * @param authenticator
- * HTTP Authenticator
- *
- */
- public static void execHttpPost(String url, String contentType,
InputStream input, long length,
- HttpAuthenticator authenticator) {
- execHttpPost(url, contentType, input, length, null, null, null, null,
authenticator) ;
- }
+// /**
+// * Executes a HTTP POST with a request body from an input stream without
+// * response body with no response handling
+// *
+// * @param url
+// * URL
+// * @param contentType
+// * Content Type to POST
+// * @param input
+// * Input Stream to POST from
+// * @param length
+// * Amount of content to POST
+// * @param authenticator
+// * HTTP Authenticator
+// *
+// */
+// public static void execHttpPost(String url, String contentType,
InputStream input, long length,
+// HttpAuthenticator authenticator) {
+// execHttpPost(url, contentType, input, length, null, null, null,
null, authenticator) ;
+// }
/**
* Executes a HTTP POST with request body from an input stream and response
@@ -501,8 +478,8 @@ public class HttpOp {
* @param handler
* Response handler called to process the response
*/
- public static void execHttpPost(String url, String contentType,
InputStream input, long length, String acceptType,
- HttpResponseHandler handler) {
+ public static void execHttpPost(String url, String contentType,
InputStream input, long length,
+ String acceptType, HttpResponseHandler
handler) {
execHttpPost(url, contentType, input, length, acceptType, handler,
null, null, null) ;
}
@@ -528,14 +505,17 @@ public class HttpOp {
* @param authenticator
* HTTP Authenticator
*/
- public static void execHttpPost(String url, String contentType,
InputStream input, long length, String acceptType,
- HttpResponseHandler handler,
- HttpClient httpClient, HttpContext
httpContext,
- HttpAuthenticator authenticator) {
- InputStreamEntity e = new InputStreamEntity(input, length);
- e.setContentType(contentType);
- e.setContentEncoding("UTF-8");
- execHttpPost(url, e, acceptType, handler, httpClient, httpContext,
authenticator);
+ public static void execHttpPost(String url, String contentType,
InputStream input, long length,
+ String acceptType, HttpResponseHandler
handler,
+ HttpClient httpClient, HttpContext
httpContext, HttpAuthenticator authenticator) {
+ InputStreamEntity e = new InputStreamEntity(input, length) ;
+ e.setContentType(contentType) ;
+ e.setContentEncoding("UTF-8") ;
+ try {
+ execHttpPost(url, e, acceptType, handler, httpClient, httpContext,
authenticator) ;
+ } finally {
+ closeEntity(e) ;
+ }
}
/**
@@ -577,38 +557,30 @@ public class HttpOp {
public static void execHttpPost(String url, HttpEntity entity, String
acceptHeader, HttpResponseHandler handler,
HttpClient httpClient, HttpContext
httpContext, HttpAuthenticator authenticator) {
- try {
- String requestURI = determineRequestURI(url) ;
- HttpPost httppost = new HttpPost(requestURI) ;
- httppost.setEntity(entity);
- exec(url, httppost, acceptHeader, handler, httpClient,
httpContext, authenticator) ;
- } finally {
- closeEntity(entity) ;
- }
+ String requestURI = determineRequestURI(url) ;
+ HttpPost httppost = new HttpPost(requestURI) ;
+ httppost.setEntity(entity);
+ exec(url, httppost, acceptHeader, handler, httpClient, httpContext,
authenticator) ;
}
//---- HTTP POST as a form.
- // -- Pass in a string
- // -- Pass in an InoputStream
- // -- Pass in Entity (see org.apache.http.entityContentProducer)
-
/**
- * Executes a HTTP POST and returns a typed input stream
+ * Executes a HTTP POST and returns a TypedInputStream
*
* @param url
* URL
* @param params
* Parameters to POST
* @param acceptHeader
- * @return Typed Input Stream
+ * @return TypedInputStream
*/
public static TypedInputStream execHttpPostForm(String url, Params params,
String acceptHeader) {
return execHttpPostForm(url, params, acceptHeader, null, null, null);
}
/**
- * Executes a HTTP GET and returns a typed input stream
+ * Executes a HTTP GET and returns a TypedInputStream
* <p>
* The acceptHeader string is any legal value for HTTP Accept: field.
* </p>
@@ -629,69 +601,20 @@ public class HttpOp {
* HTTP Context
* @param authenticator
* HTTP Authenticator
- * @return Typed Input Stream, null if the URL returns 404
+ * @return TypedInputStream, null if the URL returns 404
*/
public static TypedInputStream execHttpPostForm(String url, Params params,
String acceptHeader,
HttpClient httpClient,
HttpContext httpContext, HttpAuthenticator authenticator) {
- HttpCaptureResponse<TypedInputStream> handler = new CaptureInput()
;
- try {
- execHttpPostForm(url, params, acceptHeader, handler,
httpClient, httpContext, authenticator);
- } catch (HttpException ex) {
- if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
- return null ;
- throw ex ;
- }
- return handler.get();
+ HttpCaptureResponse<TypedInputStream> handler = new CaptureInput() ;
+ try {
+ execHttpPostForm(url, params, acceptHeader, handler, httpClient,
httpContext, authenticator);
+ } catch (HttpException ex) {
+ if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
+ return null ;
+ throw ex ;
}
-
-// try {
-// long id = counter.incrementAndGet();
-// String requestURI = determineRequestURI(url);
-// //String baseIRI = determineBaseIRI(requestURI);
-//
-// HttpPost httppost = new HttpPost(requestURI);
-// if (log.isDebugEnabled())
-// log.debug(format("[%d] %s %s", id, httppost.getMethod(),
httppost.getURI().toString()));
-// // Accept
-// if (acceptHeader != null)
-// httppost.addHeader(HttpNames.hAccept, acceptHeader);
-// httppost.setEntity(convertFormParams(params));
-//
-// // Prepare and execute
-// httpClient = ensureClient(httpClient);
-// httpContext = ensureContext(httpContext);
-// applyAuthentication(asAbstractClient(httpClient), url,
httpContext, authenticator);
-// HttpResponse response = httpClient.execute(httppost,
httpContext);
-//
-// // Response
-// StatusLine statusLine = response.getStatusLine();
-// if (statusLine.getStatusCode() == 404) {
-// log.debug(format("[%d] %s %s", id,
statusLine.getStatusCode(), statusLine.getReasonPhrase()));
-// return null;
-// }
-// if (statusLine.getStatusCode() >= 400) {
-// log.debug(format("[%d] %s %s", id,
statusLine.getStatusCode(), statusLine.getReasonPhrase()));
-// throw new HttpException(statusLine.getStatusCode(),
statusLine.getReasonPhrase());
-// }
-//
-// HttpEntity entity = response.getEntity();
-// if (entity == null) {
-// // No content in the return. Probably a mistake, but not
-// // guaranteed.
-// if (log.isDebugEnabled())
-// log.debug(format("[%d] %d %s :: (empty)", id,
statusLine.getStatusCode(), statusLine.getReasonPhrase()));
-// return null;
-// }
-//
-// MediaType mt =
MediaType.create(entity.getContentType().getValue());
-// if (log.isDebugEnabled())
-// log.debug(format("[%d] %d %s :: %s", id,
statusLine.getStatusCode(), statusLine.getReasonPhrase(), mt));
-//
-// return new TypedInputStreamHttp(entity.getContent(), mt,
httpClient.getConnectionManager());
-// } catch (IOException ex) {
-// throw new HttpException(ex);
-// }
-// }
+ return handler.get();
+ }
/**
* Executes a HTTP POST form operation
@@ -723,7 +646,6 @@ public class HttpOp {
*/
public static void execHttpPostForm(String url, Params params, String
acceptHeader, HttpResponseHandler handler,
HttpClient httpClient, HttpContext
httpContext, HttpAuthenticator authenticator) {
-
String requestURI = url;
HttpPost httppost = new HttpPost(requestURI);
httppost.setEntity(convertFormParams(params));
@@ -739,11 +661,9 @@ public class HttpOp {
* Content Type for the PUT
* @param content
* Content for the PUT
- * @param httpContext
- * HTTP Context
*/
- public static void execHttpPut(String url, String contentType, String
content, HttpContext httpContext) {
- execHttpPut(url, contentType, content, httpContext,
defaultAuthenticator);
+ public static void execHttpPut(String url, String contentType, String
content) {
+ execHttpPut(url, contentType, content, null, null,
defaultAuthenticator);
}
/**
@@ -760,13 +680,13 @@ public class HttpOp {
* @param authenticator
* HTTP Authenticator
*/
- public static void execHttpPut(String url, String contentType, String
content, HttpContext httpContext,
- HttpAuthenticator authenticator) {
+ public static void execHttpPut(String url, String contentType, String
content,
+ HttpClient httpClient, HttpContext
httpContext, HttpAuthenticator authenticator) {
StringEntity e = null;
try {
e = new StringEntity(content, "UTF-8");
- e.setContentType(contentType.toString());
- execHttpPut(url, e, httpContext, authenticator);
+ e.setContentType(contentType);
+ execHttpPut(url, e, httpClient, httpContext, authenticator);
} catch (UnsupportedEncodingException e1) {
throw new ARQInternalErrorException("Platform does not support
required UTF-8");
} finally {
@@ -785,11 +705,9 @@ public class HttpOp {
* Input Stream to read PUT content from
* @param length
* Amount of content to PUT
- * @param httpContext
- * HTTP Context
*/
- public static void execHttpPut(String url, String contentType, InputStream
input, long length, HttpContext httpContext) {
- execHttpPut(url, contentType, input, length, httpContext,
defaultAuthenticator);
+ public static void execHttpPut(String url, String contentType, InputStream
input, long length) {
+ execHttpPut(url, contentType, input, length, null, null, null);
}
/**
@@ -808,13 +726,13 @@ public class HttpOp {
* @param authenticator
* HTTP Authenticator
*/
- public static void execHttpPut(String url, String contentType, InputStream
input, long length, HttpContext httpContext,
- HttpAuthenticator authenticator) {
+ public static void execHttpPut(String url, String contentType, InputStream
input, long length,
+ HttpClient httpClient, HttpContext
httpContext, HttpAuthenticator authenticator) {
InputStreamEntity e = new InputStreamEntity(input, length);
e.setContentType(contentType);
e.setContentEncoding("UTF-8");
try {
- execHttpPut(url, e, httpContext, authenticator);
+ execHttpPut(url, e, httpClient, httpContext, authenticator);
} finally {
closeEntity(e);
}
@@ -827,11 +745,9 @@ public class HttpOp {
* URL
* @param entity
* HTTP Entity to PUT
- * @param httpContext
- * HTTP Context
*/
- public static void execHttpPut(String url, HttpEntity entity, HttpContext
httpContext) {
- execHttpPut(url, entity, httpContext, defaultAuthenticator);
+ public static void execHttpPut(String url, HttpEntity entity) {
+ execHttpPut(url, entity, null, null, null) ;
}
/**
@@ -846,29 +762,11 @@ public class HttpOp {
* @param authenticator
* HTTP Authenticator
*/
- public static void execHttpPut(String url, HttpEntity entity, HttpContext
httpContext, HttpAuthenticator authenticator) {
- try {
- //XXX
- long id = counter.incrementAndGet();
- String requestURI = determineRequestURI(url) ;
- String baseIRI = determineBaseIRI(requestURI);
- HttpPut httpput = new HttpPut(requestURI);
- if (log.isDebugEnabled())
- log.debug(format("[%d] %s %s", id, httpput.getMethod(),
httpput.getURI().toString()));
-
- httpput.setEntity(entity);
-
- // Prepare and Execute
- DefaultHttpClient httpclient = new SystemDefaultHttpClient();
- httpContext = ensureContext(httpContext);
- applyAuthentication(httpclient, url, httpContext, authenticator);
- HttpResponse response = httpclient.execute(httpput, httpContext);
-
- httpResponse(id, response, baseIRI, null);
- httpclient.getConnectionManager().shutdown();
- } catch (IOException ex) {
- throw new HttpException(ex);
- }
+ public static void execHttpPut(String url, HttpEntity entity, HttpClient
httpClient, HttpContext httpContext, HttpAuthenticator authenticator) {
+ String requestURI = determineRequestURI(url) ;
+ HttpPut httpput = new HttpPut(requestURI);
+ httpput.setEntity(entity) ;
+ exec(url, httpput, null, null, httpClient, httpContext, authenticator)
;
}
/**
@@ -922,7 +820,7 @@ public class HttpOp {
* URL
*/
public static void execHttpDelete(String url, HttpResponseHandler handler)
{
- execHttpDelete(url, handler, null, defaultAuthenticator) ;
+ execHttpDelete(url, handler, null, null, null) ;
}
/**
@@ -935,12 +833,12 @@ public class HttpOp {
* @param authenticator
* HTTP Authenticator
*/
- public static void execHttpDelete(String url, HttpResponseHandler handler,
HttpContext httpContext, HttpAuthenticator authenticator) {
+ public static void execHttpDelete(String url, HttpResponseHandler handler,
HttpClient httpClient, HttpContext httpContext, HttpAuthenticator
authenticator) {
HttpUriRequest httpDelete = new HttpDelete(url) ;
exec(url, httpDelete, null, handler, null, httpContext,
authenticator) ;
}
- // Perform the operation!
+ // ---- Perform the operation!
// With logging.
private static void exec(String url, HttpUriRequest request, String
acceptHeader,HttpResponseHandler handler,
Modified:
jena/trunk/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
(original)
+++
jena/trunk/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
Sun Jun 30 16:09:32 2013
@@ -18,29 +18,23 @@
package org.apache.jena.web;
-import java.io.ByteArrayInputStream ;
-import java.io.ByteArrayOutputStream ;
import java.io.IOException ;
+import java.io.OutputStream ;
import org.apache.http.Header ;
import org.apache.http.HttpEntity ;
import org.apache.http.HttpResponse ;
import org.apache.http.HttpVersion ;
-import org.apache.http.client.HttpClient ;
import org.apache.http.client.methods.HttpHead ;
import org.apache.http.client.methods.HttpUriRequest ;
-import org.apache.http.entity.ContentType ;
-import org.apache.http.entity.InputStreamEntity ;
-import org.apache.http.impl.client.SystemDefaultHttpClient ;
+import org.apache.http.entity.ContentProducer ;
+import org.apache.http.entity.EntityTemplate ;
import org.apache.http.params.BasicHttpParams ;
import org.apache.http.params.HttpConnectionParams ;
import org.apache.http.params.HttpParams ;
import org.apache.http.params.HttpProtocolParams ;
-import org.apache.http.protocol.HttpContext ;
-import org.apache.jena.atlas.logging.Log ;
import org.apache.jena.atlas.web.HttpException ;
import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
import org.apache.jena.riot.* ;
import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.riot.web.* ;
@@ -57,7 +51,10 @@ public class DatasetGraphAccessorHTTP im
// Test for this class are in Fuseki so they can be run with a server.
private final String remote ;
- private static final HttpResponseHandler noResponse =
HttpResponseLib.nullResponse ;
+ private static final HttpResponseHandler noResponse =
HttpResponseLib.nullResponse ;
+
+ /** Format used to send a graph to the server */
+ private static RDFFormat sendLang = RDFFormat.RDFXML_PLAIN ;
/** Create a DatasetUpdater for the remote URL */
public DatasetGraphAccessorHTTP(String remote)
@@ -118,7 +115,7 @@ public class DatasetGraphAccessorHTTP im
private void doPut(String url, Graph data)
{
HttpEntity entity = graphToHttpEntity(data) ;
- HttpOp.execHttpPut(url, entity, (HttpContext)null,
(HttpAuthenticator)null) ;
+ HttpOp.execHttpPut(url, entity) ;
}
@Override
@@ -193,52 +190,20 @@ public class DatasetGraphAccessorHTTP im
return h.getValue() ;
}
- private static RDFFormat sendLang = RDFFormat.RDFXML_PLAIN ;
-
- // Impedence mismatch - is there a better way?
- private static byte[] graphToBytes(Graph graph) {
- ByteArrayOutputStream out = new ByteArrayOutputStream() ;
- RDFDataMgr.write(out, graph, sendLang) ;
- byte[] bytes = out.toByteArray() ;
- return bytes ;
- }
-
- // Better : ContentProducer
- // (But this way ensures the graph can be serialized.)
-
- private static HttpEntity graphToHttpEntity(Graph graph) {
- byte[] bytes = graphToBytes(graph) ;
- ByteArrayInputStream in = new ByteArrayInputStream(bytes) ;
+ private static HttpEntity graphToHttpEntity(final Graph graph) {
+
+ ContentProducer producer = new ContentProducer() {
+ @Override
+ public void writeTo(OutputStream out) throws IOException {
+ RDFDataMgr.write(out, graph, sendLang) ;
+ }
+ } ;
+
+ EntityTemplate entity = new EntityTemplate(producer) ;
String ct = sendLang.getLang().getContentType().getContentType() ;
- ContentType contentType = ContentType.create(ct) ;
- InputStreamEntity reqEntity = new InputStreamEntity(in, bytes.length,
contentType) ;
- return reqEntity ;
+ entity.setContentType(ct) ;
+ return entity ;
}
-
- private void execSimple(String targetStr, HttpUriRequest httpRequest,
HttpAuthenticator httpAuthenticator)
- {
- HttpClient httpclient = new SystemDefaultHttpClient(httpParams) ;
- try {
- HttpResponse response = httpclient.execute(httpRequest) ;
- int responseCode = response.getStatusLine().getStatusCode() ;
- String responseMessage =
response.getStatusLine().getReasonPhrase() ;
-
- if ( HttpSC.isClientError(responseCode) ||
HttpSC.isServerError(responseCode) )
- throw JenaHttpException.create(responseCode, responseMessage) ;
-
- if ( responseCode == HttpSC.NO_CONTENT_204) return ;
- if ( responseCode == HttpSC.CREATED_201 ) return ;
-
- if ( responseCode != HttpSC.OK_200 )
- {
- Log.warn(this, "Unexpected status code") ;
- throw JenaHttpException.create(responseCode, responseMessage) ;
- }
- } catch (IOException ex)
- {
- httpRequest.abort() ;
- }
- }
private void readGraph(Graph graph, TypedInputStream ts, String base)
{
Modified:
jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
(original)
+++
jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
Sun Jun 30 16:09:32 2013
@@ -53,7 +53,7 @@ public class SPARQL_REST_RW extends SPAR
// commit, not abort, because locking "transactions" don't
support abort.
action.commit() ;
errorNotFound("No such graph: "+target.name) ;
- }
+ }
deleteGraph(action) ;
action.commit() ;
}
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/ServerTest.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/ServerTest.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/ServerTest.java
(original)
+++ jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/ServerTest.java
Sun Jun 30 16:09:32 2013
@@ -23,10 +23,16 @@ import org.apache.jena.fuseki.server.Fus
import org.apache.jena.fuseki.server.SPARQLServer ;
import org.apache.jena.fuseki.server.ServerConfig ;
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.NodeFactory ;
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
import com.hp.hpl.jena.sparql.core.DatasetGraph ;
import com.hp.hpl.jena.sparql.core.DatasetGraphFactory ;
import com.hp.hpl.jena.sparql.modify.request.Target ;
import com.hp.hpl.jena.sparql.modify.request.UpdateDrop ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
import com.hp.hpl.jena.update.Update ;
import com.hp.hpl.jena.update.UpdateExecutionFactory ;
import com.hp.hpl.jena.update.UpdateProcessor ;
@@ -39,10 +45,31 @@ import com.hp.hpl.jena.update.UpdateProc
\@Before public void beforeTest() { ServerTest.resetServer()
; }
</pre>
*/
-public class ServerTest extends BaseServerTest
+public class ServerTest
{
// Abstraction that runs a SPARQL server for tests.
+ public static final int port = 3535 ;
+ public static final String urlRoot = "http://localhost:"+port+"/" ;
+ public static final String datasetPath = "/dataset" ;
+ public static final String serviceUpdate =
"http://localhost:"+port+datasetPath+"/update" ;
+ public static final String serviceQuery =
"http://localhost:"+port+datasetPath+"/query" ;
+ public static final String serviceREST =
"http://localhost:"+port+datasetPath+"/data" ; // ??????
+
+ public static final String gn1 = "http://graph/1" ;
+ public static final String gn2 = "http://graph/2" ;
+ public static final String gn99 = "http://graph/99" ;
+
+ public static final Node n1 =
NodeFactory.createURI("http://graph/1") ;
+ public static final Node n2 =
NodeFactory.createURI("http://graph/2") ;
+ public static final Node n99 =
NodeFactory.createURI("http://graph/99") ;
+
+ public static final Graph graph1 = SSE.parseGraph("(base
<http://example/> (graph (<x> <p> 1)))") ;
+ public static final Graph graph2 = SSE.parseGraph("(base
<http://example/> (graph (<x> <p> 2)))") ;
+
+ public static final Model model1 =
ModelFactory.createModelForGraph(graph1) ;
+ public static final Model model2 =
ModelFactory.createModelForGraph(graph2) ;
+
private static SPARQLServer server = null ;
// reference count of start/stop server logging
@@ -83,10 +110,10 @@ public class ServerTest extends BaseServ
protected static void setupServer()
{
DatasetGraph dsg = DatasetGraphFactory.createMem() ;
- // This must agree with BaseServerTest
- ServerConfig conf = FusekiConfig.defaultConfiguration(datasetPath,
dsg, true) ;
- conf.port = BaseServerTest.port ;
- conf.pagesPort = BaseServerTest.port ;
+ // This must agree with ServerTest
+ ServerConfig conf =
FusekiConfig.defaultConfiguration(ServerTest.datasetPath, dsg, true) ;
+ conf.port = ServerTest.port ;
+ conf.pagesPort = ServerTest.port ;
server = new SPARQLServer(conf) ;
server.start() ;
}
@@ -116,7 +143,7 @@ public class ServerTest extends BaseServ
public static void resetServer()
{
Update clearRequest = new UpdateDrop(Target.ALL) ;
- UpdateProcessor proc =
UpdateExecutionFactory.createRemote(clearRequest, serviceUpdate) ;
+ UpdateProcessor proc =
UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate) ;
proc.execute() ;
}
}
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
(original)
+++ jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
Sun Jun 30 16:09:32 2013
@@ -36,7 +36,7 @@ import org.junit.runners.Suite ;
, TestQuery.class
, TestAuth.class
})
-public class TS_Fuseki extends BaseServerTest
+public class TS_Fuseki extends ServerTest
{
@BeforeClass static public void beforeClass() {
Log.disable(Fuseki.requestLogName) ; }
@AfterClass static public void afterClass() {
Log.setInfo(Fuseki.requestLogName) ;}
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestAuth.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestAuth.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestAuth.java
(original)
+++ jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestAuth.java
Sun Jun 30 16:09:32 2013
@@ -55,7 +55,7 @@ import com.hp.hpl.jena.update.UpdateRequ
/**
* Tests Fuseki operation with authentication enabled
*/
-public class TestAuth extends BaseServerTest {
+public class TestAuth extends ServerTest {
private static File realmFile;
private static SPARQLServer server;
@@ -74,10 +74,10 @@ public class TestAuth extends BaseServer
Log.logLevel("org.eclipse.jetty", org.apache.log4j.Level.WARN,
java.util.logging.Level.WARNING);
DatasetGraph dsg = DatasetGraphFactory.createMem();
- // This must agree with BaseServerTest
+ // This must agree with ServerTest
ServerConfig conf = FusekiConfig.defaultConfiguration(datasetPath,
dsg, true);
- conf.port = BaseServerTest.port;
- conf.pagesPort = BaseServerTest.port;
+ conf.port = ServerTest.port;
+ conf.pagesPort = ServerTest.port;
conf.authConfigFile = realmFile.getAbsolutePath();
server = new SPARQLServer(conf);
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestProtocol.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestProtocol.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestProtocol.java
(original)
+++
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestProtocol.java
Sun Jun 30 16:09:32 2013
@@ -30,7 +30,7 @@ import com.hp.hpl.jena.sparql.util.Conve
// SPARQL Query
// SPARQL Update
// GSP is done in TestDatasetAccessorHTTP
-public class TestProtocol extends BaseServerTest
+public class TestProtocol extends ServerTest
{
@BeforeClass public static void beforeClass()
{
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestQuery.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestQuery.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestQuery.java
(original)
+++ jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestQuery.java
Sun Jun 30 16:09:32 2013
@@ -22,11 +22,13 @@ import java.io.IOException ;
import java.net.HttpURLConnection ;
import java.net.URL ;
+import static org.apache.jena.fuseki.ServerTest.* ;
+
import org.junit.AfterClass ;
import org.junit.Assert ;
import org.junit.BeforeClass ;
import org.junit.Test ;
-
+import org.apache.jena.atlas.junit.BaseTest ;
import com.hp.hpl.jena.query.* ;
import com.hp.hpl.jena.sparql.core.Var ;
import com.hp.hpl.jena.sparql.engine.binding.Binding ;
@@ -36,7 +38,7 @@ import com.hp.hpl.jena.sparql.sse.SSE ;
import com.hp.hpl.jena.sparql.sse.builders.BuilderResultSet ;
import com.hp.hpl.jena.sparql.util.Convert ;
-public class TestQuery extends BaseServerTest
+public class TestQuery extends BaseTest
{
protected static ResultSet rs1 = null ;
static {
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestUpdate.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestUpdate.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestUpdate.java
(original)
+++ jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/TestUpdate.java
Sun Jun 30 16:09:32 2013
@@ -20,7 +20,7 @@ package org.apache.jena.fuseki;
import org.junit.Test ;
-public class TestUpdate extends BaseServerTest
+public class TestUpdate extends ServerTest
{
@Test public void t1() {}
}
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetAccessorHTTP.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetAccessorHTTP.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetAccessorHTTP.java
(original)
+++
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetAccessorHTTP.java
Sun Jun 30 16:09:32 2013
@@ -18,6 +18,7 @@
package org.apache.jena.fuseki.http;
+import static org.apache.jena.fuseki.ServerTest.* ;
import org.apache.jena.atlas.junit.BaseTest ;
import org.apache.jena.fuseki.ServerTest ;
import org.apache.jena.fuseki.WebTest ;
@@ -30,16 +31,15 @@ import com.hp.hpl.jena.query.DatasetAcce
import com.hp.hpl.jena.query.DatasetAccessorFactory ;
import com.hp.hpl.jena.rdf.model.Model ;
import com.hp.hpl.jena.rdf.model.ModelFactory ;
-import static org.apache.jena.fuseki.BaseServerTest.* ;
public class TestDatasetAccessorHTTP extends BaseTest
{
//Model level testing.
- static final String datasetURI_not_1 =
"http://localhost:"+ServerTest.port+"/junk" ;
+ static final String datasetURI_not_1 = "http://localhost:"+port+"/junk"
;
static final String datasetURI_not_2 = serviceREST+"/not" ;
- static final String datasetURI_not_3 =
"http://localhost:"+ServerTest.port+ServerTest.datasetPath+"/not/data" ;
+ static final String datasetURI_not_3 =
"http://localhost:"+port+datasetPath+"/not/data" ;
@BeforeClass public static void beforeClass() { ServerTest.allocServer()
; }
@AfterClass public static void afterClass() { ServerTest.freeServer()
; }
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java
(original)
+++
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java
Sun Jun 30 16:09:32 2013
@@ -18,14 +18,13 @@
package org.apache.jena.fuseki.http;
-import org.apache.jena.fuseki.BaseServerTest ;
import org.apache.jena.fuseki.ServerTest ;
+import org.apache.jena.web.AbstractTestDatasetGraphAccessor ;
import org.apache.jena.web.DatasetGraphAccessor ;
import org.apache.jena.web.DatasetGraphAccessorHTTP ;
-import org.apache.jena.web.AbstractTestDatasetGraphAccessor ;
-import org.junit.AfterClass ;
-import org.junit.Before ;
-import org.junit.BeforeClass ;
+import org.junit.AfterClass ;
+import org.junit.Before ;
+import org.junit.BeforeClass ;
public class TestDatasetGraphAccessorHTTP extends
AbstractTestDatasetGraphAccessor
{
@@ -39,6 +38,6 @@ public class TestDatasetGraphAccessorHTT
@Override
protected DatasetGraphAccessor getDatasetUpdater()
{
- return new DatasetGraphAccessorHTTP(BaseServerTest.serviceREST) ;
+ return new DatasetGraphAccessorHTTP(ServerTest.serviceREST) ;
}
}
Modified:
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java?rev=1498146&r1=1498145&r2=1498146&view=diff
==============================================================================
---
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
(original)
+++
jena/trunk/jena-fuseki/src/test/java/org/apache/jena/fuseki/http/TestHttpOp.java
Sun Jun 30 16:09:32 2013
@@ -23,31 +23,44 @@ import java.io.IOException ;
import org.apache.jena.atlas.junit.BaseTest ;
import org.apache.jena.atlas.web.HttpException ;
import org.apache.jena.fuseki.ServerTest ;
+import org.apache.jena.riot.WebContent ;
+import org.apache.jena.riot.system.IRILib ;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.web.HttpSC ;
import org.junit.AfterClass ;
import org.junit.BeforeClass ;
import org.junit.Test ;
+import com.hp.hpl.jena.sparql.engine.http.Params ;
import com.hp.hpl.jena.util.FileUtils ;
+// This a mixture of testign HttpOp and testing basic operation of the SPARQL
server
+// especially error cases abnd unusual usage that the higher level APIs don't
use.
public class TestHttpOp extends BaseTest {
- // Test HttpOp from ARQ
static String pingURL = ServerTest.urlRoot+"ping.txt" ;
@BeforeClass public static void beforeClass() { ServerTest.allocServer() ;
}
@AfterClass public static void afterClass() { ServerTest.freeServer() ; }
-
+
+ static String graphURL = ServerTest.serviceREST+"?default" ;
+ static String queryURL = ServerTest.serviceQuery ;
+ static String updateURL = ServerTest.serviceUpdate ;
+
+ static String simpleQuery =
queryURL+"?query="+IRILib.encodeUriComponent("ASK{}") ;
+
+ // Basic operations
+
@Test public void httpGet_01() {
HttpOp.execHttpGet(pingURL) ;
}
- @Test public void httpGet_02() {
+ @Test(expected=HttpException.class)
+ public void httpGet_02() {
try {
HttpOp.execHttpGet(ServerTest.urlRoot+"does-not-exist") ;
- fail("No exception") ;
} catch(HttpException ex) {
assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()) ;
+ throw ex ;
}
}
@@ -62,5 +75,129 @@ public class TestHttpOp extends BaseTest
assertNull(x) ;
}
+ @Test public void httpGet_05() {
+ HttpOp.execHttpGet(simpleQuery) ;
+ }
+
+ // SPARQL Query
+
+ @Test public void queryGet_01() {
+ HttpOp.execHttpGet(simpleQuery) ;
+ }
+
+ @Test(expected=HttpException.class)
+ public void queryGet_02() {
+ try {
+ // No query.
+ HttpOp.execHttpGet(queryURL+"?query=") ;
+ } catch (HttpException ex) {
+ assertEquals(ex.getResponseCode(), HttpSC.BAD_REQUEST_400) ;
+ throw ex ;
+ }
+ }
+
+// @Test(expected=HttpException.class)
+// public void queryGet_03() {
+// try {
+// // Service description.
+// HttpOp.execHttpGet(queryURL) ;
+// } catch (HttpException ex) {
+// assertEquals(ex.getResponseCode(), HttpSC.NOT_FOUND_404) ;
+// throw ex ;
+// }
+// }
+
+ @Test(expected=HttpException.class)
+ public void queryPost_01() {
+ try {
+ HttpOp.execHttpPost(queryURL, "ASK{}", "text/plain") ;
+ } catch (HttpException ex) {
+ assertEquals(ex.getResponseCode(),
HttpSC.UNSUPPORTED_MEDIA_TYPE_415) ;
+ throw ex ;
+ }
+ }
+
+ @Test(expected=HttpException.class)
+ public void httpPost_02() {
+ try {
+ HttpOp.execHttpPost(queryURL, "ASK{}",
WebContent.contentTypeSPARQLQuery) ;
+ } catch (HttpException ex) {
+ assertEquals(ex.getResponseCode(),
HttpSC.UNSUPPORTED_MEDIA_TYPE_415) ;
+ throw ex ;
+ }
+ }
+
+ @Test(expected=HttpException.class)
+ public void httpPost_03() {
+ try {
+ HttpOp.execHttpPost(queryURL, "ASK{}",
WebContent.contentTypeOctets) ;
+ } catch (HttpException ex) {
+ assertEquals(ex.getResponseCode(),
HttpSC.UNSUPPORTED_MEDIA_TYPE_415) ;
+ throw ex ;
+ }
+ }
+
+ @Test public void httpPost_04() {
+ Params params = new Params() ;
+ params.addParam("query", "ASK{}") ;
+ HttpOp.execHttpPostForm(queryURL, params,
WebContent.contentTypeResultsJSON) ;
+ }
+
+ @Test(expected=HttpException.class)
+ public void httpPost_05() {
+ Params params = new Params() ;
+ params.addParam("query", "ASK{}") ;
+ try {
+ // Query to Update
+ HttpOp.execHttpPostForm(updateURL, params,
WebContent.contentTypeResultsJSON) ;
+ } catch (HttpException ex) {
+ assertEquals(ex.getResponseCode(), HttpSC.BAD_REQUEST_400) ;
+ throw ex ;
+ }
+ }
+
+ @Test public void httpPost_06() {
+ Params params = new Params() ;
+ params.addParam("request", "CLEAR ALL") ;
+ HttpOp.execHttpPostForm(updateURL, params,
WebContent.contentTypeResultsJSON) ;
+ }
+
+ // GSP
+ @Test public void gsp_01() {
+ String x = HttpOp.execHttpGetString(graphURL, "application/rdf+xml") ;
+ assertTrue(x.contains("</")) ;
+ assertTrue(x.contains(":RDF")) ;
+ }
+
+ @Test public void gsp_02() {
+ String x = HttpOp.execHttpGetString(graphURL, "application/n-triples")
;
+ assertTrue(x.isEmpty()) ;
+ }
+
+ static String graphString = "@prefix : <http://example/> . :s :p :o ." ;
+
+ @Test public void gsp_03() {
+ HttpOp.execHttpPut(graphURL, WebContent.contentTypeTurtle,
graphString) ;
+ }
+
+ @Test public void gsp_04() {
+ HttpOp.execHttpPut(graphURL, WebContent.contentTypeTurtle,
graphString) ;
+ String s1 = HttpOp.execHttpGetString(graphURL,
WebContent.contentTypeNTriples) ;
+ assertFalse(s1.isEmpty()) ;
+ HttpOp.execHttpDelete(graphURL) ;
+ String s2 = HttpOp.execHttpGetString(graphURL,
WebContent.contentTypeNTriples) ;
+ assertTrue(s2.isEmpty()) ;
+ }
+
+ @Test public void gsp_05() {
+ HttpOp.execHttpDelete(graphURL) ;
+
+ HttpOp.execHttpPost(graphURL, WebContent.contentTypeTurtle,
graphString) ;
+ String s1 = HttpOp.execHttpGetString(graphURL,
WebContent.contentTypeNTriples) ;
+ assertFalse(s1.isEmpty()) ;
+ HttpOp.execHttpDelete(graphURL) ;
+ String s2 = HttpOp.execHttpGetString(graphURL,
WebContent.contentTypeNTriples) ;
+ assertTrue(s2.isEmpty()) ;
+ }
}