You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2013/09/08 10:33:32 UTC

svn commit: r1520844 - in /jena/Experimental/new-test/src: main/ main/java/ test/java/com/hp/hpl/jena/graph/ test/java/com/hp/hpl/jena/graph/impl/ test/java/com/hp/hpl/jena/shared/ test/java/com/hp/hpl/jena/shared/impl/

Author: claude
Date: Sun Sep  8 08:33:32 2013
New Revision: 1520844

URL: http://svn.apache.org/r1520844
Log:
added tests for shared.

Added:
    jena/Experimental/new-test/src/main/
    jena/Experimental/new-test/src/main/java/
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java   (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java   (with props)
Modified:
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java?rev=1520844&r1=1520843&r2=1520844&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/AbstractGraphTest.java Sun Sep  8 08:33:32 2013
@@ -737,6 +737,7 @@ public abstract class AbstractGraphTest 
 	public void failingTestDoubleRemoveAll() {
 		final Graph g = getGraphProducer().newGraph();
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			graphAddTxn(g, "c S d; e:ff GGG hhhh; _i J 27; Ell Em 'en'");
 			Iterator<Triple> it = new TrackingTripleIterator(g.find(Triple.ANY)) {
 				@Override
@@ -750,6 +751,11 @@ public abstract class AbstractGraphTest 
 				it.remove();
 			}
 			assertTrue(g.isEmpty());
+			}
+			catch (UnsupportedOperationException e)
+			{
+				fail( "Error attempting to remove nodes"+e.getMessage() );
+			}
 		}
 	}
 
@@ -1055,9 +1061,15 @@ public abstract class AbstractGraphTest 
 	public void testSizeAfterRemove() {
 		Graph g = graphWithTxn("x p y");
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			ExtendedIterator<Triple> it = g.find(triple("x ?? ??"));
 			it.removeNext();
 			assertEquals(0, g.size());
+			}
+			catch (UnsupportedOperationException e)
+			{
+				fail( "Error attempting to remove nodes"+e.getMessage() );
+			}
 		}
 	}
 
@@ -1150,12 +1162,18 @@ public abstract class AbstractGraphTest 
 	public void testBrokenIndexes() {
 		Graph g = graphWithTxn("x R y; x S z");
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY, Node.ANY);
 			it.removeNext();
 			it.removeNext();
 			assertFalse(g.find(node("x"), Node.ANY, Node.ANY).hasNext());
 			assertFalse(g.find(Node.ANY, node("R"), Node.ANY).hasNext());
 			assertFalse(g.find(Node.ANY, Node.ANY, node("y")).hasNext());
+			}
+			catch (UnsupportedOperationException e)
+			{
+				fail( "Error attempting to remove nodes"+e.getMessage() );
+			}
 		}
 	}
 
@@ -1163,9 +1181,15 @@ public abstract class AbstractGraphTest 
 	public void testBrokenSubject() {
 		Graph g = graphWithTxn("x brokenSubject y");
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			ExtendedIterator<Triple> it = g.find(node("x"), Node.ANY, Node.ANY);
 			it.removeNext();
 			assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			}
+			catch (UnsupportedOperationException e)
+			{
+				fail( "Error attempting to remove nodes"+e.getMessage() );
+			}
 		}
 	}
 
@@ -1173,10 +1197,16 @@ public abstract class AbstractGraphTest 
 	public void testBrokenPredicate() {
 		Graph g = graphWithTxn("x brokenPredicate y");
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			ExtendedIterator<Triple> it = g.find(Node.ANY,
 					node("brokenPredicate"), Node.ANY);
 			it.removeNext();
 			assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			}
+			catch (UnsupportedOperationException e)
+			{
+				fail( "Error attempting to remove nodes"+e.getMessage() );
+			}
 		}
 	}
 
@@ -1184,10 +1214,17 @@ public abstract class AbstractGraphTest 
 	public void testBrokenObject() {
 		Graph g = graphWithTxn("x brokenObject y");
 		if (g.getCapabilities().iteratorRemoveAllowed()) {
+			try {
 			ExtendedIterator<Triple> it = g.find(Node.ANY, Node.ANY, node("y"));
 			it.removeNext();
 			assertFalse(g.find(Node.ANY, Node.ANY, Node.ANY).hasNext());
+			
+		}
+		catch (UnsupportedOperationException e)
+		{
+			fail( "Error attempting to remove nodes"+e.getMessage() );
 		}
 	}
+	}
 
 }

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java?rev=1520844&r1=1520843&r2=1520844&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/graph/impl/WrappedGraphTest.java Sun Sep  8 08:33:32 2013
@@ -34,7 +34,7 @@ import com.hp.hpl.jena.testing_framework
 
 public class WrappedGraphTest extends AbstractGraphTest {
 
-	GraphProducerInterface graphProducer = new WrappedGraphSuite.GraphProducer();
+	protected GraphProducerInterface graphProducer = new WrappedGraphSuite.GraphProducer();
 
 	@Override
 	public GraphProducerInterface getGraphProducer() {

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java?rev=1520844&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java Sun Sep  8 08:33:32 2013
@@ -0,0 +1,43 @@
+/*
+ * 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 com.hp.hpl.jena.shared;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Test the jena Exception class
+ *
+ */
+public class JenaExceptionTest 
+    {
+    
+	/**
+	 * Test that nested Jena exceptions preserve the caught exception's message.
+	 */
+	@Test
+    public void testRethrownMessage()
+        {
+        Exception e = new Exception( "kings and queens" );
+        JenaException j = new JenaException( e );
+        assertTrue( j.getMessage().endsWith( e.getMessage() ) );
+        assertEquals( e, j.getCause() );
+        }
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/JenaExceptionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java?rev=1520844&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java Sun Sep  8 08:33:32 2013
@@ -0,0 +1,49 @@
+package com.hp.hpl.jena.shared;
+
+import static com.hp.hpl.jena.testing_framework.GraphTestUtils.*;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.graph.TripleMatch;
+import com.hp.hpl.jena.graph.impl.WrappedGraphSuite;
+import com.hp.hpl.jena.graph.impl.WrappedGraphTest;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+import com.hp.hpl.jena.testing_framework.AbstractGraphProducer;
+import com.hp.hpl.jena.testing_framework.GraphProducerInterface;
+
+public class RandomOrderGraphTest extends WrappedGraphTest {
+
+	public RandomOrderGraphTest()
+	{
+		graphProducer = new AbstractGraphProducer(){
+
+			@Override
+			protected Graph createNewGraph() {
+				return new RandomOrderGraph(5,GraphFactory.createGraphMem());
+			}};
+	}
+	
+	@Test
+	public void testRandomFindTriple() {
+		Graph g = graphWithTxn( "a b 1; a b 2; a b 3; a b 4; a b 5; a b 6");
+		List<Triple> l1 = g.find( new Triple( node( "a"), node("b"), Node.ANY) ).toList();
+		List<Triple> l2 = g.find( new Triple( node( "a"), node("b"), Node.ANY) ).toList();
+		Assert.assertNotEquals( "Lists should be different", l1,  l2 );
+	}
+	
+	@Test
+	public void testRandomFindNodes() {
+		Graph g = graphWithTxn( "a b 1; a b 2; a b 3; a b 4; a b 5; a b 6");
+		List<Triple> l1 = g.find( node( "a"), node("b"), Node.ANY).toList();
+		List<Triple> l2 = g.find( node( "a"), node("b"), Node.ANY).toList();
+		Assert.assertNotEquals( "Lists should be different", l1,  l2 );
+	}
+	
+
+}

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/RandomOrderGraphTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java?rev=1520844&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java Sun Sep  8 08:33:32 2013
@@ -0,0 +1,73 @@
+/*
+ * 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 com.hp.hpl.jena.shared.impl;
+
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import com.hp.hpl.jena.assembler.JA ;
+import com.hp.hpl.jena.shared.AbstractPrefixMappingTest;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.shared.impl.PrefixMappingImpl ;
+import com.hp.hpl.jena.vocabulary.DC_11;
+import com.hp.hpl.jena.vocabulary.OWL;
+import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.vocabulary.RDFS;
+import com.hp.hpl.jena.vocabulary.RSS;
+import com.hp.hpl.jena.vocabulary.VCARD;
+
+
+/**
+    Tests PrefixMappingImpl by subclassing AbstractTestPrefixMapping, qv.
+*/
+
+public class PrefixMappingTest extends AbstractPrefixMappingTest
+    {
+    
+    @Override
+    protected PrefixMapping getMapping()
+        { return new PrefixMappingImpl(); }
+
+    @Test
+    public void testStandard()
+        { testStandard( PrefixMapping.Standard ); }
+
+    @Test
+    public void testExtended()
+        { testExtended( PrefixMapping.Extended ); }
+
+    private void testStandard( PrefixMapping st )
+        {
+        assertEquals( RDF.getURI(), st.getNsPrefixURI( "rdf" ) );
+        assertEquals( RDFS.getURI(), st.getNsPrefixURI( "rdfs" ) );
+        assertEquals( DC_11.getURI(), st.getNsPrefixURI( "dc" ) );
+        assertEquals( OWL.getURI(), st.getNsPrefixURI( "owl" ) );
+        }
+
+    private void testExtended( PrefixMapping st )
+        {
+        testStandard( st );
+        assertEquals( RSS.getURI(), st.getNsPrefixURI( "rss" ) );
+        assertEquals( VCARD.getURI(), st.getNsPrefixURI( "vcard" ) );
+        assertEquals( JA.getURI(), st.getNsPrefixURI( "ja" ) );
+        assertEquals( "http://www.example.org/", st.getNsPrefixURI( "eg" ) );
+        }
+
+    }

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/PrefixMappingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java?rev=1520844&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java Sun Sep  8 08:33:32 2013
@@ -0,0 +1,23 @@
+/*
+    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 com.hp.hpl.jena.shared.impl;
+
+/**
+ * This package provides "standard" implementations for the interfaces 
+ * defined by .shared, notably an implementation of PrefixMapping.
+ */

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/impl/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java?rev=1520844&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java Sun Sep  8 08:33:32 2013
@@ -0,0 +1,24 @@
+/*
+    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 com.hp.hpl.jena.shared;
+
+/**
+ * This package defines some classes common to the Jena API and SPI levels, in particular 
+ * the JenaException class from which all Jena-specific exceptions hang, and the interface 
+ * PrefixMapping for translation to and from QNames.
+ */

Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain