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/11/04 22:57:29 UTC

svn commit: r1538788 - in /jena/Experimental/new-test: pom.xml src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java

Author: claude
Date: Mon Nov  4 21:57:28 2013
New Revision: 1538788

URL: http://svn.apache.org/r1538788
Log:
Updated RDFReaderFContractTests
Updated pom to download junit-contracts

Modified:
    jena/Experimental/new-test/pom.xml
    jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java

Modified: jena/Experimental/new-test/pom.xml
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/pom.xml?rev=1538788&r1=1538787&r2=1538788&view=diff
==============================================================================
--- jena/Experimental/new-test/pom.xml (original)
+++ jena/Experimental/new-test/pom.xml Mon Nov  4 21:57:28 2013
@@ -1,38 +1,68 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.apache.jena</groupId>
-  <artifactId>new-test</artifactId>
-  <version>2.10.2-SNAPSHOT</version>
-  <name>new Jena tests</name>
-  <description>New test suite for Jena project.   This is a complete rewrite of the existing tests</description>
-  <parent>
-  	<groupId>org.apache.jena</groupId>
-  	<artifactId>jena-parent</artifactId>
-  	<version>8-SNAPSHOT</version>
-  </parent>
-  <dependencies>
-  <dependency>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.jena</groupId>
+	<artifactId>new-test</artifactId>
+	<version>2.10.2-SNAPSHOT</version>
+	<name>new Jena tests</name>
+	<description>New test suite for Jena project.   This is a complete rewrite of the existing tests</description>
+	<parent>
+		<groupId>org.apache.jena</groupId>
+		<artifactId>jena-parent</artifactId>
+		<version>8-SNAPSHOT</version>
+	</parent>
+	<repositories>
+		<repository>
+			<id>snapshot-repository-xenei-org</id>
+			<name>Xenei Snapshot Repository</name>
+			<url> https://oss.sonatype.org/content/repositories/snapshots/</url>
+			<layout>default</layout>
+			<releases>
+				<enabled>false</enabled>
+				<updatePolicy>never</updatePolicy>
+			</releases>
+			<snapshots>
+				<enabled>true</enabled>
+				<updatePolicy>never</updatePolicy>
+			</snapshots>
+		</repository>
+	</repositories>
+	<dependencies>
+		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<version>${ver.junit}</version>
 		</dependency>
-  <dependency>
+		<dependency>
 			<groupId>org.apache.jena</groupId>
 			<artifactId>apache-jena-libs</artifactId>
 			<version>2.11.1-SNAPSHOT</version>
 			<type>pom</type>
 		</dependency>
-  <dependency>
-  	<groupId>org.mockito</groupId>
-  	<artifactId>mockito-all</artifactId>
-  	<version>1.9.5</version>
-  	<scope>test</scope>
-  </dependency>
-  <dependency>
-  	<groupId>org.xenei</groupId>
-  	<artifactId>junit-contracts</artifactId>
-  	<version>0.0.2-SNAPSHOT</version>
-  	<scope>test</scope>
-  </dependency>
-  </dependencies>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>1.9.5</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.xenei</groupId>
+			<artifactId>junit-contracts</artifactId>
+			<version>0.0.2-SNAPSHOT</version>
+			<!-- <scope>test</scope> -->
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.1</version>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
 </project>
\ No newline at end of file

Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java?rev=1538788&r1=1538787&r2=1538788&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java Mon Nov  4 21:57:28 2013
@@ -7,7 +7,9 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.xenei.junit.contract.Contract;
 
+import com.hp.hpl.jena.rdf.model.impl.RDFReaderFImpl;
 import com.hp.hpl.jena.shared.NoReaderForLangException;
+
 import org.xenei.junit.contract.IProducer;
 
 import com.hp.hpl.jena.testing_framework.ContractTemplate;
@@ -79,7 +81,6 @@ public class RDFReaderFContractTests<T e
 
 	}
 
-	@Ignore("enable test when ability to remove reader is available")
 	@Test
 	public void testSetReaderClassName() throws Exception {
 		RDFReaderF readerF = getProducer().newInstance();
@@ -94,13 +95,133 @@ public class RDFReaderFContractTests<T e
 			assertEquals("Wrong reader type", DummyReader.class,
 					reader.getClass());
 		} finally {
-			String s2 = readerF.setReaderClassName("foo", null);
-			assertEquals(DummyReader.class.getCanonicalName(), s2);
+			readerF.resetRDFReaderF();
+		}
+	}
+	
+	@Test
+	public void testResetRDFReaderF() throws Exception {
+		RDFReaderF readerF = getProducer().newInstance();
+			String before = readerF.setReaderClassName("foo",
+					DummyReader.class.getName());
+
+			assertNull("Should not be an existing name", before);
+
+			RDFReader reader = readerF.getReader("foo");
+			assertEquals("Wrong reader type", DummyReader.class,
+					reader.getClass());
+			readerF.resetRDFReaderF();
+			
+			
+		try {
+			readerF.getReader("foo");
+			fail( "Should have thrown NoReaderForLangException");
+		} catch( NoReaderForLangException expected ){
+			// expected
+		}
+
+	}
+
+	@Test
+	public void testRemoveReader_String_AfterInsert() throws Exception {
+		RDFReaderF readerF = getProducer().newInstance();
+		try {
+			String before = readerF.setReaderClassName("foo",
+					DummyReader.class.getName());
+
+			assertNull("Should not be an existing name", before);
 
 			RDFReader reader = readerF.getReader("foo");
-			assertNull("should not return a reader", reader);
+			assertEquals("Wrong reader type", DummyReader.class,
+					reader.getClass());
+			
+			String after = readerF.removeReader( "foo" );
+			String expectedName = RDFReaderFContractTests.class.getCanonicalName()+"$DummyReader";
+			assertEquals( "Should return reader name", expectedName, after );
+			
+			try {
+				readerF.getReader("foo");
+				fail( "Should have thrown NoReaderForLangException");
+			} catch( NoReaderForLangException expected ){
+				// expected
+			}
+			
+			
+		} finally {
+			readerF.resetRDFReaderF();
 		}
+
+	}
+	
+	@Test
+	public void testGlobalNatureOfReaderRegistration()
+	{
+		// changes in one reader impact all readers.
+		RDFReaderF readerF = getProducer().newInstance();
+		RDFReaderF defaultF = new RDFReaderFImpl();
+		
+		try {
+			String before = readerF.setReaderClassName("foo",
+					DummyReader.class.getName());
+
+			assertNull("Should not be an existing name", before);
+
+			RDFReader reader = readerF.getReader("foo");
+			assertEquals("Wrong reader type", DummyReader.class,
+					reader.getClass());
+			
+			reader = defaultF.getReader( "foo" );
+			assertEquals("Default reader type was not set type", DummyReader.class,
+					reader.getClass());
+			
+		} finally {
+
+			readerF.resetRDFReaderF();
+		}
+		try {
+			readerF.getReader("foo");;
+			fail( "Should have thrown NoReaderForLangException");
+		} catch( NoReaderForLangException expected ){
+			// expected
+		}
+		try {
+			defaultF.getReader("foo");;
+			fail( "Default should have thrown NoReaderForLangException");
+		} catch( NoReaderForLangException expected ){
+			// expected
+		}
+		
+	}
+	
+	@Test
+	public void testRemoveReader_String_requiredLang() throws Exception {
+		RDFReaderF readerF = getProducer().newInstance();
+		try {
+			try {
+				readerF.getReader( "TURTLE");
+			} catch( NoReaderForLangException expected ){
+				fail( "Language 'TURTLE' does not have a reader");
+			}
+			try {
+				readerF.removeReader("TURTLE");
+				fail( "Should have thrown an IllegalArgumentException");
+			}
+			catch (IllegalArgumentException expected)
+			{
+				// expected
+			}
+			try {
+				readerF.getReader( "TURTLE");
+			} catch( NoReaderForLangException e ){
+				fail( "getReader should not have failed but TURTLE was removed");
+			}
+		}
+		finally {
+			readerF.resetRDFReaderF();
+		}
+
 	}
+	
 
 	public static class DummyReader implements RDFReader {
 



Re: svn commit: r1538788 - in /jena/Experimental/new-test: pom.xml src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java

Posted by Claude Warren <cl...@xenei.com>.
I need to fix the update never.

I will release the junit-contract stuff soon, so we can remove the
dependency.

However, the new-tests only cover the core functionality currently.  I
still need to extend it to the other packages.




On Mon, Nov 4, 2013 at 11:22 PM, Andy Seaborne <an...@apache.org> wrote:

>
> On 04/11/13 21:57, claude@apache.org wrote:
> > +        <repository>
> > +            <id>snapshot-repository-xenei-org</id>
> > +            <name>Xenei Snapshot Repository</name>
> > + <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
> > +            <layout>default</layout>
> > +            <releases>
> > +                <enabled>false</enabled>
> > +                <updatePolicy>never</updatePolicy>
> > +            </releases>
> > +            <snapshots>
> > +                <enabled>true</enabled>
>
>     err .... snapshots+never?
>
> That means no picking up any snapshot rebuilds you put in if the developer
> has downloaded once already.
>
>
> > +                <updatePolicy>never</updatePolicy>
> > +            </snapshots>
> > +        </repository>
>
> Just so we're all on the same page - project releases need to depend only
> on maven central.
>
> This is OK for now (maven central does not have snapshots;
> oss.sonatype.org does get replicated, not sure the frequency) but before
> a release involving new-test, we'll have to be using released artifacts in
> maven central.
>
>     Andy
>
>
>


-- 
I like: Like Like - The likeliest place on the web<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Re: svn commit: r1538788 - in /jena/Experimental/new-test: pom.xml src/test/java/com/hp/hpl/jena/rdf/model/RDFReaderFContractTests.java

Posted by Andy Seaborne <an...@apache.org>.
On 04/11/13 21:57, claude@apache.org wrote:
 > +        <repository>
 > +            <id>snapshot-repository-xenei-org</id>
 > +            <name>Xenei Snapshot Repository</name>
 > + 
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
 > +            <layout>default</layout>
 > +            <releases>
 > +                <enabled>false</enabled>
 > +                <updatePolicy>never</updatePolicy>
 > +            </releases>
 > +            <snapshots>
 > +                <enabled>true</enabled>

     err .... snapshots+never?

That means no picking up any snapshot rebuilds you put in if the 
developer has downloaded once already.

 > +                <updatePolicy>never</updatePolicy>
 > +            </snapshots>
 > +        </repository>

Just so we're all on the same page - project releases need to depend 
only on maven central.

This is OK for now (maven central does not have snapshots; 
oss.sonatype.org does get replicated, not sure the frequency) but before 
a release involving new-test, we'll have to be using released artifacts 
in maven central.

     Andy