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 2013/08/01 23:53:44 UTC

svn commit: r1509448 [2/5] - in /jena/Experimental/jena-security/src: main/java/org/apache/jena/security/graph/ main/java/org/apache/jena/security/query/ main/java/org/apache/jena/security/utils/ test/java/org/apache/jena/security/graph/ test/java/org/...

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/BulkUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/BulkUpdateHandlerTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/BulkUpdateHandlerTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/BulkUpdateHandlerTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,371 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.graph;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.NodeFactory;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+import java.util.Arrays;
+import java.util.Set;
+
+import org.junit.Assert;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.Factory;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.graph.SecuredBulkUpdateHandler;
+import org.apache.jena.security.graph.SecuredGraph;
+import org.apache.jena.security.utils.CollectionGraph;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class BulkUpdateHandlerTest
+{
+	protected SecuredBulkUpdateHandler handler;
+	private final SecurityEvaluator securityEvaluator;
+	private final Triple[] tripleArray;
+	private final Set<Action> deleteAndUpdate;
+	private final Set<Action> createAndUpdate;
+
+	public BulkUpdateHandlerTest( final SecurityEvaluator securityEvaluator )
+	{
+		this.securityEvaluator = securityEvaluator;
+
+		tripleArray = new Triple[] {
+				new Triple(NodeFactory.createURI("http://example.com/1"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()),
+				new Triple(NodeFactory.createURI("http://example.com/2"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()),
+				new Triple(NodeFactory.createURI("http://example.com/3"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()) };
+		createAndUpdate = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Create, Action.Update });
+		deleteAndUpdate = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Delete, Action.Update });
+	}
+
+	@Before
+	public void setup()
+	{
+		final Graph g = GraphFactory.createDefaultGraph();
+
+		final SecuredGraph sg = Factory.getInstance(securityEvaluator,
+				"http://example.com/testGraph", g);
+		handler = sg.getBulkUpdateHandler();
+	}
+
+	@Test
+	public void testAdd()
+	{
+		try
+		{
+			handler.add(tripleArray);
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.add(Arrays.asList(tripleArray));
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.add(Arrays.asList(tripleArray).iterator());
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.add(new CollectionGraph(Arrays.asList(tripleArray)));
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.add(new CollectionGraph(Arrays.asList(tripleArray)));
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.add(new CollectionGraph(Arrays.asList(tripleArray)), true);
+			if (!securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(createAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testDelete()
+	{
+
+		try
+		{
+			handler.delete(tripleArray);
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.delete(Arrays.asList(tripleArray));
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.delete(Arrays.asList(tripleArray).iterator());
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.delete(new CollectionGraph(Arrays.asList(tripleArray)));
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			handler.delete(new CollectionGraph(Arrays.asList(tripleArray)),
+					true);
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	public void testRemove()
+	{
+		try
+		{
+			handler.remove(NodeFactory.createURI("http://example.com/1"),
+					NodeFactory.createURI("http://example.com/v"), NodeFactory.createAnon());
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	public void testRemoveAll()
+	{
+		try
+		{
+			handler.removeAll();
+			if (!securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(deleteAndUpdate,
+					handler.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/BulkUpdateHandlerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/GraphEventManagerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/GraphEventManagerTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/GraphEventManagerTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/GraphEventManagerTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,333 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.graph;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.GraphEventManager;
+import com.hp.hpl.jena.graph.GraphListener;
+import com.hp.hpl.jena.graph.NodeFactory;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jena.security.Factory;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.graph.SecuredGraph;
+import org.apache.jena.security.utils.CollectionGraph;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class GraphEventManagerTest
+{
+	private class RecordingGraphListener implements GraphListener
+	{
+
+		private boolean add;
+		private boolean delete;
+		private boolean event;
+
+		public boolean isAdd()
+		{
+			return add;
+		}
+
+		public boolean isDelete()
+		{
+			return delete;
+		}
+
+		public boolean isEvent()
+		{
+			return event;
+		}
+
+		@Override
+		public void notifyAddArray( final Graph g, final Triple[] triples )
+		{
+			add = true;
+		}
+
+		@Override
+		public void notifyAddGraph( final Graph g, final Graph added )
+		{
+			add = true;
+		}
+
+		@Override
+		public void notifyAddIterator( final Graph g, final Iterator<Triple> it )
+		{
+			add = true;
+		}
+
+		@Override
+		public void notifyAddList( final Graph g, final List<Triple> triples )
+		{
+			add = true;
+		}
+
+		@Override
+		public void notifyAddTriple( final Graph g, final Triple t )
+		{
+			add = true;
+		}
+
+		@Override
+		public void notifyDeleteArray( final Graph g, final Triple[] triples )
+		{
+			delete = true;
+		}
+
+		@Override
+		public void notifyDeleteGraph( final Graph g, final Graph removed )
+		{
+			delete = true;
+		}
+
+		@Override
+		public void notifyDeleteIterator( final Graph g,
+				final Iterator<Triple> it )
+		{
+			delete = true;
+		}
+
+		@Override
+		public void notifyDeleteList( final Graph g, final List<Triple> L )
+		{
+			delete = true;
+		}
+
+		@Override
+		public void notifyDeleteTriple( final Graph g, final Triple t )
+		{
+			delete = true;
+		}
+
+		@Override
+		public void notifyEvent( final Graph source, final Object value )
+		{
+			event = true;
+		}
+
+		public void reset()
+		{
+			add = false;
+			delete = false;
+			event = false;
+		}
+
+	}
+
+	private final GraphEventManager manager;
+	private final Graph g;
+	private final SecuredGraph sg;
+	private final SecurityEvaluator securityEvaluator;
+	private Triple[] tripleArray;
+
+	private final RecordingGraphListener listener;
+
+	public GraphEventManagerTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		this.securityEvaluator = securityEvaluator;
+		g = GraphFactory.createDefaultGraph();
+
+		sg = Factory.getInstance(securityEvaluator,
+				"http://example.com/testGraph", g);
+		manager = sg.getEventManager();
+		listener = new RecordingGraphListener();
+		manager.register(listener);
+
+	}
+
+	@Test
+	public void notifyAddTest()
+	{
+		final Set<Action> ADD = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Create, Action.Read });
+		g.add(tripleArray[0]);
+		if (securityEvaluator.evaluateAny(ADD, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded add", listener.isAdd());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded add", listener.isAdd());
+		}
+		g.delete(Triple.ANY);
+		listener.reset();
+
+		g.getBulkUpdateHandler().add(tripleArray);
+		if (securityEvaluator.evaluateAny(ADD, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded add", listener.isAdd());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded add", listener.isAdd());
+		}
+		g.delete(Triple.ANY);
+		listener.reset();
+
+		g.getBulkUpdateHandler().add(Arrays.asList(tripleArray));
+		if (securityEvaluator.evaluateAny(ADD, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded add", listener.isAdd());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded add", listener.isAdd());
+		}
+		g.delete(Triple.ANY);
+		listener.reset();
+
+		g.getBulkUpdateHandler().add(Arrays.asList(tripleArray).iterator());
+		if (securityEvaluator.evaluateAny(ADD, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded add", listener.isAdd());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded add", listener.isAdd());
+		}
+		g.delete(Triple.ANY);
+		listener.reset();
+
+		g.getBulkUpdateHandler().add(
+				new CollectionGraph(Arrays.asList(tripleArray)));
+		if (securityEvaluator.evaluateAny(ADD, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded add", listener.isAdd());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded add", listener.isAdd());
+		}
+		g.delete(Triple.ANY);
+		listener.reset();
+	}
+
+	@Test
+	public void notifyDeleteTest()
+	{
+		final Set<Action> DELETE = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Delete, Action.Read });
+		g.delete(tripleArray[0]);
+		if (securityEvaluator.evaluateAny(DELETE, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should have recorded delete",
+					listener.isDelete());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded delete",
+					listener.isDelete());
+		}
+
+		listener.reset();
+
+		g.getBulkUpdateHandler().delete(tripleArray);
+		if (securityEvaluator.evaluateAny(DELETE, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded delete", listener.isDelete());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded delete",
+					listener.isDelete());
+		}
+		listener.reset();
+
+		g.getBulkUpdateHandler().delete(Arrays.asList(tripleArray));
+		if (securityEvaluator.evaluateAny(DELETE, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded delete", listener.isDelete());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded delete",
+					listener.isDelete());
+		}
+		listener.reset();
+
+		g.getBulkUpdateHandler().delete(Arrays.asList(tripleArray).iterator());
+		if (securityEvaluator.evaluateAny(DELETE, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded delete", listener.isDelete());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded delete",
+					listener.isDelete());
+		}
+		listener.reset();
+
+		g.getBulkUpdateHandler().delete(
+				new CollectionGraph(Arrays.asList(tripleArray)));
+		if (securityEvaluator.evaluateAny(DELETE, sg.getModelNode()))
+		{
+			Assert.assertTrue("Should recorded delete", listener.isDelete());
+		}
+		else
+		{
+			Assert.assertFalse("Should not have recorded delete",
+					listener.isDelete());
+		}
+		listener.reset();
+	}
+
+	@Test
+	public void notifyEventTest()
+	{
+		g.getEventManager().notifyEvent(g, "Foo");
+		Assert.assertTrue("Should recorded delete", listener.isEvent());
+		listener.reset();
+		// final RecordingGraphListener listener2 = new
+		// RecordingGraphListener();
+		// g.getEventManager().register(listener2);
+		sg.getEventManager().notifyEvent(sg, "Foo");
+		Assert.assertTrue("Should recorded delete", listener.isEvent());
+		// Assert.assertTrue("Should recorded delete", listener2.isEvent());
+		listener.reset();
+
+	}
+
+	@Before
+	public void setup()
+	{
+		tripleArray = new Triple[] {
+				new Triple(NodeFactory.createURI("http://example.com/1"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()),
+				new Triple(NodeFactory.createURI("http://example.com/2"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()),
+				new Triple(NodeFactory.createURI("http://example.com/3"),
+						NodeFactory.createURI("http://example.com/v"),
+						NodeFactory.createAnon()) };
+
+	}
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/GraphEventManagerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/MemGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/MemGraphTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/MemGraphTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/MemGraphTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.graph;
+
+import com.hp.hpl.jena.graph.BulkUpdateHandler;
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.NodeFactory;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.graph.TripleMatch;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.EqualityTester;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.graph.SecuredBulkUpdateHandler;
+import org.apache.jena.security.graph.SecuredGraph;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class MemGraphTest
+{
+	private SecuredGraph securedGraph;
+	private final MockSecurityEvaluator securityEvaluator;
+	private Node s;
+	private Node p;
+	private Node o;
+	private Triple t;
+
+	private Graph baseGraph;
+
+	public MemGraphTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		this.securityEvaluator = securityEvaluator;
+	}
+
+	protected Graph createGraph() throws Exception
+	{
+		return GraphFactory.createDefaultGraph();
+	}
+
+	@Before
+	public void setUp() throws Exception
+	{
+		baseGraph = createGraph();
+		baseGraph.getBulkUpdateHandler().removeAll();
+		securedGraph = org.apache.jena.security.Factory
+				.getInstance(securityEvaluator,
+						"http://example.com/securedGraph", baseGraph);
+		s = NodeFactory.createURI("http://example.com/securedGraph/s");
+		p = NodeFactory.createURI("http://example.com/securedGraph/p");
+		o = NodeFactory.createURI("http://example.com/securedGraph/o");
+		t = new Triple(s, p, o);
+		baseGraph.add(t);
+	}
+
+	@Test
+	public void testBulkUpdateHandler() throws Exception
+	{
+		final BulkUpdateHandler buh = securedGraph.getBulkUpdateHandler();
+		Assert.assertNotNull("BulkUpdateHandler may not be null", buh);
+		Assert.assertTrue("BulkUpdateHandler should be secured",
+				buh instanceof SecuredBulkUpdateHandler);
+		final BulkUpdateHandlerTest buhTest = new BulkUpdateHandlerTest(
+				securityEvaluator) {
+			@Override
+			public void setup()
+			{
+				this.handler = (SecuredBulkUpdateHandler) buh;
+			}
+		};
+		for (final Method m : buhTest.getClass().getMethods())
+		{
+			if (m.isAnnotationPresent(Test.class))
+			{
+				buhTest.setup();
+				m.invoke(buhTest);
+			}
+		}
+	}
+
+	@Test
+	public void testContainsNodes() throws Exception
+	{
+		try
+		{
+			Assert.assertTrue(securedGraph.contains(s, p, o));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testContainsTriple() throws Exception
+	{
+		try
+		{
+			Assert.assertTrue(securedGraph.contains(t));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testDelete() throws Exception
+	{
+		final Set<Action> UD = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Delete });
+		try
+		{
+			securedGraph.delete(t);
+
+			if (!securityEvaluator.evaluate(UD))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+			Assert.assertEquals(0, baseGraph.size());
+
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(UD))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testDependsOn() throws Exception
+	{
+		try
+		{
+			Assert.assertFalse(securedGraph.dependsOn(GraphFactory
+					.createDefaultGraph()));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		try
+		{
+			Assert.assertTrue(securedGraph.dependsOn(baseGraph));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testFindNodes() throws Exception
+	{
+		try
+		{
+
+			Assert.assertFalse(securedGraph.find(Node.ANY, Node.ANY, Node.ANY)
+					.toList().isEmpty());
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testFindTriple() throws Exception
+	{
+		try
+		{
+			Assert.assertFalse(securedGraph.find(t).toList().isEmpty());
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetPrefixMapping() throws Exception
+	{
+		SecuredPrefixMappingTest.runTests(securityEvaluator,
+				securedGraph.getPrefixMapping());
+	}
+
+	@Test
+	public void testInequality()
+	{
+		EqualityTester
+				.testInequality("proxy and base", securedGraph, baseGraph);
+		final Graph g2 = org.apache.jena.security.graph.impl.Factory
+				.getInstance(securityEvaluator,
+						"http://example.com/securedGraph", baseGraph);
+		EqualityTester.testEquality("proxy and proxy2", securedGraph, g2);
+		EqualityTester.testInequality("base and proxy2", baseGraph, g2);
+	}
+
+	@Test
+	public void testIsIsomorphicWith() throws Exception
+	{
+		try
+		{
+			Assert.assertFalse(securedGraph.isIsomorphicWith(GraphFactory
+					.createDefaultGraph()));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		try
+		{
+			Assert.assertTrue(securedGraph.isIsomorphicWith(baseGraph));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSize() throws Exception
+	{
+		try
+		{
+			Assert.assertEquals(1, securedGraph.size());
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testTripleMatch() throws Exception
+	{
+		try
+		{
+			Assert.assertFalse(securedGraph.find(new TripleMatch() {
+
+				@Override
+				public Triple asTriple()
+				{
+					return Triple.ANY;
+				}
+
+				@Override
+				public Node getMatchObject()
+				{
+					return Node.ANY;
+				}
+
+				@Override
+				public Node getMatchPredicate()
+				{
+					return Node.ANY;
+				}
+
+				@Override
+				public Node getMatchSubject()
+				{
+					return Node.ANY;
+				}
+			}).toList().isEmpty());
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/MemGraphTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/SecuredPrefixMappingTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/SecuredPrefixMappingTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/SecuredPrefixMappingTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/SecuredPrefixMappingTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,441 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.graph;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.shared.impl.PrefixMappingImpl;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.junit.Assert;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.Factory;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.graph.SecuredGraph;
+import org.apache.jena.security.graph.SecuredPrefixMapping;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class SecuredPrefixMappingTest
+{
+	public static void runTests( final SecurityEvaluator securityEvaluator,
+			final PrefixMapping prefixMapping ) throws Exception
+	{
+		final PrefixMapping pm = prefixMapping;
+		Assert.assertNotNull("PrefixMapping may not be null", pm);
+		Assert.assertTrue("PrefixMapping should be secured",
+				pm instanceof SecuredPrefixMapping);
+		final SecuredPrefixMappingTest pmTest = new SecuredPrefixMappingTest(
+				securityEvaluator) {
+			@Override
+			public void setup()
+			{
+				this.securedMapping = (SecuredPrefixMapping) pm;
+			}
+		};
+		Method lockTest = null;
+		for (final Method m : pmTest.getClass().getMethods())
+		{
+			if (m.isAnnotationPresent(Test.class))
+			{
+				// lock test must come last
+				if (!m.getName().equals("lockTest"))
+				{
+					lockTest = m;
+				}
+				else
+				{
+					pmTest.setup();
+					m.invoke(pmTest);
+				}
+
+			}
+		}
+		pmTest.setup();
+		lockTest.invoke(pmTest);
+
+	}
+
+	private final SecurityEvaluator securityEvaluator;
+
+	protected SecuredPrefixMapping securedMapping;
+
+	public SecuredPrefixMappingTest( final SecurityEvaluator securityEvaluator )
+	{
+		this.securityEvaluator = securityEvaluator;
+	}
+
+	@Before
+	public void setup()
+	{
+		final Graph g = GraphFactory.createDefaultGraph();
+
+		final SecuredGraph sg = Factory.getInstance(securityEvaluator,
+				"http://example.com/testGraph", g);
+		this.securedMapping = sg.getPrefixMapping();
+	}
+
+	@Test
+	public void testExpandPrefix()
+	{
+		try
+		{
+			securedMapping.expandPrefix("foo");
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetNsPrefixMap()
+	{
+		try
+		{
+			securedMapping.getNsPrefixMap();
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetNsPrefixURI()
+	{
+
+		try
+		{
+			securedMapping.getNsPrefixURI("foo");
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testGetNsURIPrefix()
+	{
+
+		try
+		{
+			securedMapping.getNsURIPrefix("http://example.com/foo");
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testLock()
+	{
+		try
+		{
+			securedMapping.lock();
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testQnameFor()
+	{
+		try
+		{
+			securedMapping.qnameFor("http://example.com/foo/bar");
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testRemoveNsPrefix()
+	{
+		try
+		{
+			securedMapping.removeNsPrefix("foo");
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testSamePrefixMappingAs()
+	{
+		try
+		{
+			securedMapping.samePrefixMappingAs(GraphFactory
+					.createDefaultGraph().getPrefixMapping());
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetNsPrefix()
+	{
+		try
+		{
+			securedMapping.setNsPrefix("foo", "http://example.com/foo");
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			securedMapping.setNsPrefixes(GraphFactory.createDefaultGraph()
+					.getPrefixMapping());
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			securedMapping.setNsPrefixes(new HashMap<String, String>());
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testShortForm()
+	{
+		try
+		{
+			securedMapping.shortForm("http://example.com/foo/bar");
+			if (!securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testWithDefaultMappings()
+	{
+		PrefixMapping pm = new PrefixMappingImpl();
+		pm.setNsPrefix( "example", "http://example.com");
+		try
+		{
+			// make sure that it must update
+			securedMapping.withDefaultMappings(pm);
+			if (!securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+	
+	@Test
+	public void testWithDefaultMappingsNoAdd()
+	{
+		PrefixMapping pm = new PrefixMappingImpl();
+		try
+		{
+			// make sure that it must update
+			securedMapping.withDefaultMappings(pm);
+//			if (!securityEvaluator.evaluate(Action.Update,
+//					securedMapping.getModelNode()))
+//			{
+//				Assert.fail("Should have thrown AccessDenied Exception");
+//			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Update,
+					securedMapping.getModelNode()))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/SecuredPrefixMappingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/TDBGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/TDBGraphTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/TDBGraphTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/TDBGraphTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.graph;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
+import com.hp.hpl.jena.tdb.TDB;
+import com.hp.hpl.jena.tdb.TDBFactory;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.junit.After;
+
+public class TDBGraphTest extends MemGraphTest
+{
+
+	private DatasetGraph dsGraph;
+
+	private File f;
+
+	public TDBGraphTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		super(securityEvaluator);
+	}
+
+	@Override
+	protected Graph createGraph() throws IOException
+	{
+		TDB.init();
+		f = new File(System.getProperty("java.io.tmpdir") + "/TDBTest");
+		dsGraph = TDBFactory.createDatasetGraph(f.getCanonicalPath());
+		return dsGraph.getDefaultGraph();
+	}
+
+	@After
+	public void tearDown()
+	{
+		TDB.sync(dsGraph);
+		dsGraph.close();
+		f.delete();
+		TDB.closedown();
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/graph/TDBGraphTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredAltTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredAltTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredAltTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredAltTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,658 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.model;
+
+import com.hp.hpl.jena.rdf.model.Alt;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+import java.util.Set;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.model.SecuredAlt;
+import org.apache.jena.security.model.impl.SecuredAltImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class SecuredAltTest extends SecuredContainerTest
+{
+	private Alt alt;
+
+	public SecuredAltTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		super(securityEvaluator);
+	}
+
+	private SecuredAlt getSecuredAlt()
+	{
+		return (SecuredAlt) getSecuredRDFNode();
+	}
+
+	@Override
+	@Before
+	public void setup()
+	{
+		super.setup();
+		alt = baseModel.getAlt("http://example.com/testContainer");
+		setSecuredRDFNode(SecuredAltImpl.getInstance(securedModel, alt), alt);
+	}
+
+	/**
+	 * @sec.graph Read
+	 * @sec.triple Read SecTriple(this, RDF.li(1), o )
+	 * @throws AccessDeniedException
+	 */
+	@Test
+	public void testGetDefault()
+	{
+		alt.add("SomeDummyItem");
+		try
+		{
+			getSecuredAlt().getDefault();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredAlt().getDefaultAlt();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredAlt().getDefaultBag();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredAlt().getDefaultSeq();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultBoolean()
+	{
+		alt.add(true);
+		try
+		{
+			getSecuredAlt().getDefaultBoolean();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultByte()
+	{
+		alt.add(Byte.MAX_VALUE);
+		try
+		{
+			getSecuredAlt().getDefaultByte();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultChar()
+	{
+		alt.add('c');
+		try
+		{
+			getSecuredAlt().getDefaultChar();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultDouble()
+	{
+		alt.add(3.14d);
+		try
+		{
+			getSecuredAlt().getDefaultDouble();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultFloat()
+	{
+		alt.add(3.14f);
+		try
+		{
+			getSecuredAlt().getDefaultFloat();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultInt()
+	{
+		alt.add(2);
+		try
+		{
+			getSecuredAlt().getDefaultInt();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultLanguage()
+	{
+		alt.add("SomeDummyItem");
+		try
+		{
+			getSecuredAlt().getDefaultLanguage();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredAlt().getDefaultLiteral();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testGetDefaultLong()
+	{
+		alt.add(3L);
+
+		try
+		{
+			getSecuredAlt().getDefaultLong();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultResource()
+	{
+		alt.setDefault(ResourceFactory
+				.createResource("http://example.com/exampleResourec"));
+		try
+		{
+			getSecuredAlt().getDefaultResource();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	/*
+	 * try
+	 * {
+	 * ResourceF f = ResourceFactory.getInstance();
+	 * getSecuredAlt().getDefaultResource( f );
+	 * if (!securityEvaluator.evaluate(Action.Read))
+	 * {
+	 * Assert.fail("Should have thrown AccessDenied Exception");
+	 * }
+	 * }
+	 * catch (final AccessDeniedException e)
+	 * {
+	 * if (securityEvaluator.evaluate(Action.Read))
+	 * {
+	 * Assert.fail(String
+	 * .format("Should not have thrown AccessDenied Exception: %s - %s",
+	 * e, e.getTriple()));
+	 * }
+	 * }
+	 */
+
+	@Test
+	public void testGetDefaultShort()
+	{
+		alt.setDefault(Short.MAX_VALUE);
+		try
+		{
+			getSecuredAlt().getDefaultShort();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDefaultString()
+	{
+		alt.setDefault("Hello World");
+		try
+		{
+			getSecuredAlt().getDefaultString();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testSetDefaultBoolean()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault(true);
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultChar()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault('c');
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultDouble()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault(3.14d);
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultFloat()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault(3.14f);
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultLong()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault(2L);
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultObject()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			final Object o = Integer.valueOf(2);
+			getSecuredAlt().setDefault(o);
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultResource()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault(
+					ResourceFactory
+							.createResource("http://example.com/resource"));
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultString()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault("test");
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testSetDefaultStringAndLang()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredAlt().setDefault("dos", "es");
+			if (!securityEvaluator.evaluate(Action.Update) || (!securityEvaluator.evaluate(Action.Create) && !getSecuredAlt().iterator().hasNext() ))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredAltTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredBagTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredBagTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredBagTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredBagTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.model;
+
+import com.hp.hpl.jena.rdf.model.Bag;
+
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.model.impl.SecuredBagImpl;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class SecuredBagTest extends SecuredContainerTest
+{
+
+	public SecuredBagTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		super(securityEvaluator);
+	}
+
+	@Override
+	@Before
+	public void setup()
+	{
+		super.setup();
+		final Bag bag = baseModel.getBag("http://example.com/testContainer");
+		bag.add("SomeDummyItem");
+		setSecuredRDFNode(SecuredBagImpl.getInstance(securedModel, bag), bag);
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredBagTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredContainerTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredContainerTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredContainerTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredContainerTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,481 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.model;
+
+import com.hp.hpl.jena.rdf.model.Container;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.rdf.model.Statement;
+
+import java.util.Set;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.model.SecuredContainer;
+import org.apache.jena.security.model.impl.SecuredContainerImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public abstract class SecuredContainerTest extends SecuredResourceTest
+{
+
+	public SecuredContainerTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		super(securityEvaluator);
+	}
+
+	private SecuredContainer getSecuredContainer()
+	{
+		return (SecuredContainer) getSecuredRDFNode();
+	}
+
+	@Override
+	@Before
+	public void setup()
+	{
+		super.setup();
+		final Container container = baseModel
+				.getBag("http://example.com/testContainer");
+		container.add("SomeDummyItem");
+		setSecuredRDFNode(
+				SecuredContainerImpl.getInstance(securedModel, container),
+				container);
+	}
+
+	@Test
+	public void test()
+	{
+		try
+		{
+			getSecuredContainer().size();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	/**
+	 * @sec.graph Update
+	 * @sec.triple Create SecTriple( this, RDF.li, o );
+	 * @throws AccessDeniedException
+	 */
+	@Test
+	public void testAdd()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Create });
+		try
+		{
+			getSecuredContainer().add(true);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add('c');
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add(3.14D);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add(3.14F);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add(2L);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		final Object o = Integer.valueOf("1234");
+		try
+		{
+			getSecuredContainer().add(o);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add(
+					ResourceFactory
+							.createResource("http://example.com/testResource"));
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add("foo");
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().add("dos", "esp");
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+	@Test
+	public void testContains()
+	{
+		try
+		{
+			getSecuredContainer().contains(true);
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains('c');
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains(3.14D);
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains(3.14F);
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains(2L);
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		final Object o = Integer.valueOf("1234");
+		try
+		{
+			getSecuredContainer().contains(o);
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains(
+					ResourceFactory
+							.createResource("http://example.com/testResource"));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains("foo");
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+		try
+		{
+			getSecuredContainer().contains("dos", "esp");
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testIterator()
+	{
+		try
+		{
+			getSecuredContainer().iterator();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testRemove()
+	{
+		final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] {
+				Action.Update, Action.Delete });
+		final Statement s = baseModel.listStatements().next();
+		try
+		{
+			getSecuredContainer().remove(s);
+			if (!securityEvaluator.evaluate(perms))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(perms))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+
+	}
+
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredContainerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredLiteralTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredLiteralTest.java?rev=1509448&view=auto
==============================================================================
--- jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredLiteralTest.java (added)
+++ jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredLiteralTest.java Thu Aug  1 21:53:43 2013
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.model;
+
+import com.hp.hpl.jena.datatypes.DatatypeFormatException;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.rdf.model.ResourceRequiredException;
+
+import org.apache.jena.security.AccessDeniedException;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluatorParameters;
+import org.apache.jena.security.SecurityEvaluator.Action;
+import org.apache.jena.security.model.SecuredLiteral;
+import org.apache.jena.security.model.impl.SecuredLiteralImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class SecuredLiteralTest extends SecuredRDFNodeTest
+{
+
+	public SecuredLiteralTest( final MockSecurityEvaluator securityEvaluator )
+	{
+		super(securityEvaluator);
+	}
+
+	private SecuredLiteral getSecuredLiteral()
+	{
+		return (SecuredLiteral) getSecuredRDFNode();
+	}
+
+	@Test
+	public void sameValueAs()
+	{
+		try
+		{
+			getSecuredLiteral().sameValueAs(
+					ResourceFactory.createPlainLiteral("Junk"));
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Override
+	@Before
+	public void setup()
+	{
+		super.setup();
+		Literal l = ResourceFactory.createTypedLiteral("literal");
+		setSecuredRDFNode(SecuredLiteralImpl.getInstance(securedModel, l), l);
+	}
+
+	@Test
+	public void testAsLiteral()
+	{
+		getSecuredLiteral().asLiteral();
+	}
+
+	@Test
+	public void testAsResource()
+	{
+		try
+		{
+			getSecuredLiteral().asResource();
+			Assert.fail("Should have thrown ResoruceRequiredException");
+		}
+		catch (final ResourceRequiredException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetBoolean()
+	{
+		try
+		{
+			getSecuredLiteral().getBoolean();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetByte()
+	{
+		try
+		{
+			getSecuredLiteral().getByte();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetChar()
+	{
+		try
+		{
+			getSecuredLiteral().getChar();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetDatatype()
+	{
+		try
+		{
+			getSecuredLiteral().getDatatype();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDatatypeURI()
+	{
+		try
+		{
+			getSecuredLiteral().getDatatypeURI();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetDouble()
+	{
+		try
+		{
+			getSecuredLiteral().getDouble();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+
+	}
+
+	@Test
+	public void testGetFloat()
+	{
+		try
+		{
+			getSecuredLiteral().getFloat();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetInt()
+	{
+		try
+		{
+			getSecuredLiteral().getInt();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetLanguage()
+	{
+		try
+		{
+			getSecuredLiteral().getLanguage();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetLexicalForm()
+	{
+		try
+		{
+			getSecuredLiteral().getLexicalForm();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testGetLong()
+	{
+		try
+		{
+			getSecuredLiteral().getLong();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetShort()
+	{
+		try
+		{
+			getSecuredLiteral().getShort();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetString()
+	{
+		try
+		{
+			getSecuredLiteral().getString();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+		catch (final DatatypeFormatException e)
+		{
+			// expected
+		}
+	}
+
+	@Test
+	public void testGetValue()
+	{
+		try
+		{
+			getSecuredLiteral().getValue();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+
+	@Test
+	public void testIsWellFormedXML()
+	{
+		try
+		{
+			getSecuredLiteral().isWellFormedXML();
+			if (!securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail("Should have thrown AccessDenied Exception");
+			}
+		}
+		catch (final AccessDeniedException e)
+		{
+			if (securityEvaluator.evaluate(Action.Read))
+			{
+				Assert.fail(String
+						.format("Should not have thrown AccessDenied Exception: %s - %s",
+								e, e.getTriple()));
+			}
+		}
+	}
+}

Propchange: jena/Experimental/jena-security/src/test/java/org/apache/jena/security/model/SecuredLiteralTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain