use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class SPARQL11SEWebsocket method subscribe.
public Response subscribe(String sparql) {
if (sparql == null)
return new ErrorResponse(500, "SPARQL query is null");
// Create SPARQL 1.1 Subscribe request
JsonObject request = new JsonObject();
request.add("subscribe", new JsonPrimitive(sparql));
if (!connected) {
client = new SEPAWebsocketClient(wsURI, this);
try {
if (!client.connectBlocking()) {
logger.error("Not connected");
return new ErrorResponse(500, "Not connected");
}
} catch (InterruptedException e) {
logger.debug(e);
return new ErrorResponse(500, "Not connected");
}
}
// Send request and wait for response
Response ret = client.sendAndReceive(request.toString(), TIMEOUT);
if (ret.isSubscribeResponse())
connected = true;
return ret;
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class ITProtocolTest method Query.
@Test(timeout = 5000)
public void Query() {
final Response response = SubmitQuery(client, TestQueries.SIMPLE_QUERY);
assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class ITProtocolTest method VerifiedUTF8Update.
@Test
public void VerifiedUTF8Update() {
Update();
final Response response = SubmitQuery(client, TestQueries.UTF8_RESULT_QUERY);
assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
QueryResponse queryResponse = (QueryResponse) response;
List<Bindings> results = queryResponse.getBindingsResults().getBindings();
assertTrue("Query results empty", results.size() > 0);
Bindings bindings = results.get(0);
assertTrue("Binding variable is not a literal", bindings.isLiteral("o"));
String value = bindings.getBindingValue("o");
assertEquals("Incorrect utf-8 value", "測試", value);
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class ITProtocolTest method NotificationTest.
@Test(timeout = 20000)
public void NotificationTest() throws InterruptedException {
final Response response = submitSubscribe(TestQueries.NOTIF_QUERY, client);
assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
final Response update = SubmitUpdate(client, TestQueries.NOTIF_UPDATE);
assertFalse(String.valueOf(update.getAsJsonObject()), update.isError());
final Response notification = subHandler.getResponse();
assertFalse(String.valueOf(notification.getAsJsonObject()), notification.isError());
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class ITProtocolTest method Ping.
@Test(timeout = 5000)
public void Ping() throws InterruptedException {
final Response response = submitSubscribe(TestQueries.SIMPLE_QUERY, client);
assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
assertTrue(subHandler.pingRecived());
}
Aggregations