Search in sources :

Example 11 with TypedInputStream

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

the class TestHttpOp method queryGet_02.

@Test(expected = HttpException.class)
public void queryGet_02() {
    try {
        // No query.
        TypedInputStream in = HttpOp.execHttpGet(queryURL + "?query=");
        IO.close(in);
    } catch (HttpException ex) {
        assertEquals(ex.getResponseCode(), HttpSC.BAD_REQUEST_400);
        throw ex;
    }
}
Also used : HttpException(org.apache.jena.atlas.web.HttpException) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 12 with TypedInputStream

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

the class TestHttpOp method httpPost_04.

@Test
public void httpPost_04() {
    Params params = new Params();
    params.addParam("query", "ASK{}");
    TypedInputStream in = HttpOp.execHttpPostFormStream(queryURL, params, WebContent.contentTypeResultsJSON);
    IO.close(in);
}
Also used : Params(org.apache.jena.sparql.engine.http.Params) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 13 with TypedInputStream

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

the class TestHttpOp method httpGet_02.

@Test(expected = HttpException.class)
public void httpGet_02() {
    try {
        TypedInputStream in = HttpOp.execHttpGet(urlRoot() + "does-not-exist");
        IO.close(in);
    } catch (HttpException ex) {
        assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode());
        throw ex;
    }
}
Also used : HttpException(org.apache.jena.atlas.web.HttpException) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 14 with TypedInputStream

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

the class TestHttpOp method queryGet_01.

// SPARQL Query
@Test
public void queryGet_01() {
    TypedInputStream in = HttpOp.execHttpGet(simpleQuery);
    IO.close(in);
}
Also used : TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 15 with TypedInputStream

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

the class RDFConnectionRemote method fetchDataset.

@Override
public Dataset fetchDataset() {
    if (destination == null)
        throw new ARQException("Dataset operations not available - no dataset URL provided");
    Dataset ds = DatasetFactory.createTxnMem();
    Txn.executeWrite(ds, () -> {
        TypedInputStream s = exec(() -> HttpOp.execHttpGet(destination, WebContent.defaultDatasetAcceptHeader));
        Lang lang = RDFLanguages.contentTypeToLang(s.getContentType());
        RDFDataMgr.read(ds, s, lang);
    });
    return ds;
}
Also used : ARQException(org.apache.jena.sparql.ARQException) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream)

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