use of net.idea.restnet.c.task.ClientResourceWrapper in project ambit-mirror by ideaconsult.
the class StaXRDFTest method simpleTestRDFXML.
@Test
public void simpleTestRDFXML() throws Exception {
// testGet(getTestURI(),MediaType.APPLICATION_RDF_XML);
ClientResourceWrapper r = new ClientResourceWrapper(getTestURI());
Representation rep = r.get(MediaType.APPLICATION_RDF_XML);
Assert.assertEquals(Status.SUCCESS_OK, r.getStatus());
Assert.assertTrue(rep.isAvailable());
System.out.println(rep.getText());
rep.release();
r.release();
}
use of net.idea.restnet.c.task.ClientResourceWrapper in project ambit-mirror by ideaconsult.
the class AlgorithmResourceTest method testLocalRegression.
@Test
public void testLocalRegression() throws Exception {
Form features = new Form();
for (int i = 1; i < 3; i++) features.add(OpenTox.params.feature_uris.toString(), String.format("http://localhost:%d/feature/%d", port, i));
Form headers = new Form();
Reference dataset = new Reference(String.format("http://localhost:%d/dataset/1", port));
dataset.setQuery(features.getQueryString());
headers.add(OpenTox.params.dataset_uri.toString(), dataset.toString());
headers.add(OpenTox.params.target.toString(), String.format("http://localhost:%d/feature/2", port));
testAsyncTask(String.format("http://localhost:%d/algorithm/LR", port), // Reference.encode(String.format("http://localhost:%d/dataset/1",port))),
headers, Status.SUCCESS_OK, String.format("http://localhost:%d/model/%s", port, "3"));
headers = new Form();
headers.add(OpenTox.params.dataset_uri.toString(), dataset.toString());
testAsyncTask(String.format("http://localhost:%d/model/3", port), // Reference.encode(String.format("http://localhost:%d/dataset/1",port))),
headers, Status.SUCCESS_OK, "http://localhost:8181/dataset/1?feature_uris%5B%5D=http%3A%2F%2Flocalhost%3A8181%2Ffeature%2F1&feature_uris%5B%5D=http%3A%2F%2Flocalhost%3A8181%2Ffeature%2F2&feature_uris=http%3A%2F%2Flocalhost%3A8181%2Fmodel%2F3%2Fpredicted");
IDatabaseConnection c = getConnection();
ITable table = c.createQueryTable("EXPECTED", "SELECT * from properties where name='Property 2'");
Assert.assertEquals(2, table.getRowCount());
ClientResourceWrapper client = new ClientResourceWrapper(new Reference(String.format("http://localhost:%d/model/3", port)));
Representation r = client.get(MediaType.TEXT_PLAIN);
logger.info(r.getText());
r.release();
client.release();
Assert.fail("second run, try if predictions already exists");
testAsyncTask(String.format("http://localhost:%d/model/3", port), headers, Status.SUCCESS_OK, "http://localhost:8181/dataset/1?feature_uris%5B%5D=http%3A%2F%2Flocalhost%3A8181%2Ffeature%2F1&feature_uris%5B%5D=http%3A%2F%2Flocalhost%3A8181%2Ffeature%2F2&feature_uris=http%3A%2F%2Flocalhost%3A8181%2Fmodel%2F3%2Fpredicted");
table = c.createQueryTable("EXPECTED", "SELECT name,idstructure,idchemical FROM values_all join structure using(idstructure) where name='Property 2'");
Assert.assertEquals(7, table.getRowCount());
}
use of net.idea.restnet.c.task.ClientResourceWrapper in project ambit-mirror by ideaconsult.
the class ResourceTest method testGetJavaObject.
public void testGetJavaObject(String uri, MediaType media, Status expectedStatus) throws Exception {
ClientResourceWrapper resource = new ClientResourceWrapper(uri);
resource.setMethod(Method.GET);
resource.get(media);
Assert.assertEquals(expectedStatus, resource.getStatus());
if (resource.getStatus().isSuccess()) {
verifyResponseJavaObject(uri, media, resource.getResponseEntity());
}
}
use of net.idea.restnet.c.task.ClientResourceWrapper in project ambit-mirror by ideaconsult.
the class ResourceTest method testGetRepresentation.
public void testGetRepresentation(String uri, MediaType media) throws Exception {
ClientResourceWrapper client = new ClientResourceWrapper(uri);
Assert.assertTrue(verifyRepresentation(uri, media, client.get(media)));
}
use of net.idea.restnet.c.task.ClientResourceWrapper in project ambit-mirror by ideaconsult.
the class OTModel method report.
public String report(String ontologyURI) throws Exception {
String a = String.format("<%s>", getUri());
String query = String.format(OTModel.getSparql("sparql/ModelReport.sparql").toString(), "", a, a);
OTOntologyService<String> ontology = new OTOntologyService<String>(ontologyURI);
StringBuilder b = new StringBuilder().append(ontology.report(query));
ClientResourceWrapper client = new ClientResourceWrapper(getUri());
Representation r = null;
try {
r = client.get(MediaType.TEXT_PLAIN);
b.append(r.getText().replace("\n", "<br>"));
} catch (Exception x) {
} finally {
try {
r.release();
} catch (Exception x) {
}
try {
client.release();
} catch (Exception x) {
}
}
return b.toString();
}
Aggregations