Search in sources :

Example 1 with ApplyFn

use of org.apache.jena.rdf.model.RDFList.ApplyFn in project jena by apache.

the class SecuredRDFListTest method testApply.

@Test
public void testApply() {
    final ApplyFn fn = new ApplyFn() {

        @Override
        public void apply(final RDFNode node) {
        // do nothing
        }
    };
    try {
        getSecuredRDFList().apply(fn);
        if (!securityEvaluator.evaluate(Action.Read)) {
            Assert.fail("Should have thrown ReadDeniedException Exception");
        }
    } catch (final ReadDeniedException e) {
        if (securityEvaluator.evaluate(Action.Read)) {
            Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
        }
    }
    final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] { Action.Update, Action.Read });
    try {
        getSecuredRDFList().apply(perms, fn);
        if (!securityEvaluator.evaluate(Action.Read)) {
            Assert.fail("Should have thrown ReadDeniedException Exception");
        }
    } catch (final ReadDeniedException e) {
        if (securityEvaluator.evaluate(Action.Read)) {
            Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
        }
    }
}
Also used : Action(org.apache.jena.permissions.SecurityEvaluator.Action) ReadDeniedException(org.apache.jena.shared.ReadDeniedException) ApplyFn(org.apache.jena.rdf.model.RDFList.ApplyFn) Test(org.junit.Test)

Aggregations

Action (org.apache.jena.permissions.SecurityEvaluator.Action)1 ApplyFn (org.apache.jena.rdf.model.RDFList.ApplyFn)1 ReadDeniedException (org.apache.jena.shared.ReadDeniedException)1 Test (org.junit.Test)1