use of org.apache.jena.permissions.model.impl.SecuredStatementIterator in project jena by apache.
the class SecuredResourceTest method testListProperties.
@Test
public void testListProperties() {
try {
SecuredStatementIterator iter = getSecuredResource().listProperties();
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
assertTrue(iter.hasNext());
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
try {
SecuredStatementIterator iter = getSecuredResource().listProperties(SecuredRDFNodeTest.p);
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
if (hasP()) {
assertTrue(iter.hasNext());
} else {
assertFalse(iter.hasNext());
}
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
}
use of org.apache.jena.permissions.model.impl.SecuredStatementIterator in project jena by apache.
the class SecuredResourceTest method testListPropertiesWithLang.
@Test
public void testListPropertiesWithLang() {
try {
SecuredStatementIterator iter = getSecuredResource().listProperties(SecuredRDFNodeTest.p2, "");
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
if (hasP2()) {
assertTrue(iter.hasNext());
Statement stmt = iter.next();
assertEquals("yeehaw", stmt.getObject().asLiteral().getString());
}
assertFalse(iter.hasNext());
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
try {
SecuredStatementIterator iter = getSecuredResource().listProperties(SecuredRDFNodeTest.p2, "us");
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
if (hasP2()) {
assertTrue(iter.hasNext());
Statement stmt = iter.next();
assertEquals("yeehaw yall", stmt.getObject().asLiteral().getString());
}
assertFalse(iter.hasNext());
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
try {
SecuredStatementIterator iter = getSecuredResource().listProperties(SecuredRDFNodeTest.p2, "uk");
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
if (hasP2()) {
assertTrue(iter.hasNext());
Statement stmt = iter.next();
assertEquals("whohoo", stmt.getObject().asLiteral().getString());
}
assertFalse(iter.hasNext());
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
}
Aggregations