use of org.apache.jena.sparql.util.Context in project jena by apache.
the class TestService method query_service_context_application_05.
@SuppressWarnings("unchecked")
@Test
public void query_service_context_application_05() {
// This test requires us to set that GZip and Deflate are permitted
Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
if (serviceContextMap == null) {
ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>());
serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
}
if (serviceContextMap.get(SERVICE) == null) {
serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
}
Context serviceContext = serviceContextMap.get(SERVICE);
try {
serviceContext.put(Service.queryCompression, false);
Query q = QueryFactory.create("ASK { }");
QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
Assert.assertNotNull(engine);
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(-1, engine.getTimeout2());
Assert.assertFalse(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
} finally {
serviceContext.remove(Service.queryCompression);
}
}
use of org.apache.jena.sparql.util.Context in project jena by apache.
the class TestContext method testCxt5.
@Test
public void testCxt5() {
Context cxt = new Context();
cxt.set(p1, "false");
assertTrue("Not false", cxt.isFalse(p1));
assertTrue("Not false or undef", cxt.isFalseOrUndef(p1));
}
use of org.apache.jena.sparql.util.Context in project jena by apache.
the class TestContext method testCxt3.
@Test
public void testCxt3() {
Context cxt = new Context();
cxt.set(p1, "v");
cxt.setIfUndef(p1, "w");
Object v = cxt.get(p1);
assertSame("Not as first set", "v", v);
}
use of org.apache.jena.sparql.util.Context in project jena by apache.
the class TestContext method testCxt4.
@Test
public void testCxt4() {
Context cxt = new Context();
cxt.set(p1, "true");
assertTrue("Not true", cxt.isTrue(p1));
assertTrue("Not true or undef", cxt.isTrueOrUndef(p1));
assertTrue("Not false or undef", cxt.isFalseOrUndef(p2));
assertTrue("False when undef", !cxt.isFalse(p2));
}
use of org.apache.jena.sparql.util.Context in project jena by apache.
the class TestContext method testCxt7.
@Test
public void testCxt7() {
Context cxt = new Context();
assertEquals(-1, cxt.getInt(p1, -1));
cxt.set(p1, 1);
int x = cxt.getInt(p1, -1);
assertEquals(1, x);
}
Aggregations