Search in sources :

Example 1 with ReduceFn

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

the class SecuredRDFListTest method testReduce.

@Test
public void testReduce() {
    final ReduceFn fn = new ReduceFn() {

        @Override
        public Object reduce(final RDFNode node, final Object accumulator) {
            return accumulator;
        }
    };
    try {
        getSecuredRDFList().reduce(fn, "Hello");
        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.Create });
    try {
        getSecuredRDFList().reduce(perms, fn, "Hello");
        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) ReduceFn(org.apache.jena.rdf.model.RDFList.ReduceFn) Test(org.junit.Test)

Aggregations

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