use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.
the class TestHttpOperations method query_by_post_2.
@Test
public void query_by_post_2() {
String qs = Convert.encWWWForm("ASK{}");
String u = serviceQuery() + "?query=" + qs;
try (TypedInputStream in = HttpOp.execHttpPostStream(u, null, null)) {
Assert.assertNotNull(in);
}
}
use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.
the class TestFusekiTestAuth method testServer_auth.
@Test
public void testServer_auth() {
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
Credentials credentials = new UsernamePasswordCredentials(USER, PASSWORD);
credsProvider.setCredentials(AuthScope.ANY, credentials);
HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
try (TypedInputStream in = HttpOp.execHttpGet(FusekiTestAuth.urlDataset(), "*/*", client, null)) {
}
}
use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.
the class TestAdmin method list_datasets_2.
@Test
public void list_datasets_2() {
try (TypedInputStream in = execHttpGet(ServerCtl.urlRoot() + "$/" + opDatasets)) {
assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType());
JsonValue v = JSON.parseAny(in);
assertNotNull(v.getAsObject().get("datasets"));
checkJsonDatasetsAll(v);
}
}
use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.
the class JenaIOEnvironment method createLocationMapper.
/** Search a path (which is delimited by ";" because ":" is used in URIs)
* to find a description of a LocationMapper, then create and return a
* LocationMapper based on the description.
*/
public static LocationMapper createLocationMapper(String configPath) {
if (configPath == null || configPath.length() == 0) {
log.warn("Null configuration");
return null;
}
// Make a file manager to look for the location mapping file
StreamManager smgr = new StreamManager();
smgr.addLocator(new LocatorFile());
smgr.addLocator(new LocatorClassLoader(smgr.getClass().getClassLoader()));
try {
String uriConfig = null;
TypedInputStream in = null;
StringTokenizer pathElems = new StringTokenizer(configPath, AdapterFileManager.PATH_DELIMITER);
while (pathElems.hasMoreTokens()) {
String uri = pathElems.nextToken();
if (uri == null || uri.length() == 0)
break;
in = smgr.openNoMapOrNull(uri);
if (in != null) {
uriConfig = uri;
break;
}
}
if (in == null) {
log.debug("Failed to find configuration: " + configPath);
return null;
}
String syntax = FileUtils.guessLang(uriConfig);
Model model = ModelFactory.createDefaultModel();
model.read(in, uriConfig, syntax);
return processConfig(model);
} catch (JenaException ex) {
LoggerFactory.getLogger(LocationMapper.class).warn("Error in configuration file: " + ex.getMessage());
return new LocationMapper();
}
}
use of org.apache.jena.atlas.web.TypedInputStream in project jena by apache.
the class LocatorFTP method performOpen.
@Override
public TypedInputStream performOpen(String uri) {
if (uri.startsWith("ftp://")) {
try {
URL url = new URL(uri);
InputStream in = url.openStream();
ContentType ct = RDFLanguages.guessContentType(uri);
return new TypedInputStream(in, ct);
} catch (MalformedURLException ex) {
throw new RiotException("Bad FTP URL: " + uri, ex);
} catch (IOException ex) {
// This includes variations on "not found"
IO.exception(ex);
}
}
return null;
}
Aggregations