You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2015/07/17 20:06:11 UTC
[04/10] jena git commit: Updates for JENA-990 Modified permissions to
use new Exceptions. Added ReadDeniedException Added UpdateDeniedException
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
index 6280a33..7913ad9 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredModelTest.java
@@ -17,30 +17,30 @@
*/
package org.apache.jena.permissions.model;
-import java.io.* ;
-import java.net.URL ;
-import java.util.ArrayList ;
-import java.util.List ;
-import java.util.Set ;
-
-import org.apache.jena.datatypes.xsd.XSDDatatype ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
+import java.io.*;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.Triple;
import org.apache.jena.permissions.*;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.graph.SecuredGraph;
import org.apache.jena.permissions.graph.SecuredPrefixMappingTest;
import org.apache.jena.permissions.model.SecuredModel;
-import org.apache.jena.rdf.model.* ;
-import org.junit.Assert ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.junit.runner.RunWith ;
-
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredModelTest
-{
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.shared.AccessDeniedException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredModelTest {
protected final MockSecurityEvaluator securityEvaluator;
protected SecuredModel securedModel;
protected Model baseModel;
@@ -48,8 +48,7 @@ public class SecuredModelTest
protected Property p;
protected Resource o;
- public SecuredModelTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredModelTest(final MockSecurityEvaluator securityEvaluator) {
this.securityEvaluator = securityEvaluator;
}
@@ -58,14 +57,12 @@ public class SecuredModelTest
*
* @return
*/
- protected Model createModel()
- {
+ protected Model createModel() {
return ModelFactory.createDefaultModel();
}
@Before
- public void setup()
- {
+ public void setup() {
baseModel = createModel();
baseModel.removeAll();
securedModel = Factory.getInstance(securityEvaluator,
@@ -77,196 +74,140 @@ public class SecuredModelTest
}
@Test
- public void testAdd() throws Exception
- {
+ public void testAdd() throws Exception {
final List<Statement> stmt = baseModel.listStatements().toList();
final Set<Action> createAndUpdate = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update, Action.Create });
- try
- {
+ try {
securedModel.add(stmt);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(stmt.get(0));
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(stmt.toArray(new Statement[stmt.size()]));
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel.listStatements());
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(baseModel);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, o);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo");
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", false);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", XSDDatatype.XSDstring);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.add(s, p, "foo", "en");
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -274,8 +215,7 @@ public class SecuredModelTest
}
@Test
- public void testAnonymousInModel()
- {
+ public void testAnonymousInModel() {
// test anonymous
final RDFNode rdfNode = ResourceFactory.createResource();
final RDFNode rdfNode2 = rdfNode.inModel(securedModel);
@@ -285,121 +225,89 @@ public class SecuredModelTest
}
@Test
- public void testAsRDFNode() throws Exception
- {
- securedModel.asRDFNode(NodeFactory.createURI("http://example.com/rdfNode"));
+ public void testAsRDFNode() throws Exception {
+ securedModel.asRDFNode(NodeFactory
+ .createURI("http://example.com/rdfNode"));
}
@Test
- public void testAsStatement()
- {
+ public void testAsStatement() {
final Triple t = new Triple(s.asNode(), p.asNode(), o.asNode());
- try
- {
+ try {
securedModel.asStatement(t);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testContains() throws Exception
- {
+ public void testContains() throws Exception {
final Statement stmt = baseModel.listStatements().next();
- try
- {
+ try {
securedModel.contains(stmt);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, o);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, "foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.contains(s, p, "foo", "en");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -407,173 +315,128 @@ public class SecuredModelTest
}
@Test
- public void testContainsAll() throws Exception
- {
- try
- {
+ public void testContainsAll() throws Exception {
+ try {
securedModel.containsAll(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.containsAll(baseModel.listStatements());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateAlt() throws Exception
- {
+ public void testCreateAlt() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createAlt();
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.createAlt("foo");
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateBag() throws Exception
- {
+ public void testCreateBag() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createBag();
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.createBag("foo");
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateList() throws Exception
- {
+ public void testCreateList() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create });
final List<RDFNode> nodeList = new ArrayList<RDFNode>();
- try
- {
+ try {
securedModel.createList();
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
baseModel.removeAll();
- try
- {
+ try {
securedModel.createList(nodeList.iterator());
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
baseModel.removeAll();
- try
- {
+ try {
final RDFNode[] list = new RDFNode[] {
ResourceFactory.createResource(),
ResourceFactory.createResource(),
@@ -581,17 +444,13 @@ public class SecuredModelTest
ResourceFactory.createResource(), };
securedModel.createList(list);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -600,131 +459,100 @@ public class SecuredModelTest
}
@Test
- public void testCreateLiteral() throws Exception
- {
+ public void testCreateLiteral() throws Exception {
securedModel.createLiteral("foo");
securedModel.createLiteral("foo", false);
}
@Test
- public void testCreateLiteralBoolean() throws Exception
- {
+ public void testCreateLiteralBoolean() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, true);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralChar() throws Exception
- {
+ public void testCreateLiteralChar() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 'a');
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralDouble() throws Exception
- {
+ public void testCreateLiteralDouble() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1.0d);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralFloat() throws Exception
- {
+ public void testCreateLiteralFloat() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1.0f);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralInt() throws Exception
- {
+ public void testCreateLiteralInt() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -732,172 +560,131 @@ public class SecuredModelTest
}
@Test
- public void testCreateLiteralLong() throws Exception
- {
+ public void testCreateLiteralLong() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
+ try {
securedModel.createLiteralStatement(s, p, 1L);
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testCreateLiteralObject() throws Exception
- {
+ public void testCreateLiteralObject() throws Exception {
final Set<Action> CU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Create, Action.Update });
- try
- {
- securedModel.createLiteralStatement(s, p, new URL( "http://example.com/testing/URIType"));
- if (!securityEvaluator.evaluate(CU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ try {
+ securedModel.createLiteralStatement(s, p, new URL(
+ "http://example.com/testing/URIType"));
+ if (!securityEvaluator.evaluate(CU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(CU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(CU)) {
e.printStackTrace();
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testDifference() throws Exception
- {
- try
- {
+ public void testDifference() throws Exception {
+ try {
securedModel.difference(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testEquals() throws Exception
- {
+ public void testEquals() throws Exception {
securedModel.equals(baseModel);
baseModel.equals(securedModel);
}
@Test
- public void testExpandPrefix() throws Exception
- {
- try
- {
+ public void testExpandPrefix() throws Exception {
+ try {
securedModel.expandPrefix("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetAlt() throws Exception
- {
+ public void testGetAlt() throws Exception {
final Resource a = baseModel
.createAlt("http://example.com/securedModel/alt");
- try
- {
+ try {
securedModel.getAlt(a);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getAlt("http://example.com/securedModel/alt");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetAnyReifiedStmt()
- {
+ public void testGetAnyReifiedStmt() {
// first with create.
final Set<Action> UCR = SecurityEvaluator.Util.asSet(new Action[] {
Action.Update, Action.Create, Action.Read });
- try
- {
+ try {
securedModel.getAnyReifiedStatement(baseModel.listStatements()
.next());
- if (!securityEvaluator.evaluate(UCR))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(UCR)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(UCR))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(UCR)) {
e.printStackTrace();
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -905,357 +692,266 @@ public class SecuredModelTest
final Statement st = baseModel.listStatements().next();
baseModel.createReifiedStatement(st);
// now it is there so try with read
- try
- {
+ try {
securedModel.getAnyReifiedStatement(st);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetBag()
- {
+ public void testGetBag() {
final Resource b = baseModel
.createBag("http://example.com/securedModel/bag");
- try
- {
+ try {
securedModel.getBag(b);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getBag("http://example.com/securedModel/bag");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetGraph() throws Exception
- {
+ public void testGetGraph() throws Exception {
final Graph g = securedModel.getGraph();
Assert.assertTrue(g instanceof SecuredGraph);
EqualityTester.testInequality("getGraph test", g, baseModel.getGraph());
}
@Test
- public void testGetLock()
- {
+ public void testGetLock() {
securedModel.getLock();
}
@Test
- public void testGetProperty()
- {
+ public void testGetProperty() {
- try
- {
+ try {
securedModel.getProperty("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getProperty(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getProperty("fooNS", "foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetQNameFor() throws Exception
- {
- try
- {
+ public void testGetQNameFor() throws Exception {
+ try {
securedModel.qnameFor("foo");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testgetRDFNode()
- {
+ public void testgetRDFNode() {
- try
- {
+ try {
securedModel.getRDFNode(NodeFactory.createURI("foo"));
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetReader()
- {
+ public void testGetReader() {
securedModel.getReader();
securedModel.getReader("TURTLE");
}
@Test
- public void testGetResource()
- {
+ public void testGetResource() {
securedModel.getResource("foo");
}
@Test
- public void testGetSeq()
- {
+ public void testGetSeq() {
final Resource s = baseModel
.createSeq("http://example.com/securedModel/seq");
- try
- {
+ try {
securedModel.getSeq(s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.getSeq("http://example.com/securedModel/seq");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testGetWriter()
- {
+ public void testGetWriter() {
securedModel.getWriter();
securedModel.getWriter("TURTLE");
}
@Test
- public void testIndependent() throws Exception
- {
+ public void testIndependent() throws Exception {
Assert.assertFalse(securedModel.independent());
}
@Test
- public void testIntersection() throws Exception
- {
- try
- {
+ public void testIntersection() throws Exception {
+ try {
securedModel.intersection(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsClosed() throws Exception
- {
+ public void testIsClosed() throws Exception {
securedModel.isClosed();
}
@Test
- public void testIsEmpty() throws Exception
- {
- try
- {
+ public void testIsEmpty() throws Exception {
+ try {
securedModel.isEmpty();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsIsomorphicWith()
- {
- try
- {
+ public void testIsIsomorphicWith() {
+ try {
securedModel.isIsomorphicWith(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
baseModel.isIsomorphicWith(securedModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testIsReified()
- {
- try
- {
+ public void testIsReified() {
+ try {
securedModel.isReified(baseModel.listStatements().next());
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -1263,149 +959,109 @@ public class SecuredModelTest
}
@Test
- public void testListLiteralStatements() throws Exception
- {
- try
- {
+ public void testListLiteralStatements() throws Exception {
+ try {
securedModel.listLiteralStatements(s, p, true);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, '0');
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 2.0d);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 2.0f);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.listLiteralStatements(s, p, 1);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testLock() throws Exception
- {
- try
- {
+ public void testLock() throws Exception {
+ try {
securedModel.lock();
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testPrefixMapping() throws Exception
- {
+ public void testPrefixMapping() throws Exception {
SecuredPrefixMappingTest.runTests(securityEvaluator, securedModel);
}
@Test
- public void testQuery() throws Exception
- {
+ public void testQuery() throws Exception {
final Selector s = new SimpleSelector();
- try
- {
+ try {
securedModel.query(s);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRDFNodeInModel()
- {
+ public void testRDFNodeInModel() {
// test uri
final RDFNode rdfNode = ResourceFactory
.createResource("http://exmple.com/testInModel");
@@ -1416,8 +1072,7 @@ public class SecuredModelTest
}
@Test
- public void testReadEmpty() throws Exception
- {
+ public void testReadEmpty() throws Exception {
final Set<Action> createAndUpdate = SecurityEvaluator.Util
.asSet(new Action[] { Action.Update, Action.Create });
@@ -1431,299 +1086,214 @@ public class SecuredModelTest
final String TTL_INPUT = "@prefix rt: <http://example.com/readTest#> . rt:1 a rt:3 .";
final String base = "http://example.com/test";
final String lang = "TURTLE";
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.xml");
securedModel.read(url.toString());
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final InputStream in = new ByteArrayInputStream(
XML_INPUT.getBytes());
securedModel.read(in, base);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final Reader reader = new StringReader(XML_INPUT);
securedModel.read(reader, base);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.ttl");
securedModel.read(url.toString(), lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final InputStream in = new ByteArrayInputStream(
TTL_INPUT.getBytes());
securedModel.read(in, base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final Reader reader = new StringReader(TTL_INPUT);
securedModel.read(reader, base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
- try
- {
+ try {
final URL url = SecuredModelTest.class.getResource("./test.ttl");
securedModel.read(url.toString(), base, lang);
- if (!securityEvaluator.evaluate(createAndUpdate))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(createAndUpdate)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(createAndUpdate))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(createAndUpdate)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
- }
- finally
- {
+ } finally {
baseModel.removeAll();
}
}
@Test
- public void testRemove() throws Exception
- {
+ public void testRemove() throws Exception {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
final List<Statement> stmt = baseModel.listStatements().toList();
- try
- {
+ try {
securedModel.remove(baseModel.listStatements().toList());
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(stmt.get(0));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(stmt.toArray(new Statement[stmt.size()]));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel.listStatements());
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(baseModel);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.remove(s, p, o);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
@@ -1731,302 +1301,225 @@ public class SecuredModelTest
}
@Test
- public void testRemoveAll() throws Exception
- {
+ public void testRemoveAll() throws Exception {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
- try
- {
+ try {
securedModel.removeAll();
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
// put some data back
baseModel.add(s, p, o);
- try
- {
+ try {
securedModel.removeAll(s, p, o);
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRemoveAllReifications()
- {
+ public void testRemoveAllReifications() {
final Set<Action> DU = SecurityEvaluator.Util.asSet(new Action[] {
Action.Delete, Action.Update });
final List<Statement> stmt = baseModel.listStatements().toList();
baseModel.createReifiedStatement(stmt.get(0));
- try
- {
+ try {
securedModel.removeAllReifications(stmt.get(0));
- if (!securityEvaluator.evaluate(DU))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(DU)) {
+ Assert.fail("Should have thrown AccessDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(DU))
- {
+ } catch (final AccessDeniedException e) {
+ if (securityEvaluator.evaluate(DU)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown AccessDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testRequiredProperty()
- {
+ public void testRequiredProperty() {
- try
- {
+ try {
securedModel.getRequiredProperty(s, p);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testSize() throws Exception
- {
- try
- {
+ public void testSize() throws Exception {
+ try {
securedModel.size();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testUnion() throws Exception
- {
- try
- {
+ public void testUnion() throws Exception {
+ try {
securedModel.union(baseModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
baseModel.union(securedModel);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testVariableInModel()
- {
- try
- {
+ public void testVariableInModel() {
+ try {
final RDFNode rdfNode = ResourceFactory
.createTypedLiteral("yeehaw");
final RDFNode rdfNode2 = rdfNode.inModel(securedModel);
- if (!securityEvaluator.evaluate(Action.Update))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Update)) {
+ Assert.fail("Should have thrown UpdateDeniedException Exception");
}
Assert.assertEquals(
"Should have placed RDFNode in secured securedModel",
securedModel, rdfNode2.getModel());
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Update))
- {
+ } catch (final UpdateDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown UpdateDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
}
@Test
- public void testWrapAsResource() throws Exception
- {
- securedModel.wrapAsResource(NodeFactory.createURI("http://example.com/rdfNode"));
+ public void testWrapAsResource() throws Exception {
+ securedModel.wrapAsResource(NodeFactory
+ .createURI("http://example.com/rdfNode"));
}
@Test
- public void testWrite() throws Exception
- {
+ public void testWrite() throws Exception {
final OutputStream out = new ByteArrayOutputStream();
final Writer writer = new CharArrayWriter();
final String lang = "TURTLE";
- try
- {
+ try {
securedModel.write(out);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(out, lang);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer, lang);
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(out, lang, "http://example.com/securedGraph");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
- try
- {
+ try {
securedModel.write(writer, lang, "http://example.com/securedGraph");
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/fcf71889/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
index affa7df..803a973 100644
--- a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
+++ b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredPropertyTest.java
@@ -17,37 +17,33 @@
*/
package org.apache.jena.permissions.model;
-import org.apache.jena.permissions.AccessDeniedException;
import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.ReadDeniedException;
import org.apache.jena.permissions.SecurityEvaluatorParameters;
import org.apache.jena.permissions.SecurityEvaluator.Action;
import org.apache.jena.permissions.model.SecuredProperty;
import org.apache.jena.permissions.model.impl.SecuredPropertyImpl;
-import org.apache.jena.rdf.model.Property ;
-import org.apache.jena.rdf.model.ResourceFactory ;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.ResourceFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith( value = SecurityEvaluatorParameters.class )
-public class SecuredPropertyTest extends SecuredResourceTest
-{
+@RunWith(value = SecurityEvaluatorParameters.class)
+public class SecuredPropertyTest extends SecuredResourceTest {
- public SecuredPropertyTest( final MockSecurityEvaluator securityEvaluator )
- {
+ public SecuredPropertyTest(final MockSecurityEvaluator securityEvaluator) {
super(securityEvaluator);
}
- private SecuredProperty getSecuredProperty()
- {
+ private SecuredProperty getSecuredProperty() {
return (SecuredProperty) getSecuredRDFNode();
}
@Override
@Before
- public void setup()
- {
+ public void setup() {
super.setup();
final Property p = ResourceFactory
.createProperty("http://example.com/testProperty");
@@ -55,22 +51,16 @@ public class SecuredPropertyTest extends SecuredResourceTest
}
@Test
- public void testGetOrdinal()
- {
- try
- {
+ public void testGetOrdinal() {
+ try {
getSecuredProperty().getOrdinal();
- if (!securityEvaluator.evaluate(Action.Read))
- {
- Assert.fail("Should have thrown AccessDenied Exception");
+ if (!securityEvaluator.evaluate(Action.Read)) {
+ Assert.fail("Should have thrown ReadDeniedException Exception");
}
- }
- catch (final AccessDeniedException e)
- {
- if (securityEvaluator.evaluate(Action.Read))
- {
+ } catch (final ReadDeniedException e) {
+ if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String
- .format("Should not have thrown AccessDenied Exception: %s - %s",
+ .format("Should not have thrown ReadDeniedException Exception: %s - %s",
e, e.getTriple()));
}
}