jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject svn commit: r1525342 - in /jena/Experimental/new-test/src/test/java/com/hp/hpl/jena: rdf/model/ rdf/model/impl/ rdf/model/temp/ shared/ testing_framework/
Date Sun, 22 Sep 2013 10:35:09 GMT
Author: claude
Date: Sun Sep 22 10:35:09 2013
New Revision: 1525342

URL: http://svn.apache.org/r1525342
Log:
Cleaned up more tests

Added:
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComSuite.java
  (with props)
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComTests.java
  (with props)
Removed:
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListStatementsTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractListSubjectsTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelPrefixMappingTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelListStatementTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelListSubjectsTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelPrefixMappingTest.java
Modified:
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelConContractTests.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractSuite.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractTests.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFNodeTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelConTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/AbstractPrefixMappingTest.java
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelConContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelConContractTests.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelConContractTests.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelConContractTests.java
Sun Sep 22 10:35:09 2013
@@ -22,7 +22,10 @@ import static com.hp.hpl.jena.testing_fr
 import static org.junit.Assert.*;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -988,11 +991,11 @@ public abstract class AbstractModelConCo
 		Alt alt = model.getAlt(r);
 
 		// verify alt settings
-		assertSame("must be of the model", model, alt.getModel());
+		logAssertSame(this.getClass(), "must be of the model", model, alt.getModel());
 		assertEquals("must be uri", r.getURI(), alt.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be an alt", alt.isAlt());
+		logAssertTrue(this.getClass(), "must be an alt", alt.isAlt());
 		SL.assertEmpty();
 
 		// add the alt to the model
@@ -1003,9 +1006,9 @@ public abstract class AbstractModelConCo
 
 		Alt alt2 = model.getAlt(r);
 		SL.assertEmpty();
-		assertSame("must be of the model", model, alt2.getModel());
-		assertEquals("must be uri", r, alt2.getURI());
-		assertTrue("must be an alt", alt2.isAlt());
+		logAssertSame(this.getClass(),"must be of the model", model, alt2.getModel());
+		assertEquals("must be uri", r.getURI(), alt2.getURI());
+		logAssertTrue(this.getClass(), "must be an alt", alt2.isAlt());
 	}
 
 	@Test
@@ -1024,7 +1027,7 @@ public abstract class AbstractModelConCo
 		assertEquals("must be uri", "O", alt.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be an alt", alt.isAlt());
+		logAssertTrue( this.getClass(), "must be an alt", alt.isAlt());
 		SL.assertEmpty();
 
 		// add the alt to the model
@@ -1055,12 +1058,11 @@ public abstract class AbstractModelConCo
 		Bag bag = model.getBag(r);
 
 		// verify bag settings
-		assertSame("test", r.getModel(), bag.getModel());
-		assertSame("must be of the model", model, bag.getModel());
+		logAssertSame( this.getClass(), "must be of the model", model, bag.getModel());
 		assertEquals("must be uri", r.getURI(), bag.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be a bag", bag.isBag());
+		logAssertTrue(this.getClass(), "must be a bag", bag.isBag());
 		SL.assertEmpty();
 
 		// add the bag to the model
@@ -1074,9 +1076,9 @@ public abstract class AbstractModelConCo
 
 		Bag bag2 = model.getBag(r);
 		// SL.assertEmpty();
-		assertSame("must be of the model", model, bag2.getModel());
+		logAssertSame(this.getClass(), "must be of the model", model, bag2.getModel());
 		assertEquals("must be uri", r.getURI(), bag2.getURI());
-		assertTrue("must be a bag", bag2.isBag());
+		logAssertTrue(this.getClass(), "must be a bag", bag2.isBag());
 
 	}
 
@@ -1092,7 +1094,7 @@ public abstract class AbstractModelConCo
 		assertEquals("must be uri", "O", bag.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be a bag", bag.isBag());
+		logAssertTrue(this.getClass(), "must be a bag", bag.isBag());
 		SL.assertEmpty();
 
 		// add the bag to the model
@@ -1164,11 +1166,11 @@ public abstract class AbstractModelConCo
 		Seq seq = model.getSeq(r);
 
 		// verify bag settings
-		assertSame("must be of the model", model, seq.getModel());
+		logAssertSame(this.getClass(), "must be of the model", model, seq.getModel());
 		assertEquals("must be uri", r.getURI(), seq.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be a seq", seq.isSeq());
+		logAssertTrue(this.getClass(), "must be a seq", seq.isSeq());
 		SL.assertEmpty();
 
 		// add the seq to the model
@@ -1179,9 +1181,9 @@ public abstract class AbstractModelConCo
 
 		Seq seq2 = model.getSeq(r);
 		SL.assertEmpty();
-		assertSame("must be of the model", model, seq2.getModel());
-		assertEquals("must be uri", r, seq2.getURI());
-		assertTrue("must be a seq", seq2.isSeq());
+		logAssertSame( this.getClass(), "must be of the model", model, seq2.getModel());
+		assertEquals("must be uri", r.getURI(), seq2.getURI());
+		logAssertTrue(this.getClass(), "must be a seq", seq2.isSeq());
 
 	}
 
@@ -1201,7 +1203,7 @@ public abstract class AbstractModelConCo
 		assertEquals("must be uri", "O", seq.getURI());
 		assertFalse("model must not contain statement", model.listStatements()
 				.hasNext());
-		assertTrue("must be a seq", seq.isSeq());
+		logAssertTrue(this.getClass(),"must be a seq", seq.isSeq());
 		SL.assertEmpty();
 
 		// add the seq to the model
@@ -1214,7 +1216,7 @@ public abstract class AbstractModelConCo
 		SL.assertEmpty();
 		assertSame("must be of the model", model, seq2.getModel());
 		assertEquals("must be uri", "O", seq2.getURI());
-		assertTrue("must be a seq", seq2.isSeq());
+		logAssertTrue(this.getClass(), "must be a seq", seq2.isSeq());
 
 	}
 
@@ -1493,29 +1495,35 @@ public abstract class AbstractModelConCo
 		assertEquals(0, model.listStatements(null, p2, v2).toList().size());
 		assertEquals(0, model.listStatements(r1, p2, v2).toList().size());
 		assertEquals(0, model.listStatements(r2, p2, v2).toList().size());
-
+		
+		
 	}
 
 	@Test
 	public void testListStatements_Resource_Property_String_String() {
 		String v = "foo";
-
+		String v2 = "bar";
 		Property p = property("P");
-
-		Resource r = resource("S");
+		Resource s = resource("S");
 
 		txnBegin(model);
-		model.add(r, p, v, "en");
-		model.add(r, p, v, "fr");
-		txnCommit(model);
-
-		assertEquals(1, model.listStatements(r, p, v, "en").toList().size());
-		assertEquals(1, model.listStatements(r, p, v, "fr").toList().size());
-		assertEquals(2, model.listStatements(r, p, v, null).toList().size());
-		assertEquals(1, model.listStatements(r, p, null, "en").toList().size());
-		assertEquals(1, model.listStatements(r, null, v, "en").toList().size());
+		model.add(s, p, v, "en");
+		model.add(s, p, v, "fr");
+		model.add(s, p, v, (String)null );
+		model.add(s, p, v2, (String)null );
+		txnCommit(model);
+
+		assertEquals(1, model.listStatements(s, p, v, "en").toList().size());
+		assertEquals(1, model.listStatements(s, p, v, "fr").toList().size());
+		assertEquals(2, model.listStatements(s, p, v, null).toList().size());
+		assertEquals(1, model.listStatements(s, p, null, "en").toList().size());
+		assertEquals(1, model.listStatements(s, p, null, "fr").toList().size());
+		assertEquals(2, model.listStatements(s, p, null, "").toList().size());
+		assertEquals(1, model.listStatements(s, p, v, "").toList().size());
+		assertEquals(1, model.listStatements(s, null, v, "en").toList().size());
 		assertEquals(1, model.listStatements(null, p, v, "fr").toList().size());
-		assertEquals(2, model.listStatements(null, null, null, null).toList()
+		assertEquals(4, model.listStatements(s, p, null, null).toList().size());
+		assertEquals(4, model.listStatements(null, null, null, null).toList()
 				.size());
 	}
 
@@ -1643,6 +1651,9 @@ public abstract class AbstractModelConCo
 				lst.contains(statement("S P2 O")));
 
 	}
+	
+	
+	
 //	@Test
 //	public void testChangedListener() {
 //		final ChangedListener CL = new ChangedListener();

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractSuite.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractSuite.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractSuite.java
Sun Sep 22 10:35:09 2013
@@ -125,20 +125,15 @@ public abstract class AbstractModelContr
 	}
 	
 	public static class PrefixMappingContractTests extends AbstractPrefixMappingTest {
-		private PrefixMapping prefixMapping = null;
 		
 		@Override
 		protected PrefixMapping getMapping() {
-			if (prefixMapping == null)
-			{
-				prefixMapping = modelProducer.newModel();
-			}
-			return prefixMapping;
+			return modelProducer.newModel();
 		}
 
 		@After
 		public final void afterPrefixMappingContractTests() {
-			prefixMapping = null;
+
 			modelProducer.closeModels();
 		}
 

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractTests.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractTests.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelContractTests.java
Sun Sep 22 10:35:09 2013
@@ -18,6 +18,7 @@
 
 package com.hp.hpl.jena.rdf.model;
 
+import static com.hp.hpl.jena.testing_framework.GraphHelper.iteratorToSet;
 import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
@@ -31,8 +32,11 @@ import java.io.Reader;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+
 import javax.xml.XMLConstants;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.parsers.DocumentBuilder;
@@ -1691,7 +1695,6 @@ public abstract class AbstractModelContr
 		for (Statement s : stmts) {
 			assertTrue("Missing statement " + s, lst.contains(s));
 		}
-
 	}
 
 	private void checkReturns(final String wantedStmts, final StmtIterator it) {
@@ -1712,12 +1715,14 @@ public abstract class AbstractModelContr
 		final Property P = property("P"), P1 = property("P1");
 		final RDFNode O = resource("O"), Y = resource("Y");
 		final String S1 = "S P O; S1 P O; S2 P O";
-		final String S2 = "A P1 O; A P1 B; A P1 C";
+		final String S2 = "A P1 O; A P1 B; A P1 _C";
 		final String S3 = "X P1 Y; X P2 Y; X P3 Y";
 		txnBegin(model);
 		modelAdd(model, S1);
 		modelAdd(model, S2);
 		modelAdd(model, S3);
+		Resource anon = model.createResource();
+	    model.createResource("http://example").addProperty(RDF.type, anon);
 		txnCommit(model);
 
 		checkReturns(S1, model.listStatements(null, P, O));
@@ -1733,10 +1738,16 @@ public abstract class AbstractModelContr
 		stmts.addAll(Arrays.asList(statements(S1)));
 		stmts.addAll(Arrays.asList(statements(S1)));
 		stmts.addAll(Arrays.asList(statements(S1)));
-		assertEquals("wrong number of statements", stmts.size(), lst.size());
+		// add one for the anonymous statement added programmaticly
+		assertEquals("wrong number of statements", stmts.size()+1, lst.size());
 		for (Statement s : stmts) {
 			assertTrue("Missing statement " + s, lst.contains(s));
 		}
+		
+		// test locating anonymous nodes
+		assertEquals(1, model.listStatements( null, null, resource("_C") ).toList().size());
+		assertEquals(1, model.listStatements( null, null, anon ).toList().size());
+		
 	}
 
 	@Test
@@ -2071,7 +2082,56 @@ public abstract class AbstractModelContr
 			assertTrue("missing " + r, lst.contains(r));
 		}
 	}
+	
+	@Test
+	public void testListSubjects_DoesNoRemove()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"a P b; b Q c; c R a");
+		final ResIterator it = m.listSubjects();
+		it.next();
+		try
+		{
+			it.remove();
+			Assert.fail("listSubjects should not support .remove()");
+		}
+		catch (final UnsupportedOperationException e)
+		{
+			// expected
+		}
+	}
 
+	@Test
+	public void testListSubjects_WorksAfterRemoveProperties()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"p1 before terminal; p2 before terminal");
+		txnBegin( m );
+		m.createResource("eh:/p1").removeProperties();
+		txnCommit( m );
+		assertIsoModels(
+				modelWithStatements(getModelProducer(), "p2 before terminal"), m);
+		Assert.assertEquals(resourceSet("p2"), m.listSubjects()
+				.toSet());
+	}
+	
+	@Test
+	public void testListSubjects_WorksAfterRemovePropertiesWithLots()
+	{
+		final Model m = modelWithStatements(getModelProducer(),
+				"p2 before terminal");
+		txnBegin(m);
+		for (int i = 0; i < 100; i += 1)
+		{
+			modelAdd(m, "p1 hasValue " + i);
+		}
+		m.createResource("eh:/p1").removeProperties();
+		txnCommit( m );
+		assertIsoModels(
+				modelWithStatements(getModelProducer(), "p2 before terminal"), m);
+		Assert.assertEquals(resourceSet("p2"), m.listSubjects()
+				.toSet());
+	}
 	/**
 	 * List the subjects
 	 * 

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractModelExtractTest.java
Sun Sep 22 10:35:09 2013
@@ -24,7 +24,6 @@ import com.hp.hpl.jena.graph.Graph;
 import com.hp.hpl.jena.graph.GraphExtract;
 import com.hp.hpl.jena.graph.Node;
 import com.hp.hpl.jena.graph.TripleBoundary;
-import com.hp.hpl.jena.graph.test.GraphTestBase;
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelExtract;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
@@ -93,9 +92,9 @@ public abstract class AbstractModelExtra
 	{
 		final Model m = ModelFactory.createDefaultModel();
 		Assert.assertTrue(AbstractModelExtractTest.sbTrue.asTripleBoundary(m).stopAt(
-				GraphTestBase.triple("x R y")));
+				triple("x R y")));
 		Assert.assertFalse(AbstractModelExtractTest.sbFalse.asTripleBoundary(m).stopAt(
-				GraphTestBase.triple("x R y")));
+				triple("x R y")));
 	}
 
 	@Test
@@ -105,7 +104,7 @@ public abstract class AbstractModelExtra
 				AbstractModelExtractTest.sbTrue);
 		final Model source = modelWithStatements(getModelProducer(), "a R b");
 		final Model m = mock.extract(resource("a"), source);
-		Assert.assertEquals(GraphTestBase.node("a"), mock.root);
+		Assert.assertEquals(node("a"), mock.root);
 		Assert.assertSame(mock.result, m.getGraph());
 		Assert.assertSame(mock.subject, source.getGraph());
 	}

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFNodeTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFNodeTest.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFNodeTest.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFNodeTest.java
Sun Sep 22 10:35:09 2013
@@ -35,7 +35,7 @@ import static com.hp.hpl.jena.testing_fr
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Assert;
+import static org.junit.Assert.*;
 import org.junit.Test;
 
 /**
@@ -47,55 +47,58 @@ public abstract class AbstractRDFNodeTes
 	public void testInModel() {
 		final Model m1 = modelWithStatements(getModelProducer(), "");
 		final Model m2 = modelWithStatements(getModelProducer(), "");
-		final Resource r1 = resource("r1");
-		final Resource r2 = resource("_r2");
-		/* */
-		Assert.assertEquals(r1.getModel(), m1);
-		Assert.assertEquals(r2.getModel(), m1);
-		Assert.assertFalse(r1.isAnon());
-		Assert.assertTrue(r2.isAnon());
-		/* */
-		Assert.assertEquals(r1.inModel(m2).getModel(), m2);
-		Assert.assertEquals(r2.inModel(m2).getModel(), m2);
-		/* */
-		Assert.assertEquals(r1, r1.inModel(m2));
-		Assert.assertEquals(r2, r2.inModel(m2));
+		final Resource r1 = m1.getResource( resource("r1").getURI() );
+		final Resource r2 = m1.createResource( resource("_r2").getId() );
+		/* verify initial conditions */
+		assertSame(r1.getModel(), m1);
+		assertSame(r2.getModel(), m1);
+		assertFalse(r1.isAnon());
+		assertTrue(r2.isAnon());
+		/* verify calling inModel with same model returns resource */
+		assertSame( r1, r1.inModel(m1));
+		assertSame( r2, r2.inModel(m1));
+		/* verify calling in model changes model*/
+		assertSame(r1.inModel(m2).getModel(), m2);
+		assertSame(r2.inModel(m2).getModel(), m2);
+		/* verify in model check returns equivalent resource*/
+		assertEquals(r1, r1.inModel(m2));
+		assertEquals(r2, r2.inModel(m2));
 	}
 
 	@Test
 	public void testIsAnon() {
 		final Model m = modelWithStatements(getModelProducer(), "");
-		Assert.assertEquals(false, m.createResource("eh:/foo").isAnon());
-		Assert.assertEquals(true, m.createResource().isAnon());
-		Assert.assertEquals(false, m.createTypedLiteral(17).isAnon());
-		Assert.assertEquals(false, m.createTypedLiteral("hello").isAnon());
+		assertEquals(false, m.createResource("eh:/foo").isAnon());
+		assertEquals(true, m.createResource().isAnon());
+		assertEquals(false, m.createTypedLiteral(17).isAnon());
+		assertEquals(false, m.createTypedLiteral("hello").isAnon());
 	}
 
 	@Test
 	public void testIsLiteral() {
 		final Model m = modelWithStatements(getModelProducer(), "");
-		Assert.assertEquals(false, m.createResource("eh:/foo").isLiteral());
-		Assert.assertEquals(false, m.createResource().isLiteral());
-		Assert.assertEquals(true, m.createTypedLiteral(17).isLiteral());
-		Assert.assertEquals(true, m.createTypedLiteral("hello").isLiteral());
+		assertEquals(false, m.createResource("eh:/foo").isLiteral());
+		assertEquals(false, m.createResource().isLiteral());
+		assertEquals(true, m.createTypedLiteral(17).isLiteral());
+		assertEquals(true, m.createTypedLiteral("hello").isLiteral());
 	}
 
 	@Test
 	public void testIsResource() {
 		final Model m = modelWithStatements(getModelProducer(), "");
-		Assert.assertEquals(true, m.createResource("eh:/foo").isResource());
-		Assert.assertEquals(true, m.createResource().isResource());
-		Assert.assertEquals(false, m.createTypedLiteral(17).isResource());
-		Assert.assertEquals(false, m.createTypedLiteral("hello").isResource());
+		assertEquals(true, m.createResource("eh:/foo").isResource());
+		assertEquals(true, m.createResource().isResource());
+		assertEquals(false, m.createTypedLiteral(17).isResource());
+		assertEquals(false, m.createTypedLiteral("hello").isResource());
 	}
 
 	@Test
 	public void testIsURIResource() {
 		final Model m = modelWithStatements(getModelProducer(), "");
-		Assert.assertEquals(true, m.createResource("eh:/foo").isURIResource());
-		Assert.assertEquals(false, m.createResource().isURIResource());
-		Assert.assertEquals(false, m.createTypedLiteral(17).isURIResource());
-		Assert.assertEquals(false, m.createTypedLiteral("hello")
+		assertEquals(true, m.createResource("eh:/foo").isURIResource());
+		assertEquals(false, m.createResource().isURIResource());
+		assertEquals(false, m.createTypedLiteral(17).isURIResource());
+		assertEquals(false, m.createTypedLiteral("hello")
 				.isURIResource());
 	}
 
@@ -105,7 +108,7 @@ public abstract class AbstractRDFNodeTes
 		final Resource r = m.createResource("eh:/spoo");
 		try {
 			r.asLiteral();
-			Assert.fail("should not be able to do Resource.asLiteral()");
+			fail("should not be able to do Resource.asLiteral()");
 		} catch (final LiteralRequiredException e) {
 		}
 	}
@@ -114,14 +117,14 @@ public abstract class AbstractRDFNodeTes
 	public void testRDFNodeAsLiteral() {
 		final Model m = modelWithStatements(getModelProducer(), "");
 		final Literal l = m.createLiteral("hello, world");
-		Assert.assertSame(l, ((RDFNode) l).asLiteral());
+		assertSame(l, ((RDFNode) l).asLiteral());
 	}
 
 	@Test
 	public void testRDFNodeAsResource() {
 		final Model m = modelWithStatements(getModelProducer(), "");
 		final Resource r = m.createResource("eh:/spoo");
-		Assert.assertSame(r, ((RDFNode) r).asResource());
+		assertSame(r, ((RDFNode) r).asResource());
 	}
 
 	@Test
@@ -136,31 +139,31 @@ public abstract class AbstractRDFNodeTes
 			@Override
 			public Object visitBlank(final Resource R, final AnonId id) {
 				history.add("blank");
-				Assert.assertTrue("must visit correct node", R == S);
-				Assert.assertEquals("must have correct field", R.getId(), id);
+				assertTrue("must visit correct node", R == S);
+				assertEquals("must have correct field", R.getId(), id);
 				return "blank result";
 			}
 
 			@Override
 			public Object visitLiteral(final Literal L) {
 				history.add("literal");
-				Assert.assertTrue("must visit correct node", L == O);
+				assertTrue("must visit correct node", L == O);
 				return "literal result";
 			}
 
 			@Override
 			public Object visitURI(final Resource R, final String uri) {
 				history.add("uri");
-				Assert.assertTrue("must visit correct node", R == P);
-				Assert.assertEquals("must have correct field", R.getURI(), uri);
+				assertTrue("must visit correct node", R == P);
+				assertEquals("must have correct field", R.getURI(), uri);
 				return "uri result";
 			}
 		};
 		/* */
-		Assert.assertEquals("blank result", S.visitWith(rv));
-		Assert.assertEquals("uri result", P.visitWith(rv));
-		Assert.assertEquals("literal result", O.visitWith(rv));
-		Assert.assertEquals(JenaTestBase.listOfStrings("blank uri literal"),
+		assertEquals("blank result", S.visitWith(rv));
+		assertEquals("uri result", P.visitWith(rv));
+		assertEquals("literal result", O.visitWith(rv));
+		assertEquals(JenaTestBase.listOfStrings("blank uri literal"),
 				history);
 	}
 
@@ -179,9 +182,9 @@ public abstract class AbstractRDFNodeTes
 		final String ps = "x P a; x P b", rest = "x Q c; y P a; y Q b";
 		final Model m = modelWithStatements(getModelProducer(), ps
 				+ "; " + rest);
-		final Resource r = resource("x");
+		final Resource r = m.getResource( resource("x").getURI() );
 		final Resource r2 = r.removeAll(property("P"));
-		Assert.assertSame("removeAll should deliver its receiver", r, r2);
+		assertSame("removeAll should deliver its receiver", r, r2);
 		assertIsoModels("x's P-values should go",
 				modelWithStatements(getModelProducer(), rest), m);
 	}
@@ -192,7 +195,7 @@ public abstract class AbstractRDFNodeTes
 		final Literal l = m.createLiteral("hello, world");
 		try {
 			l.asResource();
-			Assert.fail("should not be able to do Literal.asResource()");
+			fail("should not be able to do Literal.asResource()");
 		} catch (final ResourceRequiredException e) {
 		}
 	}
@@ -204,9 +207,9 @@ public abstract class AbstractRDFNodeTes
 		final Model model = getModelProducer().newModel();
 		final Resource anon = model.createResource();
 		final Resource bAnon = anon.inModel(B);
-		Assert.assertTrue("moved resource should still be blank",
+		assertTrue("moved resource should still be blank",
 				bAnon.isAnon());
-		Assert.assertEquals("move resource should equal original", anon, bAnon);
+		assertEquals("move resource should equal original", anon, bAnon);
 	}
 
 }

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComSuite.java?rev=1525342&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComSuite.java
(added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComSuite.java
Sun Sep 22 10:35:09 2013
@@ -0,0 +1,27 @@
+package com.hp.hpl.jena.rdf.model.impl;
+
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import com.hp.hpl.jena.rdf.model.AbstractModelContractSuite;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+import com.hp.hpl.jena.testing_framework.AbstractModelProducer;
+
+@RunWith(Suite.class)
+public class ModelComSuite extends AbstractModelContractSuite {
+	
+	@BeforeClass
+	public static void beforeClass() {
+		setModelProducer(new ModelProducer());
+	}
+
+	public static class ModelProducer extends AbstractModelProducer {
+		@Override
+		protected Model createNewModel() {
+			return new ModelCom( GraphFactory.createGraphMem());
+		}
+	}
+	
+}

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

Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComTests.java?rev=1525342&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComTests.java
(added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/impl/ModelComTests.java
Sun Sep 22 10:35:09 2013
@@ -0,0 +1,58 @@
+package com.hp.hpl.jena.rdf.model.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.hp.hpl.jena.shared.AbstractPrefixMappingTest;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.shared.PrefixMapping;
+import com.hp.hpl.jena.sparql.graph.GraphFactory;
+
+public class ModelComTests {
+	
+	protected PrefixMapping baseMap = PrefixMapping.Factory
+			.create()
+			.setNsPrefix(AbstractPrefixMappingTest.httpPrefix,
+					AbstractPrefixMappingTest.httpURI)
+			.setNsPrefix(AbstractPrefixMappingTest.urnPrefix,
+					AbstractPrefixMappingTest.urnURI);
+
+	private PrefixMapping prevMap;
+
+	private void restorePrefixes()
+	{
+		ModelCom.setDefaultModelPrefixes(prevMap);
+	}
+	
+	private void setPrefixes()
+	{
+		prevMap = ModelCom.setDefaultModelPrefixes(baseMap);
+	}
+	/**
+	 * Test that a freshly-created Model has the prefixes established by the
+	 * default in ModelCom.
+	 */
+	@Test
+	public void testDefaultPrefixes()
+	{
+		setPrefixes();
+		final Model m = new ModelCom( GraphFactory.createGraphMem());
+		Assert.assertEquals(baseMap.getNsPrefixMap(), m.getNsPrefixMap());
+		restorePrefixes();
+	}
+
+	@Test
+	public void testGetDefault()
+	{
+		setPrefixes();
+		try
+		{
+			Assert.assertSame(baseMap, ModelCom.getDefaultModelPrefixes());
+		}
+		finally
+		{
+			restorePrefixes();
+		}
+	}
+
+}

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

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelConTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelConTest.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelConTest.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/temp/ModelConTest.java
Sun Sep 22 10:35:09 2013
@@ -1,7 +1,5 @@
 package com.hp.hpl.jena.rdf.model.temp;
 
-import org.junit.Test;
-
 import com.hp.hpl.jena.rdf.model.AbstractModelConContractTests;
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/AbstractPrefixMappingTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/AbstractPrefixMappingTest.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/AbstractPrefixMappingTest.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/shared/AbstractPrefixMappingTest.java
Sun Sep 22 10:35:09 2013
@@ -36,6 +36,11 @@ import org.junit.Test;
 
 public abstract class AbstractPrefixMappingTest {
 
+	public static boolean sameMapping( final PrefixMapping L, final PrefixMapping R )
+	{
+		return L.getNsPrefixMap().equals(R.getNsPrefixMap());
+	}
+	
 	/**
 	 * Subclasses implement to return a new, empty prefixMapping of their
 	 * preferred implementation.

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java?rev=1525342&r1=1525341&r2=1525342&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java
(original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java
Sun Sep 22 10:35:09 2013
@@ -239,6 +239,7 @@ public class TestUtils {
 		return getURL( fn ).openStream();
 	}
 	
+	// FIXME this is to be removed when testing is complete
 	public static void logAssertEquals( Class<?> clazz, String msg, Object obj1, Object
obj2)
 	{
 		if (obj1 == null && obj2 == null)
@@ -258,6 +259,38 @@ public class TestUtils {
 			}
 		}
 		LoggerFactory.getLogger(clazz).warn( String.format( "%s expected: %s got: %s", msg, obj1,
obj2));
-		System.out.println( String.format( "[WARNING] %s expected: %s got: %s", msg, obj1, obj2));
+		System.out.println( String.format( "[%sWARNING] %s expected: %s got: %s", clazz, msg, obj1,
obj2));
 	}
+	
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertTrue( Class<?> clazz, String msg, boolean value)
+	{
+		if (value)
+		{
+			return;
+		}
+		
+		LoggerFactory.getLogger(clazz).warn( String.format( "%s", msg));
+		System.out.println( String.format( "[%s WARNING] %s ", clazz, msg));
+	}
+	
+	// FIXME this is to be removed when testing is complete
+	public static void logAssertSame( Class<?> clazz, String msg, Object obj1, Object
obj2)
+	{
+		if (obj1 == null && obj2 == null)
+		{
+			return;
+		}
+		
+		if (obj1 != null)
+		{
+			if (obj1 == obj2)
+			{
+				 return;
+			}
+		}
+		LoggerFactory.getLogger(clazz).warn( String.format( "%s expected: %s got: %s", msg, obj1,
obj2));
+		System.out.println( String.format( "[%s WARNING] %s expected: %s got: %s",clazz, msg, obj1,
obj2));
+	}
+	
 }



Mime
View raw message