Search in sources :

Example 1 with AddDeniedException

use of org.apache.jena.shared.AddDeniedException in project jena by apache.

the class SecuredModelTest method testGetSeq_ResourceNotExisting.

@Test
public void testGetSeq_ResourceNotExisting() throws Exception {
    Resource r = ResourceFactory.createResource("http://example.com/securedModel/seq");
    Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Seq.asNode());
    try {
        Seq seq = securedModel.getSeq(r);
        assertEquals(securedModel, seq.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/seq", seq.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Resource(org.apache.jena.rdf.model.Resource) AddDeniedException(org.apache.jena.shared.AddDeniedException) Seq(org.apache.jena.rdf.model.Seq) Test(org.junit.Test) SecuredPrefixMappingTest(org.apache.jena.permissions.graph.SecuredPrefixMappingTest)

Example 2 with AddDeniedException

use of org.apache.jena.shared.AddDeniedException in project jena by apache.

the class SecuredModelTest method testGetAlt_Existing.

@Test
public void testGetAlt_Existing() throws Exception {
    Resource r = baseModel.createAlt("http://example.com/securedModel/alt");
    Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Bag.asNode());
    try {
        Alt alt = securedModel.getAlt(r);
        assertEquals(securedModel, alt.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/alt", alt.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
    try {
        Alt alt = securedModel.getAlt("http://example.com/securedModel/alt");
        assertEquals(securedModel, alt.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/alt", alt.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Resource(org.apache.jena.rdf.model.Resource) Alt(org.apache.jena.rdf.model.Alt) AddDeniedException(org.apache.jena.shared.AddDeniedException) Test(org.junit.Test) SecuredPrefixMappingTest(org.apache.jena.permissions.graph.SecuredPrefixMappingTest)

Example 3 with AddDeniedException

use of org.apache.jena.shared.AddDeniedException in project jena by apache.

the class SecuredModelTest method testGetAlt_ResourceNotExisting.

@Test
public void testGetAlt_ResourceNotExisting() throws Exception {
    Resource r = ResourceFactory.createResource("http://example.com/securedModel/alt");
    Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Alt.asNode());
    try {
        Alt alt = securedModel.getAlt(r);
        assertEquals(securedModel, alt.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/alt", alt.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Resource(org.apache.jena.rdf.model.Resource) Alt(org.apache.jena.rdf.model.Alt) AddDeniedException(org.apache.jena.shared.AddDeniedException) Test(org.junit.Test) SecuredPrefixMappingTest(org.apache.jena.permissions.graph.SecuredPrefixMappingTest)

Example 4 with AddDeniedException

use of org.apache.jena.shared.AddDeniedException in project jena by apache.

the class SecuredModelTest method testGetBag_StringNotExisting.

@Test
public void testGetBag_StringNotExisting() throws Exception {
    Resource r = ResourceFactory.createResource("http://example.com/securedModel/bag");
    Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Bag.asNode());
    try {
        Bag bag = securedModel.getBag("http://example.com/securedModel/bag");
        assertEquals(securedModel, bag.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/bag", bag.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Resource(org.apache.jena.rdf.model.Resource) Bag(org.apache.jena.rdf.model.Bag) AddDeniedException(org.apache.jena.shared.AddDeniedException) Test(org.junit.Test) SecuredPrefixMappingTest(org.apache.jena.permissions.graph.SecuredPrefixMappingTest)

Example 5 with AddDeniedException

use of org.apache.jena.shared.AddDeniedException in project jena by apache.

the class SecuredModelTest method testGetSeq_Existing.

@Test
public void testGetSeq_Existing() {
    final Resource r = baseModel.createSeq("http://example.com/securedModel/seq");
    Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Bag.asNode());
    try {
        Seq seq = securedModel.getSeq(r);
        assertEquals(securedModel, seq.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/seq", seq.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
    try {
        Seq seq = securedModel.getSeq("http://example.com/securedModel/seq");
        assertEquals(securedModel, seq.getModel());
        if (securedModel.canRead()) {
            assertEquals("http://example.com/securedModel/seq", seq.getURI());
        } else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
            fail("Should have thrown AddDeniedException ");
        }
    } catch (AddDeniedException e) {
        if (securedModel.canUpdate() && securedModel.canCreate(t)) {
            fail(String.format("Should not have thrown AddDeniedException ", e));
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Resource(org.apache.jena.rdf.model.Resource) AddDeniedException(org.apache.jena.shared.AddDeniedException) Seq(org.apache.jena.rdf.model.Seq) Test(org.junit.Test) SecuredPrefixMappingTest(org.apache.jena.permissions.graph.SecuredPrefixMappingTest)

Aggregations

AddDeniedException (org.apache.jena.shared.AddDeniedException)13 Resource (org.apache.jena.rdf.model.Resource)12 SecuredPrefixMappingTest (org.apache.jena.permissions.graph.SecuredPrefixMappingTest)11 Test (org.junit.Test)11 Triple (org.apache.jena.graph.Triple)10 Alt (org.apache.jena.rdf.model.Alt)3 Bag (org.apache.jena.rdf.model.Bag)3 Seq (org.apache.jena.rdf.model.Seq)3 UpdateDeniedException (org.apache.jena.shared.UpdateDeniedException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Reader (java.io.Reader)1 Writer (java.io.Writer)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1