Search in sources :

Example 16 with TypedInputStream

use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.

the class TestDatasetOps method gsp_x_ct.

private void gsp_x_ct(String urlDataset, String acceptheader, String contentTypeResponse) {
    HttpEntity e = datasetToHttpEntity(data);
    HttpOp.execHttpPut(urlDataset(), e);
    // Do manually so the test can validate the expected ContentType
    try (TypedInputStream in = HttpOp.execHttpGet(urlDataset, acceptheader)) {
        assertEqualsIgnoreCase(contentTypeResponse, in.getContentType());
        Lang lang = RDFLanguages.contentTypeToLang(in.getContentType());
        DatasetGraph dsg = DatasetGraphFactory.create();
        StreamRDF dest = StreamRDFLib.dataset(dsg);
        RDFParser.source(in).lang(lang).parse(dest);
    }
}
Also used : HttpEntity(org.apache.http.HttpEntity) StreamRDF(org.apache.jena.riot.system.StreamRDF) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 17 with TypedInputStream

use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.

the class TestHttpOperations method query_by_get_1.

// XXX and directly on dataset
@Test
public void query_by_get_1() {
    String qs = Convert.encWWWForm("ASK{}");
    String u = serviceQuery() + "?query=" + qs;
    try (TypedInputStream in = HttpOp.execHttpGet(u)) {
        Assert.assertNotNull(in);
    }
}
Also used : TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) Test(org.junit.Test)

Example 18 with TypedInputStream

use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.

the class TestAdmin method getDatasetDescription.

private static JsonValue getDatasetDescription(String dsName) {
    try (TypedInputStream in = execHttpGet(ServerCtl.urlRoot() + "$/" + opDatasets + "/" + dsName)) {
        assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType());
        JsonValue v = JSON.parse(in);
        return v;
    }
}
Also used : JsonValue(org.apache.jena.atlas.json.JsonValue) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream)

Example 19 with TypedInputStream

use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.

the class TestAdmin method list_backups_1.

@Test
public void list_backups_1() {
    try (TypedInputStream in = execHttpGet(ServerCtl.urlRoot() + "$/" + opListBackups)) {
        assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType());
        JsonValue v = JSON.parseAny(in);
        assertNotNull(v.getAsObject().get("backups"));
    }
}
Also used : JsonValue(org.apache.jena.atlas.json.JsonValue) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) Test(org.junit.Test)

Example 20 with TypedInputStream

use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.

the class HttpQuery method execPost.

private InputStream execPost() throws QueryExceptionHTTP {
    URL target = null;
    try {
        target = new URL(serviceURL);
    } catch (MalformedURLException malEx) {
        throw new QueryExceptionHTTP(0, "Malformed URL: " + malEx);
    }
    log.trace("POST " + target.toExternalForm());
    ARQ.getHttpRequestLogger().trace(target.toExternalForm());
    try {
        // Get the actual response stream
        TypedInputStream stream = HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, getContext());
        if (stream == null)
            throw new QueryExceptionHTTP(404);
        return execCommon(stream);
    } catch (HttpException httpEx) {
        throw rewrap(httpEx);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) HttpException(org.apache.jena.atlas.web.HttpException) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) URL(java.net.URL)

Aggregations

TypedInputStream (org.apache.jena.atlas.web.TypedInputStream)32 Test (org.junit.Test)11 BaseTest (org.apache.jena.atlas.junit.BaseTest)8 HttpException (org.apache.jena.atlas.web.HttpException)7 ContentType (org.apache.jena.atlas.web.ContentType)6 InputStream (java.io.InputStream)4 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)4 HttpClient (org.apache.http.client.HttpClient)4 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)4 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 JsonValue (org.apache.jena.atlas.json.JsonValue)3 HttpEntity (org.apache.http.HttpEntity)2 Credentials (org.apache.http.auth.Credentials)2 FusekiTestAuth.assertAuthHttpException (org.apache.jena.fuseki.embedded.FusekiTestAuth.assertAuthHttpException)2 Model (org.apache.jena.rdf.model.Model)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 NoSuchFileException (java.nio.file.NoSuchFileException)1 AccessControlException (java.security.AccessControlException)1