Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/ModelTestSuite.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/ModelTestSuite.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/ModelTestSuite.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/ModelTestSuite.java
 Thu Aug  1 21:47:45 2013
@@ -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.security.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;
+                               }
+                       }
+               }
+       }
+}

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

Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestLiterals.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestLiterals.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestLiterals.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestLiterals.java
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.contract.model;
+
+import com.hp.hpl.jena.rdf.model.test.TestLiterals;
+import com.hp.hpl.jena.rdf.model.test.TestPackage;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+
+public class SecTestLiterals extends TestLiterals {
+
+       public SecTestLiterals() {
+               super(new TestPackage.PlainModelFactory(), "SecTestLiterals");
+       }
+
+}

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

Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestPackage.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestPackage.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestPackage.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestPackage.java
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.contract.model;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.test.AbstractTestPackage;
+import com.hp.hpl.jena.rdf.model.test.helpers.TestingModelFactory;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.util.FileUtils;
+
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestSuite;
+
+import org.apache.jena.atlas.web.TypedInputStream;
+import org.apache.jena.riot.stream.Locator;
+import org.apache.jena.riot.stream.StreamManager;
+import org.apache.jena.riot.stream.LocatorZip;
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+
+import org.junit.runner.RunWith;
+
+/**
+ * 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.security.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";
+               }
+               
+       }
+}

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

Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaderEvents.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaderEvents.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaderEvents.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaderEvents.java
 Thu Aug  1 21:47:45 2013
@@ -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.security.contract.model;
+
+import com.hp.hpl.jena.rdf.model.test.TestPackage;
+
+public class SecTestReaderEvents extends 
com.hp.hpl.jena.rdf.model.test.TestReaderEvents {
+
+       public SecTestReaderEvents() {
+               super( new TestPackage.PlainModelFactory(), 
"SecTestReaderEvents" );
+       }
+
+}

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

Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaders.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaders.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaders.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/contract/model/SecTestReaders.java
 Thu Aug  1 21:47:45 2013
@@ -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.security.contract.model;
+
+import com.hp.hpl.jena.rdf.model.test.TestPackage;
+
+public class SecTestReaders extends com.hp.hpl.jena.rdf.model.test.TestReaders 
{
+
+       public SecTestReaders() {
+               super( new TestPackage.PlainModelFactory(), "SecTestReaders" );
+       }
+
+}

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

Added: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/query/rewriter/OpRewriterTest.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/java/org/apache/jena/security/query/rewriter/OpRewriterTest.java?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/query/rewriter/OpRewriterTest.java
 (added)
+++ 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/query/rewriter/OpRewriterTest.java
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.security.query.rewriter;
+
+import com.hp.hpl.jena.graph.NodeFactory;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
+import com.hp.hpl.jena.sparql.core.BasicPattern;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+import java.util.Arrays;
+
+import org.apache.jena.security.MockSecurityEvaluator;
+import org.apache.jena.security.SecurityEvaluator;
+import org.apache.jena.security.query.rewriter.OpRewriter;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OpRewriterTest
+{
+       private OpRewriter rewriter;
+       private SecurityEvaluator securityEvaluator = new 
MockSecurityEvaluator( true, true, true, true, true, true );
+       
+       public OpRewriterTest()
+       {
+       }
+       
+       @Before
+       public void setUp()
+       {
+               rewriter = new OpRewriter( securityEvaluator, 
"http://example.com/dummy";);
+       }
+       
+       @Test
+       public void testBGP()
+       {
+               Triple[] triples = {
+                               new Triple( NodeFactory.createVariable("foo"), 
RDF.type.asNode(), NodeFactory.createURI( "http://example.com/class";)),
+                               new Triple( NodeFactory.createVariable("foo"), 
NodeFactory.createAnon(), NodeFactory.createVariable("bar")),
+                               new Triple( NodeFactory.createVariable("bar"), 
NodeFactory.createAnon(), NodeFactory.createVariable("baz")),
+               };
+               rewriter.visit( new OpBGP( 
BasicPattern.wrap(Arrays.asList(triples))));
+               System.out.println( rewriter.getResult());
+       }
+
+}

Propchange: 
jena/Experimental/jena-security/src/test/java/org/apache/jena/security/query/rewriter/OpRewriterTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/detail.ttl
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/detail.ttl?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/detail.ttl
 (added)
+++ 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/detail.ttl
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,33 @@
+@prefix ex: <http://example.com/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+ex:msg1 rdf:type ex:msg; 
+       ex:to "bob";
+       ex:from "alice" ;
+       ex:subj "alice to bob 1";
+       .
+
+ex:msg2  rdf:type ex:msg; 
+       ex:to "alice";
+       ex:from "bob";
+       ex:subj "bob to alice 1";
+       .
+       
+ex:msg3  rdf:type ex:msg; 
+       ex:to "chuck" ;
+       ex:from "alice";
+       ex:subj "alice to chuck 1";
+       .
+       
+ex:msg4  rdf:type ex:msg; 
+       ex:to "darla" ;
+       ex:from "bob" ;
+       ex:subj "bob to darla 1"
+       .
+
+ex:msg5  rdf:type ex:msg; 
+       ex:to "alice";
+       ex:from "bob";
+       ex:subj "bob to alice 2";
+       .
+       
\ No newline at end of file

Added: 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.ttl
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.ttl?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.ttl
 (added)
+++ 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.ttl
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,2 @@
+@prefix rt: <http://example.com/readTest#> .
+rt:1 a rt:3 .
\ No newline at end of file

Added: 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.xml
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.xml?rev=1509440&view=auto
==============================================================================
--- 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.xml
 (added)
+++ 
jena/Experimental/jena-security/src/test/resources/org/apache/jena/security/model/test.xml
 Thu Aug  1 21:47:45 2013
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+       xmlns:rt="http://example.com/readTest#"; 
xmlns:j.0="http://example.com/readTest#3";>
+       <rdf:Description rdf:about="http://example.com/readTest#1";>
+               <rdf:type rdf:resource="http://example.com/readTest#3"; />
+       </rdf:Description>
+</rdf:RDF>

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


Reply via email to