http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
new file mode 100644
index 0000000..db6b55d
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/SecuredAssemblerTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.permissions;
+
+import java.net.URL;
+
+import org.junit.Assert;
+import org.apache.jena.assembler.Assembler ;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.model.SecuredModel;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.rdf.model.Resource ;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SecuredAssemblerTest
+{
+    private Assembler assembler;
+       private Model model;
+       
+       public SecuredAssemblerTest() 
+       {
+               assembler = Assembler.general;
+       }
+       
+       @Before
+       public void setUp() throws Exception {
+               model = ModelFactory.createDefaultModel();
+               URL url = 
SecuredAssemblerTest.class.getClassLoader().getResource( 
SecuredAssemblerTest.class.getName().replace(".", "/")+".ttl");
+               model.read( url.toURI().toString(), "TURTLE" );
+               //model.write( System.out, "TURTLE" );
+       }
+       
+       @Test
+       public void testCreation() throws Exception {
+               
+               Resource r = model.createResource( 
"http://apache.org/jena/permissions/test#secModel";);
+               Object o = assembler.open( r );
+               Assert.assertTrue( o instanceof Model);
+               Assert.assertTrue( o instanceof SecuredModel );
+       }
+
+       @Test
+       public void testCreationWithArgs() throws Exception {
+               
+               Resource r = model.createResource( 
"http://apache.org/jena/permissions/test#secModel2";);
+               Object o = assembler.open( r );
+               Assert.assertTrue( o instanceof Model);
+               Assert.assertTrue( o instanceof SecuredModel );
+       }
+       
+       @Test
+       public void testSecurityEvaluatorWithStringArgs() throws Exception {
+               
+               Resource r = model.createResource( 
"http://apache.org/jena/permissions/test#secEvaluator";);
+               Object o = assembler.open( r );
+               Assert.assertTrue( o instanceof SecurityEvaluator );
+               Assert.assertTrue( o instanceof StaticSecurityEvaluator );
+       }
+       
+       @Test
+       public void testSecurityEvaluatorWithModelArgs() throws Exception {
+               
+               Resource r = model.createResource( 
"http://apache.org/jena/permissions/test#secEvaluator2";);
+               Object o = assembler.open( r );
+               Assert.assertTrue( o instanceof SecurityEvaluator );
+               Assert.assertTrue( o instanceof ModelBasedSecurityEvaluator );
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/SecurityEvaluatorParameters.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/SecurityEvaluatorParameters.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/SecurityEvaluatorParameters.java
new file mode 100644
index 0000000..86872c0
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/SecurityEvaluatorParameters.java
@@ -0,0 +1,135 @@
+/*
+ * 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.permissions;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.Suite;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
+public class SecurityEvaluatorParameters extends Suite
+{
+
+       private class TestClassRunnerForParameters extends 
BlockJUnit4ClassRunner
+       {
+               private final int fParameterSetNumber;
+
+               private final List<Object[]> fParameterList;
+
+               TestClassRunnerForParameters( final Class<?> type,
+                               final List<Object[]> parameterList, final int i 
)
+                               throws InitializationError
+               {
+                       super(type);
+                       fParameterList = parameterList;
+                       fParameterSetNumber = i;
+               }
+
+               @Override
+               protected Statement classBlock( final RunNotifier notifier )
+               {
+                       return childrenInvoker(notifier);
+               }
+
+               @Override
+               public Object createTest() throws Exception
+               {
+                       return getTestClass().getOnlyConstructor().newInstance(
+                                       
fParameterList.get(fParameterSetNumber));
+               }
+
+               @Override
+               protected String getName()
+               {
+                       return String.format("[%s]", fParameterSetNumber);
+               }
+
+               @Override
+               protected Annotation[] getRunnerAnnotations()
+               {
+                       return new Annotation[0];
+               }
+
+               @Override
+               protected String testName( final FrameworkMethod method )
+               {
+                       return String.format("%s[%s]", method.getName(),
+                                       
fParameterList.get(fParameterSetNumber)[0]);
+               }
+
+               @Override
+               protected void validateConstructor( final List<Throwable> 
errors )
+               {
+                       validateOnlyOneConstructor(errors);
+               }
+       }
+
+       private final ArrayList<Runner> runners = new ArrayList<Runner>();
+
+       /**
+        * Only called reflectively. Do not use programmatically.
+        */
+       public SecurityEvaluatorParameters( final Class<?> klass ) throws 
Throwable
+       {
+               super(klass, Collections.<Runner> emptyList());
+               final List<Object[]> parametersList = new ArrayList<Object[]>();
+
+               final boolean[] bSet = { true, false };
+
+               for (final boolean create : bSet)
+               {
+                       for (final boolean read : bSet)
+                       {
+                               for (final boolean update : bSet)
+                               {
+                                       for (final boolean delete : bSet)
+                                       {
+                                               for (final boolean 
forceTripleCheck : bSet)
+                                               {
+                                                       parametersList
+                                                                       
.add(new Object[] { new MockSecurityEvaluator(
+                                                                               
        true, create, read, update, delete,
+                                                                               
        forceTripleCheck) });
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               for (int i = 0; i < parametersList.size(); i++)
+               {
+                       runners.add(new 
TestClassRunnerForParameters(getTestClass()
+                                       .getJavaClass(), parametersList, i));
+               }
+       }
+
+       @Override
+       protected List<Runner> getChildren()
+       {
+               return runners;
+       }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/StaticSecurityEvaluator.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/StaticSecurityEvaluator.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/StaticSecurityEvaluator.java
new file mode 100644
index 0000000..54ee9ef
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/StaticSecurityEvaluator.java
@@ -0,0 +1,80 @@
+/*
+ * 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.permissions;
+
+import java.util.Set;
+
+import org.apache.jena.permissions.SecurityEvaluator;
+
+public class StaticSecurityEvaluator implements SecurityEvaluator {
+
+       private String user;
+       
+       public StaticSecurityEvaluator( String user) {
+               this.user = user;
+       }
+       
+       public void setUser( String user )
+       {
+               this.user = user;
+       }
+
+       @Override
+       public boolean evaluate(final Object principal, Action action, SecNode 
graphIRI) {
+               return true;
+       }
+
+       @Override
+       public boolean evaluate(final Object principal, Action action, SecNode 
graphIRI, SecTriple triple) {
+               return triple.getSubject().getValue().equals( "urn:"+principal 
);
+       }
+
+       @Override
+       public boolean evaluate(final Object principal, Set<Action> actions, 
SecNode graphIRI) {
+               return true;
+       }
+
+       @Override
+       public boolean evaluate(final Object principal, Set<Action> actions, 
SecNode graphIRI,
+                       SecTriple triple) {
+               return triple.getSubject().getValue().equals( "urn:"+principal 
);
+       }
+
+       @Override
+       public boolean evaluateAny(final Object principal, Set<Action> actions, 
SecNode graphIRI) {
+               return true;
+       }
+
+       @Override
+       public boolean evaluateAny(final Object principal, Set<Action> actions, 
SecNode graphIRI,
+                       SecTriple triple) {
+               return triple.getSubject().getValue().equals( "urn:"+principal 
);
+       }
+
+       @Override
+       public boolean evaluateUpdate(final Object principal, SecNode graphIRI, 
SecTriple from, SecTriple to) {
+               return from.getSubject().getValue().equals( "urn:"+principal ) 
&& 
+                               to.getSubject().getValue().equals( 
"urn:"+principal );
+       }
+
+       @Override
+       public Object getPrincipal() {
+               return user;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/CachedSecurityEvaluatorTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/CachedSecurityEvaluatorTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/CachedSecurityEvaluatorTest.java
new file mode 100644
index 0000000..688ffd4
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/CachedSecurityEvaluatorTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.permissions.contract.graph;
+
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.StaticSecurityEvaluator;
+import org.apache.jena.permissions.impl.CachedSecurityEvaluator;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class CachedSecurityEvaluatorTest {
+
+       private StaticSecurityEvaluator securityEvaluator;
+       private SecurityEvaluator cachedEvaluator;
+       
+       public CachedSecurityEvaluatorTest() {
+               securityEvaluator = new StaticSecurityEvaluator( "bob" );
+               cachedEvaluator = new CachedSecurityEvaluator( 
securityEvaluator, "ted" );
+               
+       }
+       
+       @Test
+       public void testGetPrincipal()
+       {
+               assertEquals( "bob", securityEvaluator.getPrincipal());
+               assertEquals( "ted", cachedEvaluator.getPrincipal());
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphContractTests.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphContractTests.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphContractTests.java
new file mode 100644
index 0000000..714e1e4
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphContractTests.java
@@ -0,0 +1,51 @@
+/*
+ * 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.permissions.contract.graph;
+
+import org.apache.jena.graph.Factory ;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.test.MetaTestGraph ;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+
+public class SecuredGraphContractTests extends MetaTestGraph
+{
+
+       private final SecurityEvaluator eval;
+
+       public SecuredGraphContractTests( final Class<? extends Graph> 
graphClass,
+                       final String name )
+       {
+               super(graphClass, name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       public SecuredGraphContractTests( final String name )
+       {
+               super(name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       @Override
+       public Graph getGraph()
+       {
+               return org.apache.jena.permissions.Factory.getInstance(eval, 
getName(),
+                               Factory.createDefaultGraph());
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphListenerTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphListenerTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphListenerTest.java
new file mode 100644
index 0000000..ebdbf1c
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredGraphListenerTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.permissions.contract.graph;
+
+import org.apache.jena.graph.Factory ;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.test.TestGraphListener ;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+
+public class SecuredGraphListenerTest extends TestGraphListener
+{
+       private final SecurityEvaluator eval;
+
+       public SecuredGraphListenerTest( final Class<? extends Graph> 
graphClass,
+                       final String name )
+       {
+               super(graphClass, name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       public SecuredGraphListenerTest( final String name )
+       {
+               super(name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       @Override
+       public Graph getGraph()
+       {
+               final Graph graph = 
org.apache.jena.permissions.Factory.getInstance(eval,
+                               getName(), Factory.createDefaultGraph());
+               graph.getEventManager().register(new CheckChanges("simple 
tracking", graph));
+               return graph;
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredTDBGraphContractTests.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredTDBGraphContractTests.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredTDBGraphContractTests.java
new file mode 100644
index 0000000..361222f
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/graph/SecuredTDBGraphContractTests.java
@@ -0,0 +1,51 @@
+/*
+ * 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.permissions.contract.graph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.test.MetaTestGraph ;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.tdb.TDBFactory ;
+
+public class SecuredTDBGraphContractTests extends MetaTestGraph
+{
+
+       private final SecurityEvaluator eval;
+
+       public SecuredTDBGraphContractTests( final Class<? extends Graph> 
graphClass,
+                       final String name )
+       {
+               super(graphClass, name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       public SecuredTDBGraphContractTests( final String name )
+       {
+               super(name);
+               eval = new MockSecurityEvaluator(true, true, true, true, true, 
true);
+       }
+
+       @Override
+       public Graph getGraph()
+       {
+               return org.apache.jena.permissions.Factory.getInstance(eval, 
getName(),
+                               
TDBFactory.createDatasetGraph().getDefaultGraph());
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/ModelTestSuite.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/ModelTestSuite.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/ModelTestSuite.java
new file mode 100644
index 0000000..5e89a98
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/ModelTestSuite.java
@@ -0,0 +1,132 @@
+/*
+ * 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.permissions.contract.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import junit.framework.Test;
+
+
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
+
+
+public class ModelTestSuite extends ParentRunner<Test>
+{
+       private SecTestPackage pkg;
+       
+       public ModelTestSuite( Class<?> testClass ) throws Exception
+       {
+               super( Test.class );
+               pkg = new SecTestPackage();
+       }
+
+       @Override
+       protected List<Test> getChildren()
+       {
+               List<Test> lst = new ArrayList<Test>();
+               Enumeration<Test> enm = pkg.tests();
+               while (enm.hasMoreElements())
+               {
+                       lst.add( enm.nextElement() );
+               }
+               return lst;
+       }
+
+       @Override
+       protected Description describeChild( Test child )
+       {
+               return Description.createTestDescription( child.getClass(), 
child.toString() );
+       }
+
+       @Override
+       protected void runChild( Test child, RunNotifier notifier )
+       {
+               Method setUp = null;
+               try
+               {
+                       setUp = child.getClass().getMethod("setUp" );
+               }
+               catch (SecurityException e1)
+               {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+                       throw new RuntimeException( e1 );
+               }
+               catch (NoSuchMethodException e1)
+               {
+               }
+               Method tearDown = null;
+               try
+               {
+                       tearDown = child.getClass().getMethod("tearDown" );
+               }
+               catch (SecurityException e1)
+               {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+                       throw new RuntimeException( e1 );
+               }
+               catch (NoSuchMethodException e1)
+               {
+               }
+               for (Method m : child.getClass().getMethods())
+               {
+                       if (m.getName().startsWith( "test" ) && 
m.getParameterTypes().length == 0)
+                       {
+                               Description desc = 
Description.createTestDescription( child.getClass(), child.toString() );
+                               notifier.fireTestStarted( desc );
+                               try
+                               {
+                                       if (setUp != null)
+                                       {
+                                               setUp.invoke(child);
+                                       }
+                                       m.invoke(child);
+                                       if (tearDown != null)
+                                       {
+                                               tearDown.invoke( child );
+                                       }
+                                       notifier.fireTestFinished( desc );
+                               }
+                               catch (IllegalArgumentException e)
+                               {
+                                       notifier.fireTestFailure( new 
Failure(desc, e));
+                               }
+                               catch (IllegalAccessException e)
+                               {
+                                       notifier.fireTestFailure( new 
Failure(desc, e));
+                               }
+                               catch (InvocationTargetException e)
+                               {
+                                       notifier.fireTestFailure( new 
Failure(desc, e.getTargetException()));
+                               }
+                               catch (RuntimeException e) {
+                                       notifier.fireTestFailure( new 
Failure(desc, e));
+                                       throw e;
+                               }
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestLiterals.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestLiterals.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestLiterals.java
new file mode 100644
index 0000000..f375bbd
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestLiterals.java
@@ -0,0 +1,29 @@
+/*
+ * 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.permissions.contract.model;
+
+import org.apache.jena.rdf.model.test.TestLiterals ;
+import org.apache.jena.rdf.model.test.TestPackage ;
+
+public class SecTestLiterals extends TestLiterals {
+
+       public SecTestLiterals() {
+               super(new TestPackage.PlainModelFactory(), "SecTestLiterals");
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestPackage.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestPackage.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestPackage.java
new file mode 100644
index 0000000..a69ebc5
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestPackage.java
@@ -0,0 +1,121 @@
+/*
+ * 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.permissions.contract.model;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestSuite;
+
+import org.apache.jena.atlas.web.TypedInputStream;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.rdf.model.test.AbstractTestPackage ;
+import org.apache.jena.rdf.model.test.helpers.TestingModelFactory ;
+import org.apache.jena.riot.system.stream.Locator;
+import org.apache.jena.riot.system.stream.StreamManager;
+import org.apache.jena.riot.system.stream.LocatorZip;
+import org.apache.jena.shared.PrefixMapping ;
+import org.apache.jena.util.FileUtils ;
+
+/**
+ * Test package to test Model implementation.
+ */
+//@RunWith(ModelTestSuite.class)
+public class SecTestPackage extends AbstractTestPackage
+{
+       static public TestSuite suite() throws SecurityException, 
IllegalArgumentException, NoSuchMethodException, InstantiationException, 
IllegalAccessException, InvocationTargetException
+       {
+               return new SecTestPackage();
+       }
+       
+       public SecTestPackage() throws SecurityException, 
IllegalArgumentException, NoSuchMethodException, InstantiationException, 
IllegalAccessException, InvocationTargetException
+       {
+               super("SecuredModel", new PlainModelFactory() );
+               // register a jar reader here
+               StreamManager sm =StreamManager.get();
+               sm.addLocator( new LocatorJarURL()  );
+       }
+
+       /* package private */static class PlainModelFactory implements 
TestingModelFactory
+       {
+               private final SecurityEvaluator eval;
+               
+               public PlainModelFactory()
+               {
+                       eval = new MockSecurityEvaluator(true, true, true, 
true, true, true);
+               }
+               
+               @Override
+               public Model createModel()
+               {
+                       // Graph graph = Factory.createDefaultGraph( style );
+                       final Model model = ModelFactory.createDefaultModel();
+                       return 
org.apache.jena.permissions.Factory.getInstance(eval, "testModel",
+                                       model);
+               }
+               
+               @Override
+               public PrefixMapping getPrefixMapping()
+               {
+                       return createModel().getGraph().getPrefixMapping();
+               }
+               
+               @Override
+               public Model createModel( Graph base )
+               {
+                       return ModelFactory.createModelForGraph(base);
+               }
+       }
+       
+       public static class LocatorJarURL implements Locator {
+
+               @Override
+               public TypedInputStream open(String uri) {
+                        String uriSchemeName = FileUtils.getScheme(uri) ;
+                        if ( ! "jar".equalsIgnoreCase(uriSchemeName))
+                        {
+                                return null;
+                        }
+                        
+                        String[] parts = uri.substring( 4 ).split("!");
+                        if (parts.length != 2)
+                        {
+                                return null;
+                        } 
+                        if (parts[0].toLowerCase().startsWith("file:"))
+                        {
+                                parts[0] = parts[0].substring( 5 );
+                        }
+                        if (parts[1].startsWith( "/"))
+                        {
+                                parts[1] = parts[1].substring(1);
+                        }
+                        LocatorZip zl = new LocatorZip( parts[0] );
+                        return zl.open(parts[1] );
+               }
+
+               @Override
+               public String getName() {
+                       return "JarURLLocator";
+               }
+               
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaderEvents.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaderEvents.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaderEvents.java
new file mode 100644
index 0000000..f6bb7be
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaderEvents.java
@@ -0,0 +1,28 @@
+/*
+ * 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.permissions.contract.model;
+
+import org.apache.jena.rdf.model.test.TestPackage ;
+
+public class SecTestReaderEvents extends 
org.apache.jena.rdf.model.test.TestReaderEvents {
+
+       public SecTestReaderEvents() {
+               super( new TestPackage.PlainModelFactory(), 
"SecTestReaderEvents" );
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaders.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaders.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaders.java
new file mode 100644
index 0000000..a04e446
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/contract/model/SecTestReaders.java
@@ -0,0 +1,28 @@
+/*
+ * 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.permissions.contract.model;
+
+import org.apache.jena.rdf.model.test.TestPackage ;
+
+public class SecTestReaders extends org.apache.jena.rdf.model.test.TestReaders 
{
+
+       public SecTestReaders() {
+               super( new TestPackage.PlainModelFactory(), "SecTestReaders" );
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
new file mode 100644
index 0000000..e3544e0
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/CrossIDGraphEventManagerTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.permissions.graph;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.GraphEventManager ;
+import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.permissions.Factory;
+import org.apache.jena.permissions.StaticSecurityEvaluator;
+import org.apache.jena.permissions.graph.SecuredGraph;
+import org.apache.jena.sparql.graph.GraphFactory ;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CrossIDGraphEventManagerTest {
+
+       private final GraphEventManager manager;
+       private final Graph g;
+       private final SecuredGraph sg;
+       private final StaticSecurityEvaluator securityEvaluator;
+
+       private final RecordingGraphListener annListener;
+       private final RecordingGraphListener bobListener;
+
+       public CrossIDGraphEventManagerTest() {
+               this.securityEvaluator = new StaticSecurityEvaluator("ann");
+
+               g = GraphFactory.createDefaultGraph();
+               g.add(new Triple(NodeFactory.createURI("urn:ann"), NodeFactory
+                               .createURI("http://example.com/v";), 
NodeFactory.createAnon()));
+               g.add(new Triple(NodeFactory.createURI("urn:bob"), NodeFactory
+                               .createURI("http://example.com/v";), 
NodeFactory.createAnon()));
+               g.add(new Triple(NodeFactory.createURI("urn:ann"), NodeFactory
+                               .createURI("http://example.com/v2";), 
NodeFactory.createAnon()));
+
+               sg = Factory.getInstance(securityEvaluator,
+                               "http://example.com/testGraph";, g);
+               manager = sg.getEventManager();
+               annListener = new RecordingGraphListener();
+               manager.register(annListener);
+               this.securityEvaluator.setUser("bob");
+               bobListener = new RecordingGraphListener();
+               manager.register(bobListener);
+       }
+
+       @Test
+       public void notificationsTest() {
+               sg.add(new Triple(NodeFactory.createURI("urn:bob"), NodeFactory
+                               .createURI("http://example.com/v2";), 
NodeFactory.createAnon()));
+
+               Assert.assertTrue("Should recorded add", bobListener.isAdd());
+               Assert.assertFalse("Should not have recorded add", 
annListener.isAdd());
+
+               sg.delete(new Triple(NodeFactory.createURI("urn:bob"), 
NodeFactory
+                               .createURI("http://example.com/v2";), 
NodeFactory.createAnon()));
+
+               Assert.assertTrue("Should recorded delete", 
bobListener.isDelete());
+               Assert.assertFalse("Should not have recorded delete",
+                               annListener.isDelete());
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
new file mode 100644
index 0000000..4a99c5c
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/GraphEventManagerTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.permissions.graph;
+
+import java.util.Arrays;
+import java.util.Set;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.GraphEventManager ;
+import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.impl.CollectionGraph ;
+import org.apache.jena.permissions.Factory;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluatorParameters;
+import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.graph.SecuredGraph;
+import org.apache.jena.sparql.graph.GraphFactory ;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Verifies that messages are properly filtered when sent to listeners.
+ *
+ */
+@RunWith( value = SecurityEvaluatorParameters.class )
+public class GraphEventManagerTest
+{
+       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
+       @SuppressWarnings("deprecation")
+       public void notifyAddTest()
+       {
+               Object principal = securityEvaluator.getPrincipal();
+               final Set<Action> ADD = SecurityEvaluator.Util.asSet(new 
Action[] {
+                               Action.Create, Action.Read });
+               g.add(tripleArray[0]);
+               if (securityEvaluator.evaluateAny(principal, 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();
+
+       }
+
+       @SuppressWarnings("deprecation")
+    @Test
+       public void notifyDeleteTest()
+       {
+               Object principal = securityEvaluator.getPrincipal();
+               final Set<Action> DELETE = SecurityEvaluator.Util.asSet(new 
Action[] {
+                               Action.Delete, Action.Read });
+               g.delete(tripleArray[0]);
+               if (securityEvaluator.evaluateAny(principal, DELETE, 
sg.getModelNode()))
+               {
+                       Assert.assertTrue("Should have 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()) };
+
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
new file mode 100644
index 0000000..bc086b4
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/MemGraphTest.java
@@ -0,0 +1,313 @@
+/*
+ * 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.permissions.graph;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.jena.graph.* ;
+import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.EqualityTester;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluatorParameters;
+import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.graph.SecuredGraph;
+import org.apache.jena.sparql.graph.GraphFactory ;
+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();
+       }
+
+       @SuppressWarnings("deprecation")
+    @Before
+       public void setUp() throws Exception
+       {
+               baseGraph = createGraph();
+               baseGraph.remove(Node.ANY, Node.ANY, Node.ANY);
+               securedGraph = org.apache.jena.permissions.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 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.permissions.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()));
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
new file mode 100644
index 0000000..5a75461
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/RecordingGraphListener.java
@@ -0,0 +1,124 @@
+package org.apache.jena.permissions.graph;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.graph.GraphListener ;
+import org.apache.jena.graph.Triple ;
+
+/*
+ * 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.
+ */
+
+public 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;
+       }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
new file mode 100644
index 0000000..e4d55ba
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/SecuredPrefixMappingTest.java
@@ -0,0 +1,440 @@
+/*
+ * 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.permissions.graph;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.Factory;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluatorParameters;
+import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.graph.SecuredGraph;
+import org.apache.jena.permissions.graph.SecuredPrefixMapping;
+import org.apache.jena.shared.PrefixMapping ;
+import org.apache.jena.shared.impl.PrefixMappingImpl ;
+import org.apache.jena.sparql.graph.GraphFactory ;
+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("testLock"))
+                               {
+                                       lockTest = m;
+                               }
+                               else
+                               {
+                                       pmTest.setup();
+                                       m.invoke(pmTest);
+                               }
+
+                       }
+               }
+               Assert.assertNotNull( "Did not find 'testLock' method", 
lockTest );             
+               pmTest.setup();
+               lockTest.invoke(pmTest);
+
+       }
+
+       private final SecurityEvaluator securityEvaluator;
+       private final Object principal;
+
+       protected SecuredPrefixMapping securedMapping;
+
+       public SecuredPrefixMappingTest( final SecurityEvaluator 
securityEvaluator )
+       {
+               this.securityEvaluator = securityEvaluator;
+               this.principal = securityEvaluator.getPrincipal();
+       }
+
+       @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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Read,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, 
Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail("Should have thrown AccessDenied 
Exception");
+                       }
+               }
+               catch (final AccessDeniedException e)
+               {
+                       if (securityEvaluator.evaluate(principal, 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(principal, Action.Update,
+                                       securedMapping.getModelNode()))
+                       {
+                               Assert.fail(String
+                                               .format("Should not have thrown 
AccessDenied Exception: %s - %s",
+                                                               e, 
e.getTriple()));
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
new file mode 100644
index 0000000..18be198
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/graph/TDBGraphTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.permissions.graph;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.tdb.TDB ;
+import org.apache.jena.tdb.TDBFactory ;
+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();
+               dsGraph = TDBFactory.createDataset().asDatasetGraph();
+               return dsGraph.getDefaultGraph();
+       }
+
+       @After
+       public void tearDown()
+       {
+               TDB.sync(dsGraph);
+               dsGraph.close();
+               TDB.closedown();
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
new file mode 100644
index 0000000..fd4331f
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredAltTest.java
@@ -0,0 +1,657 @@
+/*
+ * 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.permissions.model;
+
+import java.util.Set;
+
+import org.apache.jena.permissions.AccessDeniedException;
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluatorParameters;
+import org.apache.jena.permissions.SecurityEvaluator.Action;
+import org.apache.jena.permissions.model.SecuredAlt;
+import org.apache.jena.permissions.model.impl.SecuredAltImpl;
+import org.apache.jena.rdf.model.Alt ;
+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 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 = 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()));
+                       }
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/c4b0113d/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
----------------------------------------------------------------------
diff --git 
a/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
 
b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
new file mode 100644
index 0000000..33c1fb0
--- /dev/null
+++ 
b/jena-permissions/src/test/java/org/apache/jena/permissions/model/SecuredBagTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.permissions.model;
+
+import org.apache.jena.permissions.MockSecurityEvaluator;
+import org.apache.jena.permissions.SecurityEvaluatorParameters;
+import org.apache.jena.permissions.model.impl.SecuredBagImpl;
+import org.apache.jena.rdf.model.Bag ;
+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);
+       }
+
+}

Reply via email to