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 2014/01/05 12:28:05 UTC
svn commit: r1555482 [3/6] - in /jena/Experimental/new-test: ./
src/test/java/ src/test/java/com/hp/hpl/jena/graph/
src/test/java/com/hp/hpl/jena/graph/compose/
src/test/java/com/hp/hpl/jena/graph/impl/
src/test/java/com/hp/hpl/jena/mem/ src/test/java/...
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java Sun Jan 5 11:28:03 2014
@@ -30,41 +30,34 @@ import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFReader;
+public class TurtleReaderTests {
+ private URL getURL(String name) throws FileNotFoundException {
+ URL url = TurtleReaderTests.class.getResource(name);
+ if (url == null) {
+ throw new FileNotFoundException(name);
+ }
+ return url;
+ }
-public class TurtleReaderTests
-{
- private URL getURL( String name ) throws FileNotFoundException
- {
- URL url = TurtleReaderTests.class.getResource(name );
- if (url == null)
- {
- throw new FileNotFoundException( name );
- }
- return url;
- }
-
- @Test
- public void test0()
- {
- RDFReader r = ModelFactory.createDefaultModel().getReader("Turtle") ;
- assertNotNull(r) ;
- }
-
- @Test
- public void test1() throws IOException
- {
- Model m = ModelFactory.createDefaultModel() ;
- URL url = getURL("simple.ttl");
- m.read(url.openStream(), url.toExternalForm(), "TTL") ;
- assertFalse(m.isEmpty()) ;
- }
-
- @Test
- public void test2() throws IOException
- {
- Model m = ModelFactory.createDefaultModel() ;
- URL url = getURL("i18n.ttl");
- m.read(url.openStream(), url.toExternalForm(), "TTL") ;
- assertFalse(m.isEmpty()) ;
- }
+ @Test
+ public void test0() {
+ RDFReader r = ModelFactory.createDefaultModel().getReader("Turtle");
+ assertNotNull(r);
+ }
+
+ @Test
+ public void test1() throws IOException {
+ Model m = ModelFactory.createDefaultModel();
+ URL url = getURL("simple.ttl");
+ m.read(url.openStream(), url.toExternalForm(), "TTL");
+ assertFalse(m.isEmpty());
+ }
+
+ @Test
+ public void test2() throws IOException {
+ Model m = ModelFactory.createDefaultModel();
+ URL url = getURL("i18n.ttl");
+ m.read(url.openStream(), url.toExternalForm(), "TTL");
+ assertFalse(m.isEmpty());
+ }
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java Sun Jan 5 11:28:03 2014
@@ -34,8 +34,6 @@ import com.hp.hpl.jena.rdf.model.RDFRead
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.util.FileUtils;
-import com.hp.hpl.jena.vocabulary.RDF;
-import com.hp.hpl.jena.testing_framework.manifest.Manifest;
import com.hp.hpl.jena.testing_framework.manifest.ManifestException;
import com.hp.hpl.jena.testing_framework.manifest.ManifestItem;
import com.hp.hpl.jena.testing_framework.manifest.ManifestSuite;
@@ -51,96 +49,92 @@ public class TurtleTestSuite implements
@Override
public void processManifestItem(ManifestItem manifestItem) {
-
- Resource r = manifestItem.getType();
- ManifestTestRunner mt = null;
- Class<? extends ManifestTest> cls = null;
-
- if (r.equals(TurtleTestVocab.TestInOut)) {
- cls = TestTurtle.class;
- }
- if (r.equals(TurtleTestVocab.TestSyntax)) {
- cls = TestSyntax.class;
- }
- if (r.equals(TurtleTestVocab.TestBadSyntax)) {
- cls = TestBadSyntax.class;
- }
-
- if (cls != null) {
- try {
- runners.add(new ManifestTestRunner(manifestItem, cls));
- } catch (InitializationError e) {
- runners.add( new ErrorReportingRunner( cls, e ) );
- }
- } else {
- runners.add( new ErrorReportingRunner( this.getClass(),
- new ManifestException( "Unrecognized test : "
- + manifestItem.getTestName())) );
- }
-
-
+
+ Resource r = manifestItem.getType();
+ ManifestTestRunner mt = null;
+ Class<? extends ManifestTest> cls = null;
+
+ if (r.equals(TurtleTestVocab.TestInOut)) {
+ cls = TestTurtle.class;
+ }
+ if (r.equals(TurtleTestVocab.TestSyntax)) {
+ cls = TestSyntax.class;
+ }
+ if (r.equals(TurtleTestVocab.TestBadSyntax)) {
+ cls = TestBadSyntax.class;
+ }
+
+ if (cls != null) {
+ try {
+ runners.add(new ManifestTestRunner(manifestItem, cls));
+ } catch (InitializationError e) {
+ runners.add(new ErrorReportingRunner(cls, e));
+ }
+ } else {
+ runners.add(new ErrorReportingRunner(this.getClass(),
+ new ManifestException("Unrecognized test : "
+ + manifestItem.getTestName())));
+ }
+
}
@Override
public void setTestRunnerList(List<Runner> runners) {
this.runners = runners;
}
-
- public static class TestTurtle extends ManifestTest
- {
+
+ public static class TestTurtle extends ManifestTest {
@Override
- public void runTest()
- {
- Model model = ModelFactory.createDefaultModel() ;
- RDFReader t = new TurtleReader() ;
- try {
- if ( manifestItem.getUriString() != null )
- t.read(model, FileManager.get().open(manifestItem.getInput().getURI()), manifestItem.getUriString()) ;
- else
- t.read(model, manifestItem.getInput().getURI()) ;
- // "http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfq-results.ttl"
-
- String syntax = FileUtils.guessLang(manifestItem.getOutput().getURI(), FileUtils.langNTriple) ;
-
- Model results = FileManager.get().loadModel(manifestItem.getOutput().getURI(), syntax);
- boolean b = model.isIsomorphicWith(results) ;
- if ( !b )
- assertTrue("Models not isomorphic", b) ;
- } catch (TurtleParseException ex)
- {
- throw ex ;
- }
- }
+ public void runTest() {
+ Model model = ModelFactory.createDefaultModel();
+ RDFReader t = new TurtleReader();
+ try {
+ if (manifestItem.getUriString() != null)
+ t.read(model,
+ FileManager.get().open(
+ manifestItem.getInput().getURI()),
+ manifestItem.getUriString());
+ else
+ t.read(model, manifestItem.getInput().getURI());
+ // "http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfq-results.ttl"
+
+ String syntax = FileUtils.guessLang(manifestItem.getOutput()
+ .getURI(), FileUtils.langNTriple);
+
+ Model results = FileManager.get().loadModel(
+ manifestItem.getOutput().getURI(), syntax);
+ boolean b = model.isIsomorphicWith(results);
+ if (!b)
+ assertTrue("Models not isomorphic", b);
+ } catch (TurtleParseException ex) {
+ throw ex;
+ }
+ }
}
-
- public static class TestSyntax extends ManifestTest
- {
+
+ public static class TestSyntax extends ManifestTest {
@Override
- public void runTest()
- {
- Model model = ModelFactory.createDefaultModel() ;
- RDFReader t = new TurtleReader() ;
- t.read(model, manifestItem.getInput().getURI()) ;
- }
+ public void runTest() {
+ Model model = ModelFactory.createDefaultModel();
+ RDFReader t = new TurtleReader();
+ t.read(model, manifestItem.getInput().getURI());
+ }
}
- public static class TestBadSyntax extends ManifestTest
- {
+ public static class TestBadSyntax extends ManifestTest {
@Override
- public void runTest()
- {
- Model model = ModelFactory.createDefaultModel() ;
- RDFReader t = new TurtleReader() ;
- try {
- t.read(model, manifestItem.getInput().getURI()) ;
- fail("Bad syntax test succeed in parsing the file") ;
- } catch (TurtleParseException ex)
- {
- return ;
- }
+ public void runTest() {
+ Model model = ModelFactory.createDefaultModel();
+ RDFReader t = new TurtleReader();
+ try {
+ t.read(model, manifestItem.getInput().getURI());
+ fail("Bad syntax test succeed in parsing the file");
+ } catch (TurtleParseException ex) {
+ return;
+ }
- }
+ }
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java Sun Jan 5 11:28:03 2014
@@ -16,42 +16,80 @@
* limitations under the License.
*/
-package com.hp.hpl.jena.n3.turtle ;
+package com.hp.hpl.jena.n3.turtle;
import com.hp.hpl.jena.rdf.model.*;
-
+
/**
- * Vocabulary definitions from TurtleTestVocab.ttl
+ * Vocabulary definitions from TurtleTestVocab.ttl
*/
public class TurtleTestVocab {
- /** <p>The RDF model that holds the vocabulary terms</p> */
- private static Model m_model = ModelFactory.createDefaultModel();
-
- /** <p>The namespace of the vocabulary as a string</p> */
- public static final String NS = "http://jena.hpl.hp.com/2005/12/test-turtle#";
-
- /** <p>The namespace of the vocabulary as a string</p>
- * @see #NS */
- public static String getURI() {return NS;}
-
- /** <p>The namespace of the vocabulary as a resource</p> */
- public static final Resource NAMESPACE = m_model.createResource( NS );
-
- /** <p>Declare a IRI for the test input</p> */
- public static final Property inputIRI = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#inputIRI" );
-
- /** <p>Output of a test</p> */
- public static final Property output = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#output" );
-
- /** <p>Input to a test</p> */
- public static final Property input = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#input" );
-
- public static final Resource TestInOut = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestInOut" );
-
- public static final Resource TestBadSyntax = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestBadSyntax" );
-
- public static final Resource TestSyntax = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestSyntax" );
-
- public static final Resource Test = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#Test" );
-
+ /**
+ * <p>
+ * The RDF model that holds the vocabulary terms
+ * </p>
+ */
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /**
+ * <p>
+ * The namespace of the vocabulary as a string
+ * </p>
+ */
+ public static final String NS = "http://jena.hpl.hp.com/2005/12/test-turtle#";
+
+ /**
+ * <p>
+ * The namespace of the vocabulary as a string
+ * </p>
+ *
+ * @see #NS
+ */
+ public static String getURI() {
+ return NS;
+ }
+
+ /**
+ * <p>
+ * The namespace of the vocabulary as a resource
+ * </p>
+ */
+ public static final Resource NAMESPACE = m_model.createResource(NS);
+
+ /**
+ * <p>
+ * Declare a IRI for the test input
+ * </p>
+ */
+ public static final Property inputIRI = m_model
+ .createProperty("http://jena.hpl.hp.com/2005/12/test-turtle#inputIRI");
+
+ /**
+ * <p>
+ * Output of a test
+ * </p>
+ */
+ public static final Property output = m_model
+ .createProperty("http://jena.hpl.hp.com/2005/12/test-turtle#output");
+
+ /**
+ * <p>
+ * Input to a test
+ * </p>
+ */
+ public static final Property input = m_model
+ .createProperty("http://jena.hpl.hp.com/2005/12/test-turtle#input");
+
+ public static final Resource TestInOut = m_model
+ .createResource("http://jena.hpl.hp.com/2005/12/test-turtle#TestInOut");
+
+ public static final Resource TestBadSyntax = m_model
+ .createResource("http://jena.hpl.hp.com/2005/12/test-turtle#TestBadSyntax");
+
+ public static final Resource TestSyntax = m_model
+ .createResource("http://jena.hpl.hp.com/2005/12/test-turtle#TestSyntax");
+
+ public static final Resource Test = m_model
+ .createResource("http://jena.hpl.hp.com/2005/12/test-turtle#Test");
+
}
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=1555482&r1=1555481&r2=1555482&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 Jan 5 11:28:03 2014
@@ -1,4 +1,5 @@
package com.hp.hpl.jena.rdf.model;
+
//
//import java.util.Arrays;
//import java.util.List;
@@ -689,4 +690,4 @@ package com.hp.hpl.jena.rdf.model;
// this.modelProducer = producer;
// }
// }
-//}
+// }
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFWriterTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFWriterTest.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFWriterTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AbstractRDFWriterTest.java Sun Jan 5 11:28:03 2014
@@ -3,8 +3,6 @@ package com.hp.hpl.jena.rdf.model;
import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
@@ -16,123 +14,117 @@ import org.slf4j.LoggerFactory;
import com.hp.hpl.jena.testing_framework.ModelHelper;
public abstract class AbstractRDFWriterTest {
-
+
private static Logger LOG = LoggerFactory
.getLogger(AbstractRDFWriterTest.class);
-
+
protected RDFWriter rdfWriter;
-
- protected void setWriter( RDFWriter writer )
- {
+
+ protected void setWriter(RDFWriter writer) {
this.rdfWriter = writer;
}
-
+
public static final String DEFAULT_BASE = "http://example.com/";
-
+
public AbstractRDFWriterTest() {
}
-
+
@Before
- public final void beforeRDFWriterTest()
- {
+ public final void beforeRDFWriterTest() {
this.rdfWriter = createWriter();
}
-
+
protected abstract RDFWriter createWriter();
- protected abstract void checkWriteResult( String result );
-
+ protected abstract void checkWriteResult(String result);
+
protected abstract String getFormat();
-
- protected abstract String getTestModelFacts();
-
- private Model getTestModel()
- {
- return ModelHelper.memModel( getTestModelFacts() );
+
+ protected abstract String getTestModelFacts();
+
+ private Model getTestModel() {
+ return ModelHelper.memModel(getTestModelFacts());
}
-
+
@Test
- public void testWriteWriter()
- {
+ public void testWriteWriter() {
StringWriter writer = new StringWriter();
- rdfWriter.write( getTestModel(), writer, DEFAULT_BASE );
- checkWriteResult( writer.getBuffer().toString() ) ;
+ rdfWriter.write(getTestModel(), writer, DEFAULT_BASE);
+ checkWriteResult(writer.getBuffer().toString());
}
@Test
- public void testWriteOutputStream() {
+ public void testWriteOutputStream() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- rdfWriter.write( getTestModel(), baos, DEFAULT_BASE );
- checkWriteResult( new String(baos.toByteArray()) ) ;
+ rdfWriter.write(getTestModel(), baos, DEFAULT_BASE);
+ checkWriteResult(new String(baos.toByteArray()));
}
@Test
- public void testSetProperty()
- {
- Object o = rdfWriter.setProperty( "test1", "test1a");
- assertNull( "Should not have returned a value", o );
- o = rdfWriter.setProperty( "test1", "test1b");
- assertNotNull( "Should have returned a value", o );
- assertEquals( o, "test1a");
-
- o = rdfWriter.setProperty( "test2", "test2a");
- assertNull( "Should not have returned a value", o );
- o = rdfWriter.setProperty( "test2", "test2b");
- assertNotNull( "Should have returned a value", o );
- assertEquals( o, "test2a");
+ public void testSetProperty() {
+ Object o = rdfWriter.setProperty("test1", "test1a");
+ assertNull("Should not have returned a value", o);
+ o = rdfWriter.setProperty("test1", "test1b");
+ assertNotNull("Should have returned a value", o);
+ assertEquals(o, "test1a");
+
+ o = rdfWriter.setProperty("test2", "test2a");
+ assertNull("Should not have returned a value", o);
+ o = rdfWriter.setProperty("test2", "test2b");
+ assertNotNull("Should have returned a value", o);
+ assertEquals(o, "test2a");
// can not set null -- no documentation about what this should do
// but it throws an exception in some cases where the properties
// are map based.
-// o = rdfWriter.setProperty( "test2", null);
-// assertNotNull( "Should have returned a value", o );
-// assertEquals( o, "test2b");
-// o = rdfWriter.setProperty( "test2", "test2c");
-// assertNull( "Should not have returned a value", o );
+ // o = rdfWriter.setProperty( "test2", null);
+ // assertNotNull( "Should have returned a value", o );
+ // assertEquals( o, "test2b");
+ // o = rdfWriter.setProperty( "test2", "test2c");
+ // assertNull( "Should not have returned a value", o );
}
@Test
- public void testSetErrorHandler()
- {
- RDFErrorHandler e = new RDFErrorHandler(){
+ public void testSetErrorHandler() {
+ RDFErrorHandler e = new RDFErrorHandler() {
@Override
public void warning(Exception e) {
// TODO Auto-generated method stub
-
+
}
@Override
public void error(Exception e) {
// TODO Auto-generated method stub
-
+
}
@Override
public void fatalError(Exception e) {
// TODO Auto-generated method stub
-
- }};
-
-
- RDFErrorHandler o = rdfWriter.setErrorHandler( e );
- RDFErrorHandler o2 = rdfWriter.setErrorHandler( o );
- assertEquals( "Should have returned original error handler", e, o2 );
+
+ }
+ };
+
+ RDFErrorHandler o = rdfWriter.setErrorHandler(e);
+ RDFErrorHandler o2 = rdfWriter.setErrorHandler(o);
+ assertEquals("Should have returned original error handler", e, o2);
}
@Test
- public void testRoundtrip() throws Exception
- {
+ public void testRoundtrip() throws Exception {
Model model = getTestModel();
StringWriter writer = new StringWriter();
- rdfWriter.write( getTestModel(), writer, DEFAULT_BASE );
-
- writer.close() ;
-
- StringReader r = new StringReader(writer.toString()) ;
- Model model2 = ModelFactory.createDefaultModel() ;
- model2.read(r, DEFAULT_BASE, getFormat()) ;
-
- assertTrue( "Models should be isomorphic", model.isIsomorphicWith(model2) );
+ rdfWriter.write(getTestModel(), writer, DEFAULT_BASE);
+
+ writer.close();
+
+ StringReader r = new StringReader(writer.toString());
+ Model model2 = ModelFactory.createDefaultModel();
+ model2.read(r, DEFAULT_BASE, getFormat());
+
+ assertTrue("Models should be isomorphic",
+ model.isIsomorphicWith(model2));
}
-
+
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AltContractTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AltContractTest.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AltContractTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/AltContractTest.java Sun Jan 5 11:28:03 2014
@@ -18,9 +18,8 @@
package com.hp.hpl.jena.rdf.model;
-import org.junit.Ignore;
-import org.junit.Test;
import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
import com.hp.hpl.jena.rdf.model.Alt;
import com.hp.hpl.jena.rdf.model.Bag;
@@ -31,7 +30,6 @@ import com.hp.hpl.jena.testing_framework
import static com.hp.hpl.jena.testing_framework.ModelHelper.*;
import static org.junit.Assert.*;
-@Ignore
@Contract(Alt.class)
public class AltContractTest<T extends Alt> {
@@ -46,7 +44,7 @@ public class AltContractTest<T extends A
return producer;
}
- @Test
+ @ContractTest
public void testDefaults() {
final Alt a = getAltProducer().newInstance();
final Literal tvLiteral = getAltProducer().getModel().createLiteral(
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/BagContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/BagContractTests.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/BagContractTests.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/BagContractTests.java Sun Jan 5 11:28:03 2014
@@ -18,13 +18,11 @@
package com.hp.hpl.jena.rdf.model;
-import org.junit.Ignore;
-import org.junit.Test;
import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
import com.hp.hpl.jena.testing_framework.IContainerProducer;
-@Ignore
@Contract(Bag.class)
public class BagContractTests<T extends Bag> {
private IContainerProducer<T> producer;
@@ -34,7 +32,7 @@ public class BagContractTests<T extends
this.producer = producer;
}
- @Test
+ @ContractTest
public void dummyTestBecauseThereAreNoRealTests() {
}
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/ContainerContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/ContainerContractTests.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/ContainerContractTests.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/ContainerContractTests.java Sun Jan 5 11:28:03 2014
@@ -29,11 +29,9 @@ import com.hp.hpl.jena.vocabulary.RDF;
import static org.junit.Assert.*;
import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
-@Ignore
@Contract(Container.class)
public class ContainerContractTests<T extends Container> {
@@ -49,7 +47,7 @@ public class ContainerContractTests<T ex
return producer;
}
- @Test
+ @ContractTest
public void testContainerOfIntegers() {
final int num = 10;
final Container c = getContainerProducer().newInstance();
@@ -64,21 +62,21 @@ public class ContainerContractTests<T ex
assertFalse(it.hasNext());
}
- @Test
+ @ContractTest
public void testContainerOfIntegersRemovingA() {
final boolean[] retain = { true, true, true, false, false, false,
false, false, true, true };
testContainerOfIntegersWithRemoving(retain);
}
- @Test
+ @ContractTest
public void testContainerOfIntegersRemovingB() {
final boolean[] retain = { false, true, true, false, false, false,
false, false, true, false };
testContainerOfIntegersWithRemoving(retain);
}
- @Test
+ @ContractTest
public void testContainerOfIntegersRemovingC() {
final boolean[] retain = { false, false, false, false, false, false,
false, false, false, false };
@@ -110,7 +108,7 @@ public class ContainerContractTests<T ex
}
}
- @Test
+ @ContractTest
public void testEmptyContainer() {
final Container c = getContainerProducer().newInstance();
assertTrue(getContainerProducer().getModel().contains(c, RDF.type,
@@ -126,7 +124,7 @@ public class ContainerContractTests<T ex
assertFalse(c.contains(tvString));
}
- @Test
+ @ContractTest
public void testFillingContainer() {
final Container c = getContainerProducer().newInstance();
final String lang = "fr";
@@ -159,7 +157,7 @@ public class ContainerContractTests<T ex
assertEquals(11, c.size());
}
- @Test
+ @ContractTest
public void testResourceCanAsContainer() {
Container c = getContainerProducer().newInstance();
final Resource res = c.asResource();
@@ -169,7 +167,7 @@ public class ContainerContractTests<T ex
Assert.assertTrue(res.canAs(Container.class));
}
- @Test
+ @ContractTest
public void testCreateAnonContainer() {
Container c = getContainerProducer().newInstance();
Assert.assertTrue(c.isAnon());
@@ -177,7 +175,7 @@ public class ContainerContractTests<T ex
RDF.type, getContainerProducer().getContainerType()));
}
- @Test
+ @ContractTest
public void testCreateNamedContainer() {
final String uri = "http://aldabaran/sirius";
final Container c = getContainerProducer().newInstance(uri);
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/InfModelContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/InfModelContractTests.java?rev=1555482&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/InfModelContractTests.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/InfModelContractTests.java Sun Jan 5 11:28:03 2014
@@ -0,0 +1,266 @@
+//package com.hp.hpl.jena.rdf.model;
+//
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.Iterator;
+//import java.util.List;
+//
+//import org.junit.After;
+//import org.junit.Before;
+//import org.junit.Ignore;
+//import org.junit.Test;
+//
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.modelAdd;
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.property;
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.resource;
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.statements;
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.txnBegin;
+//import static com.hp.hpl.jena.testing_framework.ModelHelper.txnCommit;
+//import static org.junit.Assert.*;
+//
+//import org.xenei.junit.contract.Contract;
+//
+//
+//import com.hp.hpl.jena.reasoner.Derivation;
+//import com.hp.hpl.jena.reasoner.Reasoner;
+//import com.hp.hpl.jena.reasoner.ValidityReport;
+//import com.hp.hpl.jena.testing_framework.AbstractInfModelProducer;
+//import com.hp.hpl.jena.testing_framework.AbstractModelProducer;
+//import com.hp.hpl.jena.vocabulary.RDF;
+//
+//@Ignore
+//@Contract(InfModel.class)
+//public class InfModelContractTests<T extends InfModel> {
+//
+// private AbstractInfModelProducer<T> producer;
+// private InfModel model;
+//
+// public InfModelContractTests() {
+// }
+//
+// protected final AbstractModelProducer<T> getProducer() {
+// return producer;
+// }
+//
+//
+// @Before
+// public final void beforeInfModelContractTests()
+// {
+// model = producer.newInstance();
+// }
+//
+// /**
+// * Return the raw RDF model being processed (i.e. the argument
+// * to the Reasonder.bind call that created this InfModel).
+// */
+// @Test
+// public void testGetRawModel()
+// {
+// Model m = model.getRawModel();
+// assertNotNull( "InfModel must have a raw model", m );
+// assertEquals( "Model bound in reasoner must be returned a raw model", producer.getBoundModel(), m );
+// }
+//
+// /**
+// * Return the Reasoner which is being used to answer queries to this graph.
+// */
+// @Test
+// public void testGetReasoner()
+// {
+// Reasoner r = model.getReasoner();
+// assertNotNull( "InfModel must have a reasoner", r);
+// assertEquals( "Producer should be same as in constructor", producer.getReasoner(), r );
+// }
+//
+// /**
+// * Cause the inference model to reconsult the underlying data to take
+// * into account changes. Normally changes are made through the InfModel's add and
+// * remove calls are will be handled appropriately. However, in some cases changes
+// * are made "behind the InfModels's back" and this forces a full reconsult of
+// * the changed data.
+// */
+// @Test
+// public void testRebind()
+// {
+// // just verify that it does not thorw an exception.
+// model.rebind();
+// }
+//
+// /**
+// * Perform any initial processing and caching. This call is optional. Most
+// * engines either have negligable set up work or will perform an implicit
+// * "prepare" if necessary. The call is provided for those occasions where
+// * substantial preparation work is possible (e.g. running a forward chaining
+// * rule system) and where an application might wish greater control over when
+// * this prepration is done rather than just leaving to be done at first query time.
+// */
+// @Test
+// public void testPprepare()
+// {
+// // just test that it does not throw an exception
+// model.prepare();
+// }
+//
+// /**
+// * Reset any internal caches. Some systems, such as the tabled backchainer,
+// * retain information after each query. A reset will wipe this information preventing
+// * unbounded memory use at the expense of more expensive future queries. A reset
+// * does not cause the raw data to be reconsulted and so is less expensive than a rebind.
+// */
+// @Test
+// public void testReset()
+// {
+// // just test that it does not thow an exception
+// model.reset();
+// }
+//
+// /**
+// * Test the consistency of the underlying data. This normally tests
+// * the validity of the bound instance data against the bound
+// * schema data.
+// * <p>Logically inconsistent models will be indicated by a ValidityReport which
+// * reports isValid() as false. Additional non.error problems, such as uninstantiatable classes,
+// * may be reported as warnings.
+// * @return a ValidityReport structure
+// */
+// @Test
+// public void testValidate()
+// {
+//
+// }
+//
+//
+// private void checkReturns(final String wantedStmts, final StmtIterator it) {
+// Statement[] stmts = statements(wantedStmts);
+// List<Statement> lst = it.toList();
+// assertEquals("wrong number of statements", stmts.length, lst.size());
+// for (Statement s : stmts) {
+// assertTrue("Missing statement " + s, lst.contains(s));
+// }
+// }
+// /** Find all the statements matching a pattern.
+// * <p>Return an iterator over all the statements in a model
+// * that match a pattern. The statements selected are those
+// * whose subject matches the <code>subject</code> argument,
+// * whose predicate matches the <code>predicate</code> argument
+// * and whose object matchesthe <code>object</code> argument.
+// * If an argument is <code>null</code> it matches anything.</p>
+// * <p>
+// * The s/p/o terms may refer to resources which are temporarily defined in the "posit" model.
+// * This allows one, for example, to query what resources are of type CE where CE is a
+// * class expression rather than a named class - put CE in the posit arg.</p>
+// *
+// * @return an iterator over the subjects
+// * @param subject The subject sought
+// * @param predicate The predicate sought
+// * @param object The value sought
+// */
+// @Test
+// public void testListStatements()
+// {
+// Model posit = ModelFactory.createDefaultModel();
+// assertFalse("Model had statements to start",
+// model.listStatements(null, null, (RDFNode) null, posit).hasNext());
+//
+// final Resource A = resource("Foo"), X = resource("X");
+// 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 = "Foo P1 O; Foo P1 B; Foo 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, posit));
+// checkReturns(S2, model.listStatements(A, P1, (RDFNode) null, posit));
+// checkReturns(S3, model.listStatements(X, null, Y, posit));
+//
+// List<Statement> lst = model.listStatements(resource("Foo"), P, O, posit)
+// .toList();
+// assertEquals("Wrong number of statements", 0, lst.size());
+//
+// lst = model.listStatements(null, null, (RDFNode) null, posit).toList();
+// List<Statement> stmts = new ArrayList<Statement>();
+// stmts.addAll(Arrays.asList(statements(S1)));
+// stmts.addAll(Arrays.asList(statements(S1)));
+// stmts.addAll(Arrays.asList(statements(S1)));
+// // 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"), posit)
+// .toList().size());
+// assertEquals(1, model.listStatements(null, null, anon, posit).toList().size());
+//
+// // not test with posit changes
+// // FIXME add posit driven changes.
+// }
+//
+// /**
+// * Switch on/off drivation logging. If this is switched on then every time an inference
+// * is a made that fact is recorded and the resulting record can be access through a later
+// * getDerivation call. This may consume a lot of space!
+// */
+// @Test
+// public void testDerivationLogging()
+// {
+// Iterator<Derivation> derivation = null;
+// model.setDerivationLogging(false);
+// producer.populateModel(model);
+// derivation = model.getDerivation( producer.getDerivationStatement() );
+// assertNull( "Derivation logging is off, there should be no derivations", derivation );
+//
+// InfModel model2 = producer.newInstance();
+// model2.setDerivationLogging(true);
+// producer.populateModel( model2 );
+// derivation = model2.getDerivation( producer.getDerivationStatement());
+// assertNotNull( "Derivation logging is on, there should be derivations", derivation );
+// assertTrue( "Derivation should contain values", derivation.hasNext());
+//
+// derivation = model2.getDerivation( producer.getNoDerivationStatement());
+// assertNull( "The 'No derivation statement' returned a derivation", derivation );
+// }
+//
+//
+//
+// /**
+// * Returns a derivations model. The rule reasoners typically create a
+// * graph containing those triples added to the base graph due to rule firings.
+// * In some applications it can useful to be able to access those deductions
+// * directly, without seeing the raw data which triggered them. In particular,
+// * this allows the forward rules to be used as if they were rewrite transformation
+// * rules.
+// * @return the deductions model, if relevant for this class of inference
+// * engine or null if not.
+// */
+// @Test
+// public void testGetDeductionsModel()
+// {
+// Model derivations = model.getDeductionsModel();
+// if (producer.supportsDeductionsModel())
+// {
+// derivations = model.getDeductionsModel();
+// assertNotNull( "InfModel supports deductions model and should not null", derivations );
+// assertTrue( "Initial derivation model should be empty", derivations.isEmpty());
+// producer.populateModel(model);
+// derivations = model.getDeductionsModel();
+// assertFalse( "Derivation model from populated model should not be empty", derivations.isEmpty());
+//
+// // test derivation
+//
+//
+// } else {
+// assertNull( "InfModel does not support deductions model and should return null", derivations );
+// }
+//
+// }
+//
+// }
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/InfModelContractTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/LockContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/LockContractTests.java?rev=1555482&r1=1555481&r2=1555482&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/LockContractTests.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/LockContractTests.java Sun Jan 5 11:28:03 2014
@@ -20,11 +20,10 @@ package com.hp.hpl.jena.rdf.model;
import org.junit.After;
import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractTest;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.testing_framework.ContractTemplate;
@@ -38,9 +37,9 @@ import org.xenei.junit.contract.IProduce
* independent or not.
*
*/
-@Ignore
@Contract(Lock.class)
-public class LockContractTests<T extends Lock> extends ContractTemplate<T> {
+public class LockContractTests<T extends Lock> extends
+ ContractTemplate<IProducer<T>> {
// @SuppressWarnings("unchecked")
// public LockContractTests() {
@@ -75,7 +74,7 @@ public class LockContractTests<T extends
*
* @throws Throwable
*/
- @Test
+ @ContractTest
public void testCriticalSection_Nesting() {
int MODEL1 = 0;
int MODEL2 = 1;
@@ -221,7 +220,7 @@ public class LockContractTests<T extends
/**
* Verify that critical seciton works in parallel usage.
*/
- @Test
+ @ContractTest
public void testCriticalSection_Parallel() {
int threadCount = 0; // current number of threads.
long sleep = 100; // number of miliseconds to sleep in processing