|
From: <cw...@us...> - 2006-12-10 15:20:46
|
Revision: 103
http://svn.sourceforge.net/mptstore/?rev=103&view=rev
Author: cwilper
Date: 2006-12-10 07:20:42 -0800 (Sun, 10 Dec 2006)
Log Message:
-----------
Testing now uses JUnit 4
Modified Paths:
--------------
trunk/build.properties
trunk/src/test/org/nsdl/mptstore/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/core/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/core/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorIntegrationTest.java
trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorUnitTest.java
trunk/src/test/org/nsdl/mptstore/core/DatabaseAdaptorIntegrationTest.java
trunk/src/test/org/nsdl/mptstore/core/GenericDatabaseAdaptorIntegrationTest.java
trunk/src/test/org/nsdl/mptstore/impl/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/impl/derby/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorUnitTest.java
trunk/src/test/org/nsdl/mptstore/impl/h2/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorUnitTest.java
trunk/src/test/org/nsdl/mptstore/impl/postgres/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorUnitTest.java
trunk/src/test/org/nsdl/mptstore/query/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/query/lang/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/query/lang/spo/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/query/lang/spo/SPOQueryCompilerUnitTest.java
trunk/src/test/org/nsdl/mptstore/rdf/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/rdf/LiteralUnitTest.java
trunk/src/test/org/nsdl/mptstore/util/AllUnitTests.java
trunk/src/test/org/nsdl/mptstore/util/NTriplesUtilUnitTest.java
Added Paths:
-----------
trunk/lib/junit-4.1.jar
Removed Paths:
-------------
trunk/lib/junit.jar
trunk/src/test/org/nsdl/mptstore/impl/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/impl/derby/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorIntegrationTest.java
trunk/src/test/org/nsdl/mptstore/impl/h2/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorIntegrationTest.java
trunk/src/test/org/nsdl/mptstore/impl/postgres/AllIntegrationTests.java
trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorIntegrationTest.java
Modified: trunk/build.properties
===================================================================
--- trunk/build.properties 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/build.properties 2006-12-10 15:20:42 UTC (rev 103)
@@ -24,8 +24,8 @@
lib.commons-pool = lib/commons-pool-1.2.jar
lib.commons-collections = lib/commons-collections-3.1.jar
-# JUnit 3.8.1 from http://junit.org/
-lib.junit = lib/junit.jar
+# JUnit 4.1 from http://junit.org/
+lib.junit = lib/junit-4.1.jar
# Postgres JDBC driver from http://jdbc.postgresql.org/
lib.postgres-driver = lib/postgresql-8.1-407.jdbc3.jar
Added: trunk/lib/junit-4.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/junit-4.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/lib/junit.jar
===================================================================
(Binary files differ)
Modified: trunk/src/test/org/nsdl/mptstore/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,25 +1,10 @@
package org.nsdl.mptstore;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(Whatever.class);
-
- // sub-package suites
- suite.addTest(org.nsdl.mptstore.core.AllIntegrationTests.suite());
- suite.addTest(org.nsdl.mptstore.impl.AllIntegrationTests.suite());
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.nsdl.mptstore.core.AllIntegrationTests.class
+})
+public class AllIntegrationTests { }
Modified: trunk/src/test/org/nsdl/mptstore/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,27 +1,14 @@
package org.nsdl.mptstore;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- //suite.addUnitTestSuite(Whatever.class);
-
- // sub-package suites
- suite.addTest(org.nsdl.mptstore.core.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.impl.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.query.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.rdf.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.util.AllUnitTests.suite());
-
- return suite;
-
- }
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.nsdl.mptstore.core.AllUnitTests.class,
+ org.nsdl.mptstore.impl.AllUnitTests.class,
+ org.nsdl.mptstore.query.AllUnitTests.class,
+ org.nsdl.mptstore.rdf.AllUnitTests.class,
+ org.nsdl.mptstore.util.AllUnitTests.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/core/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,21 +1,11 @@
package org.nsdl.mptstore.core;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(GenericDatabaseAdaptorIntegrationTest.class);
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ GenericDatabaseAdaptorIntegrationTest.class,
+ DDLGeneratorIntegrationTest.class
+})
+public class AllIntegrationTests { }
Modified: trunk/src/test/org/nsdl/mptstore/core/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +1,10 @@
package org.nsdl.mptstore.core;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(Whatever.class);
-
- return suite;
-
- }
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ //SomeUnitTest.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,6 +1,5 @@
package org.nsdl.mptstore.core;
-import java.util.Iterator;
import java.util.List;
import java.sql.Connection;
@@ -9,64 +8,53 @@
import javax.sql.DataSource;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.nsdl.mptstore.TestConfig;
-public abstract class DDLGeneratorIntegrationTest extends TestCase {
+public class DDLGeneratorIntegrationTest {
- private String _className;
+ private static DDLGenerator GENERATOR;
+ private static DataSource POOL;
+
private Connection _conn;
- static {
+ @BeforeClass
+ public static void setUpClass() {
TestConfig.init();
+ GENERATOR = TestConfig.getDDLGenerator();
+ POOL = TestConfig.getTestDataSource(2);
}
- protected DDLGeneratorIntegrationTest(String name,
- String className) {
- super(name);
- _className = className;
- }
-
- /**
- * Get an instance of the DDLGenerator we're testing.
- *
- * The DDLGenerator implementation must have a public no-arg
- * constructor.
- */
- protected DDLGenerator getInstance() {
- try {
- return (DDLGenerator) Class.forName(_className).newInstance();
- } catch (Throwable th) {
- throw new RuntimeException("Error getting instance of "
- + _className, th);
- }
- }
-
+ @Before
public void setUp() throws Exception {
- DataSource pool = TestConfig.getTestDataSource(2);
- _conn = pool.getConnection();
+ _conn = POOL.getConnection();
}
+ @After
public void tearDown() throws Exception {
_conn.close();
}
+ @Test
public void testCreateAndDropMapTable() {
try {
- executeUpdates(getInstance().getCreateMapTableDDL("tMap"));
- executeUpdates(getInstance().getDropMapTableDDL("tMap"));
+ executeUpdates(GENERATOR.getCreateMapTableDDL("tMap"));
+ executeUpdates(GENERATOR.getDropMapTableDDL("tMap"));
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
+ @Test
public void testCreateAndDropSOTable() {
try {
- executeUpdates(getInstance().getCreateMapTableDDL("t1"));
- executeUpdates(getInstance().getDropMapTableDDL("t1"));
+ executeUpdates(GENERATOR.getCreateMapTableDDL("t1"));
+ executeUpdates(GENERATOR.getDropMapTableDDL("t1"));
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -74,11 +62,10 @@
private void executeUpdates(List<String> sql) throws SQLException {
- Iterator<String> iter = sql.iterator();
Statement st = _conn.createStatement();
try {
- while (iter.hasNext()) {
- st.executeUpdate(iter.next());
+ for (String statement : sql) {
+ st.executeUpdate(statement);
}
} finally {
st.close();
Modified: trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/DDLGeneratorUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -2,22 +2,21 @@
import java.util.List;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
import org.nsdl.mptstore.TestConfig;
-public abstract class DDLGeneratorUnitTest extends TestCase {
+public abstract class DDLGeneratorUnitTest {
private String _className;
- static {
+ public static void setUpClass() {
TestConfig.init();
}
- protected DDLGeneratorUnitTest(String name,
- String className) {
- super(name);
+ protected DDLGeneratorUnitTest(String className) {
_className = className;
}
@@ -36,24 +35,28 @@
}
}
+ @Test
public void testGetCreateMapTableDDL() {
List<String> ddl = getInstance().getCreateMapTableDDL("tableName");
assertTrue(_className + ".getCreateMapTableDDL returned empty list",
ddl.size() > 0);
}
-
+
+ @Test
public void testGetDropMapTableDDL() {
List<String> ddl = getInstance().getDropMapTableDDL("tableName");
assertTrue(_className + ".getDropMapTableDDL returned empty list",
ddl.size() > 0);
}
-
+
+ @Test
public void testGetCreateSOTableDDL() {
List<String> ddl = getInstance().getCreateSOTableDDL("tableName");
assertTrue(_className + ".getCreateSOTableDDL returned empty list",
ddl.size() > 0);
}
-
+
+ @Test
public void testGetDropSOTableDDL() {
List<String> ddl = getInstance().getDropSOTableDDL("tableName");
assertTrue(_className + ".getDropSOTableDDL returned empty list",
Modified: trunk/src/test/org/nsdl/mptstore/core/DatabaseAdaptorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/DatabaseAdaptorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/DatabaseAdaptorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -11,8 +11,12 @@
import javax.sql.DataSource;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import org.nsdl.mptstore.query.QueryResults;
import org.nsdl.mptstore.query.lang.QueryLanguage;
@@ -27,34 +31,40 @@
import org.nsdl.mptstore.TestConfig;
-public abstract class DatabaseAdaptorIntegrationTest extends TestCase {
+public abstract class DatabaseAdaptorIntegrationTest {
private static final String XSD_NS = "http://www.w3.org/2001/XMLSchema#";
- private static final URIReference XSD_INT;
+ private static URIReference XSD_INT;
- private static final URIReference RESOURCE_ONE;
- private static final URIReference RESOURCE_TWO;
+ private static URIReference RESOURCE_ONE;
+ private static URIReference RESOURCE_TWO;
- private static final URIReference TITLE;
- private static final URIReference ENGLISH_TITLE;
- private static final URIReference SPANISH_TITLE;
- private static final URIReference RESOURCE_NUM;
- private static final URIReference NEXT_RESOURCE;
- private static final URIReference PREV_RESOURCE;
+ private static URIReference TITLE;
+ private static URIReference ENGLISH_TITLE;
+ private static URIReference SPANISH_TITLE;
+ private static URIReference RESOURCE_NUM;
+ private static URIReference NEXT_RESOURCE;
+ private static URIReference PREV_RESOURCE;
- private static final Literal R1_TITLE;
- private static final Literal R1_ENGLISH_TITLE;
- private static final Literal R1_SPANISH_TITLE;
- private static final Literal R1_RESOURCE_NUM;
+ private static Literal R1_TITLE;
+ private static Literal R1_ENGLISH_TITLE;
+ private static Literal R1_SPANISH_TITLE;
+ private static Literal R1_RESOURCE_NUM;
- private static final Literal R2_TITLE;
- private static final Literal R2_ENGLISH_TITLE;
- private static final Literal R2_SPANISH_TITLE;
- private static final Literal R2_RESOURCE_NUM;
+ private static Literal R2_TITLE;
+ private static Literal R2_ENGLISH_TITLE;
+ private static Literal R2_SPANISH_TITLE;
+ private static Literal R2_RESOURCE_NUM;
- static {
+ private static DataSource POOL;
+
+ private static DatabaseAdaptor ADAPTOR;
+
+ @BeforeClass
+ public static void setUpClass() {
TestConfig.init();
+ POOL = TestConfig.getTestDataSource(2);
try {
XSD_INT = new URIReference(XSD_NS + "int");
@@ -83,24 +93,16 @@
}
}
- private DataSource _pool;
-
- private DatabaseAdaptor _adaptor;
-
- protected DatabaseAdaptorIntegrationTest(String name) {
- super(name);
- }
-
+ @Before
public void setUp() throws Exception {
- _pool = TestConfig.getTestDataSource(2);
- _adaptor = initAdaptor(_pool, "tMap", "t");
+ ADAPTOR = getAdaptor(POOL, "tMap", "t");
clearTriples(false);
}
- private void clearTriples(boolean andMapTable) throws Exception {
- Connection conn = _pool.getConnection();
+ private static void clearTriples(boolean andMapTable) throws Exception {
+ Connection conn = POOL.getConnection();
try {
- _adaptor.deleteAllTriples(conn);
+ ADAPTOR.deleteAllTriples(conn);
if (andMapTable) {
try {
executeUpdates(conn, TestConfig.getDDLGenerator().getDropMapTableDDL("tMap"));
@@ -112,42 +114,27 @@
}
}
+ @After
public void tearDown() throws Exception {
+ clearTriples(false);
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
clearTriples(true);
}
- public abstract DatabaseAdaptor initAdaptor(DataSource pool,
- String mapTable,
- String soTablePrefix)
+ public abstract DatabaseAdaptor getAdaptor(DataSource pool,
+ String mapTable,
+ String soTablePrefix)
throws Exception;
/**
- * Get our test set of ten triples.
- */
- private Set<Triple> getTestTriples() throws Exception {
-
- Set<Triple> triples = new HashSet<Triple>();
-
- triples.add(new Triple(RESOURCE_ONE, TITLE, R1_TITLE));
- triples.add(new Triple(RESOURCE_ONE, ENGLISH_TITLE, R1_ENGLISH_TITLE));
- triples.add(new Triple(RESOURCE_ONE, SPANISH_TITLE, R1_SPANISH_TITLE));
- triples.add(new Triple(RESOURCE_ONE, RESOURCE_NUM, R1_RESOURCE_NUM));
- triples.add(new Triple(RESOURCE_ONE, NEXT_RESOURCE, RESOURCE_TWO));
-
- triples.add(new Triple(RESOURCE_TWO, TITLE, R2_TITLE));
- triples.add(new Triple(RESOURCE_TWO, ENGLISH_TITLE, R2_ENGLISH_TITLE));
- triples.add(new Triple(RESOURCE_TWO, SPANISH_TITLE, R2_SPANISH_TITLE));
- triples.add(new Triple(RESOURCE_TWO, RESOURCE_NUM, R2_RESOURCE_NUM));
- triples.add(new Triple(RESOURCE_TWO, PREV_RESOURCE, RESOURCE_ONE));
-
- return triples;
- }
-
- /**
* Test that after adding, then deleting our test set
* of triples, querying for all triples returns an
* empty set.
*/
+ @Test
public void testDeleteTriples() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -160,6 +147,7 @@
* Test that after adding our test set of triples,
* querying for all triples returns the same set.
*/
+ @Test
public void testAddTriples() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -167,10 +155,12 @@
assertEquals(input, output);
}
+ @Test
public void testQuerySPOAll() throws Exception {
// this case is covered by testAddTriples
}
+ @Test
public void testQuerySPOWithFixedS() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -185,6 +175,7 @@
assertEquals(0, output.size());
}
+ @Test
public void testQuerySPOWithFixedSP() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -205,6 +196,7 @@
assertEquals(0, output.size());
}
+ @Test
public void testQuerySPOWithFixedSPO() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -234,6 +226,7 @@
assertEquals(0, output.size());
}
+ @Test
public void testQuerySPOWithFixedP() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -245,6 +238,7 @@
assertEquals(0, output.size());
}
+ @Test
public void testQuerySPOWithFixedPO() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -262,6 +256,7 @@
assertEquals(0, output.size());
}
+ @Test
public void testQuerySPOWithFixedO() throws Exception {
Set<Triple> input = getTestTriples();
add(input);
@@ -283,13 +278,35 @@
}
+ /**
+ * Get our test set of ten triples.
+ */
+ private static Set<Triple> getTestTriples() throws Exception {
+
+ Set<Triple> triples = new HashSet<Triple>();
+
+ triples.add(new Triple(RESOURCE_ONE, TITLE, R1_TITLE));
+ triples.add(new Triple(RESOURCE_ONE, ENGLISH_TITLE, R1_ENGLISH_TITLE));
+ triples.add(new Triple(RESOURCE_ONE, SPANISH_TITLE, R1_SPANISH_TITLE));
+ triples.add(new Triple(RESOURCE_ONE, RESOURCE_NUM, R1_RESOURCE_NUM));
+ triples.add(new Triple(RESOURCE_ONE, NEXT_RESOURCE, RESOURCE_TWO));
+
+ triples.add(new Triple(RESOURCE_TWO, TITLE, R2_TITLE));
+ triples.add(new Triple(RESOURCE_TWO, ENGLISH_TITLE, R2_ENGLISH_TITLE));
+ triples.add(new Triple(RESOURCE_TWO, SPANISH_TITLE, R2_SPANISH_TITLE));
+ triples.add(new Triple(RESOURCE_TWO, RESOURCE_NUM, R2_RESOURCE_NUM));
+ triples.add(new Triple(RESOURCE_TWO, PREV_RESOURCE, RESOURCE_ONE));
+
+ return triples;
+ }
+
private Set<Triple> spo(String query) throws Exception {
Set<Triple> triples = new HashSet<Triple>();
- Connection conn = _pool.getConnection();
+ Connection conn = POOL.getConnection();
conn.setAutoCommit(false);
- QueryResults results = _adaptor.query(conn,
+ QueryResults results = ADAPTOR.query(conn,
QueryLanguage.SPO,
TestConfig.getFetchSize(),
true,
@@ -310,10 +327,10 @@
}
private void add(Set<Triple> triples) throws Exception {
- Connection conn = _pool.getConnection();
+ Connection conn = POOL.getConnection();
try {
conn.setAutoCommit(false);
- _adaptor.addTriples(conn, triples.iterator());
+ ADAPTOR.addTriples(conn, triples.iterator());
} finally {
conn.setAutoCommit(true);
conn.close();
@@ -321,17 +338,17 @@
}
private void delete(Set<Triple> triples) throws Exception {
- Connection conn = _pool.getConnection();
+ Connection conn = POOL.getConnection();
try {
conn.setAutoCommit(false);
- _adaptor.deleteTriples(conn, triples.iterator());
+ ADAPTOR.deleteTriples(conn, triples.iterator());
} finally {
conn.setAutoCommit(true);
conn.close();
}
}
- private void executeUpdates(Connection conn,
+ private static void executeUpdates(Connection conn,
List<String> sql) throws SQLException {
Iterator<String> iter = sql.iterator();
Modified: trunk/src/test/org/nsdl/mptstore/core/GenericDatabaseAdaptorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/core/GenericDatabaseAdaptorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/core/GenericDatabaseAdaptorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -2,25 +2,25 @@
import javax.sql.DataSource;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
import org.nsdl.mptstore.TestConfig;
public class GenericDatabaseAdaptorIntegrationTest
extends DatabaseAdaptorIntegrationTest {
- static {
- TestConfig.init();
- }
+ private static DatabaseAdaptor ADAPTOR;
- public GenericDatabaseAdaptorIntegrationTest(String name) {
- super(name);
+ public synchronized DatabaseAdaptor getAdaptor(DataSource dataSource,
+ String mapTable, String soTablePrefix)
+ throws Exception {
+ if (ADAPTOR == null) {
+ ADAPTOR = initAdaptor(dataSource, mapTable, soTablePrefix);
+ }
+ return ADAPTOR;
}
- public DatabaseAdaptor initAdaptor(DataSource dataSource,
- String mapTable,
- String soTablePrefix) throws Exception {
+ private static DatabaseAdaptor initAdaptor(DataSource dataSource,
+ String mapTable, String soTablePrefix)
+ throws Exception {
TableManager tableManager =
new BasicTableManager(dataSource,
@@ -33,8 +33,4 @@
}
- public static void main(String[] args) {
- TestRunner.run(GenericDatabaseAdaptorIntegrationTest.class);
- }
-
}
Deleted: trunk/src/test/org/nsdl/mptstore/impl/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,36 +0,0 @@
-package org.nsdl.mptstore.impl;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
-
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(Whatever.class);
-
- // sub-package suites
- String testDatabase = TestConfig.getTestDatabase();
-
- if (testDatabase.equals("derby")) {
- suite.addTest(org.nsdl.mptstore.impl.derby.AllIntegrationTests.suite());
- } else if (testDatabase.equals("h2")) {
- suite.addTest(org.nsdl.mptstore.impl.h2.AllIntegrationTests.suite());
- } else if (testDatabase.equals("postgres")) {
- suite.addTest(org.nsdl.mptstore.impl.postgres.AllIntegrationTests.suite());
- } else {
- throw new Exception("Unrecognized test.database: " + testDatabase);
- }
-
- return suite;
-
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,28 +1,12 @@
package org.nsdl.mptstore.impl;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-import org.nsdl.mptstore.TestConfig;
-
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(Whatever.class);
-
- // sub-package suites
- suite.addTest(org.nsdl.mptstore.impl.derby.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.impl.h2.AllUnitTests.suite());
- suite.addTest(org.nsdl.mptstore.impl.postgres.AllUnitTests.suite());
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.nsdl.mptstore.impl.derby.AllUnitTests.class,
+ org.nsdl.mptstore.impl.h2.AllUnitTests.class,
+ org.nsdl.mptstore.impl.postgres.AllUnitTests.class
+})
+public class AllUnitTests { }
Deleted: trunk/src/test/org/nsdl/mptstore/impl/derby/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/derby/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/derby/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +0,0 @@
-package org.nsdl.mptstore.impl.derby;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(DerbyDDLGeneratorIntegrationTest.class);
-
- return suite;
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/derby/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/derby/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/derby/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +1,10 @@
package org.nsdl.mptstore.impl.derby;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(DerbyDDLGeneratorUnitTest.class);
-
- return suite;
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ DerbyDDLGeneratorUnitTest.class
+})
+public class AllUnitTests { }
Deleted: trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,24 +0,0 @@
-package org.nsdl.mptstore.impl.derby;
-
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
-import org.nsdl.mptstore.core.DDLGeneratorIntegrationTest;
-
-public class DerbyDDLGeneratorIntegrationTest
- extends DDLGeneratorIntegrationTest {
-
- static {
- TestConfig.init();
- }
-
- public DerbyDDLGeneratorIntegrationTest(String name) {
- super(name, DerbyDDLGenerator.class.getName());
- }
-
- public static void main(String[] args) {
- TestRunner.run(DerbyDDLGeneratorIntegrationTest.class);
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/derby/DerbyDDLGeneratorUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,29 +1,11 @@
package org.nsdl.mptstore.impl.derby;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
import org.nsdl.mptstore.core.DDLGeneratorUnitTest;
public class DerbyDDLGeneratorUnitTest extends DDLGeneratorUnitTest {
- static {
- TestConfig.init();
+ public DerbyDDLGeneratorUnitTest() {
+ super(DerbyDDLGenerator.class.getName());
}
- public DerbyDDLGeneratorUnitTest(String name) {
- super(name, DerbyDDLGenerator.class.getName());
- }
-
- public void setUp() {
- }
-
- public void tearDown() {
- }
-
- public static void main(String[] args) {
- TestRunner.run(DerbyDDLGeneratorUnitTest.class);
- }
-
}
Deleted: trunk/src/test/org/nsdl/mptstore/impl/h2/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/h2/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/h2/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +0,0 @@
-package org.nsdl.mptstore.impl.h2;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(H2DDLGeneratorIntegrationTest.class);
-
- return suite;
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/h2/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/h2/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/h2/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +1,10 @@
package org.nsdl.mptstore.impl.h2;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(H2DDLGeneratorUnitTest.class);
-
- return suite;
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ H2DDLGeneratorUnitTest.class
+})
+public class AllUnitTests { }
Deleted: trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,24 +0,0 @@
-package org.nsdl.mptstore.impl.h2;
-
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
-import org.nsdl.mptstore.core.DDLGeneratorIntegrationTest;
-
-public class H2DDLGeneratorIntegrationTest
- extends DDLGeneratorIntegrationTest {
-
- static {
- TestConfig.init();
- }
-
- public H2DDLGeneratorIntegrationTest(String name) {
- super(name, H2DDLGenerator.class.getName());
- }
-
- public static void main(String[] args) {
- TestRunner.run(H2DDLGeneratorIntegrationTest.class);
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/h2/H2DDLGeneratorUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,29 +1,11 @@
package org.nsdl.mptstore.impl.h2;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
import org.nsdl.mptstore.core.DDLGeneratorUnitTest;
public class H2DDLGeneratorUnitTest extends DDLGeneratorUnitTest {
- static {
- TestConfig.init();
+ public H2DDLGeneratorUnitTest() {
+ super(H2DDLGenerator.class.getName());
}
- public H2DDLGeneratorUnitTest(String name) {
- super(name, H2DDLGenerator.class.getName());
- }
-
- public void setUp() {
- }
-
- public void tearDown() {
- }
-
- public static void main(String[] args) {
- TestRunner.run(H2DDLGeneratorUnitTest.class);
- }
-
}
Deleted: trunk/src/test/org/nsdl/mptstore/impl/postgres/AllIntegrationTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/postgres/AllIntegrationTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/postgres/AllIntegrationTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +0,0 @@
-package org.nsdl.mptstore.impl.postgres;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-public class AllIntegrationTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllIntegrationTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(PostgresDDLGeneratorIntegrationTest.class);
-
- return suite;
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/postgres/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/postgres/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/postgres/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,21 +1,10 @@
package org.nsdl.mptstore.impl.postgres;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(PostgresDDLGeneratorUnitTest.class);
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ PostgresDDLGeneratorUnitTest.class
+})
+public class AllUnitTests { }
Deleted: trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorIntegrationTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorIntegrationTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorIntegrationTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,24 +0,0 @@
-package org.nsdl.mptstore.impl.postgres;
-
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
-import org.nsdl.mptstore.core.DDLGeneratorIntegrationTest;
-
-public class PostgresDDLGeneratorIntegrationTest
- extends DDLGeneratorIntegrationTest {
-
- static {
- TestConfig.init();
- }
-
- public PostgresDDLGeneratorIntegrationTest(String name) {
- super(name, PostgresDDLGenerator.class.getName());
- }
-
- public static void main(String[] args) {
- TestRunner.run(PostgresDDLGeneratorIntegrationTest.class);
- }
-
-}
Modified: trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/impl/postgres/PostgresDDLGeneratorUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,29 +1,11 @@
package org.nsdl.mptstore.impl.postgres;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
-
-import org.nsdl.mptstore.TestConfig;
import org.nsdl.mptstore.core.DDLGeneratorUnitTest;
public class PostgresDDLGeneratorUnitTest extends DDLGeneratorUnitTest {
- static {
- TestConfig.init();
+ public PostgresDDLGeneratorUnitTest() {
+ super(PostgresDDLGenerator.class.getName());
}
- public PostgresDDLGeneratorUnitTest(String name) {
- super(name, PostgresDDLGenerator.class.getName());
- }
-
- public void setUp() {
- }
-
- public void tearDown() {
- }
-
- public static void main(String[] args) {
- TestRunner.run(PostgresDDLGeneratorUnitTest.class);
- }
-
}
Modified: trunk/src/test/org/nsdl/mptstore/query/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/query/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/query/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,24 +1,10 @@
package org.nsdl.mptstore.query;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(SomeTest.class);
-
- // sub-package suites
- suite.addTest(org.nsdl.mptstore.query.lang.AllUnitTests.suite());
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.nsdl.mptstore.query.lang.AllUnitTests.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/query/lang/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/query/lang/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/query/lang/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,23 +1,10 @@
package org.nsdl.mptstore.query.lang;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- //suite.addTestSuite(SomeTest.class);
-
- // sub-package suites
- suite.addTest(org.nsdl.mptstore.query.lang.spo.AllUnitTests.suite());
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.nsdl.mptstore.query.lang.spo.AllUnitTests.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/query/lang/spo/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/query/lang/spo/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/query/lang/spo/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,23 +1,10 @@
package org.nsdl.mptstore.query.lang.spo;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-import org.nsdl.mptstore.query.lang.spo.AllUnitTests;
-
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(SPOQueryCompilerUnitTest.class);
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ SPOQueryCompilerUnitTest.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/query/lang/spo/SPOQueryCompilerUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/query/lang/spo/SPOQueryCompilerUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/query/lang/spo/SPOQueryCompilerUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,43 +1,31 @@
package org.nsdl.mptstore.query.lang.spo;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.nsdl.mptstore.TestConfig;
import org.nsdl.mptstore.core.TableManager;
import org.nsdl.mptstore.query.QueryException;
import org.nsdl.mptstore.rdf.PredicateNode;
-public class SPOQueryCompilerUnitTest extends TestCase {
+public class SPOQueryCompilerUnitTest {
private SPOQueryCompiler _compiler;
- static {
+ @BeforeClass
+ public static void setUpClass() {
TestConfig.init();
}
- public SPOQueryCompilerUnitTest(String name) { super (name); }
-
+ @Before
public void setUp() {
_compiler = new SPOQueryCompiler(new FakeTableManager(), true);
}
- public void tearDown() {
- }
-
- //
- // Parse Tests
- //
-
- private boolean isValidQuery(String query) {
- try {
- _compiler.compile(query);
- return true;
- } catch (QueryException e) {
- return false;
- }
- }
-
+ @Test
public void testParseValidSPOQueries() {
assertTrue(isValidQuery("* * *"));
assertTrue(isValidQuery("* * \"test\""));
@@ -48,6 +36,7 @@
assertTrue(isValidQuery("<urn:a> <urn:b> \"1\"^^<urn:someDatatype>"));
}
+ @Test
public void testParseInvalidSPOQueries() {
assertFalse(isValidQuery(""));
assertFalse(isValidQuery("* *"));
@@ -61,8 +50,13 @@
assertFalse(isValidQuery("<urn:a> <urn:b> \"1\"^^<urn:some badDatatype>"));
}
- public static void main(String[] args) {
- TestRunner.run(SPOQueryCompilerUnitTest.class);
+ private boolean isValidQuery(String query) {
+ try {
+ _compiler.compile(query);
+ return true;
+ } catch (QueryException e) {
+ return false;
+ }
}
private class FakeTableManager implements TableManager {
Modified: trunk/src/test/org/nsdl/mptstore/rdf/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/rdf/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/rdf/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,20 +1,10 @@
package org.nsdl.mptstore.rdf;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(LiteralUnitTest.class);
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ LiteralUnitTest.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/rdf/LiteralUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/rdf/LiteralUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/rdf/LiteralUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -2,25 +2,22 @@
import java.text.ParseException;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import org.nsdl.mptstore.TestConfig;
-public class LiteralUnitTest extends TestCase {
+public class LiteralUnitTest {
- static {
+ @BeforeClass
+ public static void setUpClass() {
TestConfig.init();
}
- public LiteralUnitTest(String name) { super (name); }
-
- public void setUp() {
- }
-
- public void tearDown() {
- }
-
+ @Test
public void testPlainLiteralNoLanguage() throws Exception {
Literal l = new Literal("1");
@@ -55,6 +52,7 @@
}
+ @Test
public void testPlainLiteralWithLanguage() throws Exception {
Literal l = new Literal("1", "EN");
@@ -91,6 +89,7 @@
}
+ @Test
public void testTypedLiteral() throws Exception {
URIReference type = new URIReference("urn:someDatatype");
@@ -126,8 +125,4 @@
}
- public static void main(String[] args) {
- TestRunner.run(LiteralUnitTest.class);
- }
-
}
Modified: trunk/src/test/org/nsdl/mptstore/util/AllUnitTests.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/util/AllUnitTests.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/util/AllUnitTests.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -1,22 +1,10 @@
package org.nsdl.mptstore.util;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class AllUnitTests extends TestCase {
-
- public static Test suite() throws Exception {
-
- TestSuite suite = new TestSuite(AllUnitTests.class.getName());
-
- // classes in this package
- suite.addTestSuite(NTriplesUtilUnitTest.class);
-
- // sub-package suites
-
- return suite;
-
- }
-
-}
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ NTriplesUtilUnitTest.class
+})
+public class AllUnitTests { }
Modified: trunk/src/test/org/nsdl/mptstore/util/NTriplesUtilUnitTest.java
===================================================================
--- trunk/src/test/org/nsdl/mptstore/util/NTriplesUtilUnitTest.java 2006-12-10 07:16:14 UTC (rev 102)
+++ trunk/src/test/org/nsdl/mptstore/util/NTriplesUtilUnitTest.java 2006-12-10 15:20:42 UTC (rev 103)
@@ -2,34 +2,24 @@
import java.text.ParseException;
-import junit.framework.TestCase;
-import junit.swingui.TestRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.nsdl.mptstore.TestConfig;
-public class NTriplesUtilUnitTest extends TestCase {
+public class NTriplesUtilUnitTest {
- static {
+ @BeforeClass
+ public static void setUpClass() {
TestConfig.init();
}
- public NTriplesUtilUnitTest(String name) { super (name); }
-
- public void setUp() {
- }
-
- public void tearDown() {
- }
-
- private boolean isValidLanguage(String lang) {
- try {
- NTriplesUtil.validateLanguage(lang);
- return true;
- } catch (ParseException e) {
- return false;
- }
- }
-
+ @Test
public void testParseGoodLanguages() {
assertTrue(isValidLanguage("en"));
assertTrue(isValidLanguage("en-US"));
@@ -38,6 +28,7 @@
assertTrue(isValidLanguage("a-2-c-4-e-f-g-h-i-jklmnopq"));
}
+ @Test
public void testParseBadLanguages() {
assertFalse(isValidLanguage(""));
assertFalse(isValidLanguage("-"));
@@ -48,16 +39,7 @@
assertFalse(isValidLanguage("en-abcdefghi"));
}
- private String checkTriple(String ntTriple) {
- try {
- NTriplesUtil.parseTriple(ntTriple);
- return null;
- } catch (ParseException e) {
- return e.getMessage() + " at character " + e.getErrorOffset()
- + " of input: " + ntTriple;
- }
- }
-
+ @Test
public void testParseGoodTriples() {
String msg;
@@ -118,6 +100,7 @@
}
+ @Test
public void testUnicodeUnescaping() throws Exception {
String notEscaped = "\u00BFHabla espa\u00F1ol?";
@@ -126,6 +109,7 @@
assertEquals(notEscaped, NTriplesUtil.unescapeLiteralValue(escaped));
}
+ @Test
public void testAsciiUnescaping() throws Exception {
checkUnescapingCombos("\t", "\\t");
checkUnescapingCombos("\r", "\\r");
@@ -134,18 +118,7 @@
checkUnescapingCombos("\\", "\\\\");
}
- private void checkUnescapingCombos(String unescaped, String escaped) throws Exception {
- checkUnescaping(unescaped, escaped);
- checkUnescaping(" " + unescaped, " " + escaped);
- checkUnescaping("a" + unescaped, "a" + escaped);
- checkUnescaping(unescaped + " ", escaped + " ");
- checkUnescaping(unescaped + "a", escaped + "a");
- }
-
- private void checkUnescaping(String unescaped, String escaped) throws Exception {
- assertEquals(unescaped, NTriplesUtil.unescapeLiteralValue(escaped));
- }
-
+ @Test
public void testUnicodeEscaping() throws Exception {
String notEscaped = "\u00BFHabla espa\u00F1ol?";
@@ -154,8 +127,8 @@
assertEquals(escaped, NTriplesUtil.escapeLiteralValue(notEscaped));
}
+ @Test
public void testParseBadTriples() {
-
assertNotNull(checkTriple(""));
assertNotNull(checkTriple("."));
assertNotNull(checkTriple("<urn:a> ."));
@@ -182,8 +155,35 @@
assertNotNull(checkTriple("\"bad literal position\" <urn:b> <urn:c> ."));
}
- public static void main(String[] args) {
- TestRunner.run(NTriplesUtilUnitTest.class);
- }
+ private boolean isValidLanguage(String lang) {
+ try {
+ NTriplesUtil.validateLanguage(lang);
+ return true;
+ } catch (ParseException e) {
+ return false;
+ }
+ }
+ private String checkTriple(String ntTriple) {
+ try {
+ NTriplesUtil.parseTriple(ntTriple);
+ return null;
+ } catch (ParseException e) {
+ return e.getMessage() + " at character " + e.getErrorOffset()
+ + " of input: " + ntTriple;
+ }
+ }
+
+ private void checkUnescapingCombos(String unescaped, String escaped) throws Exception {
+ checkUnescaping(unescaped, escaped);
+ checkUnescaping(" " + unescaped, " " + escaped);
+ checkUnescaping("a" + unescaped, "a" + escaped);
+ checkUnescaping(unescaped + " ", escaped + " ");
+ checkUnescaping(unescaped + "a", escaped + "a");
+ }
+
+ private void checkUnescaping(String unescaped, String escaped) throws Exception {
+ assertEquals(unescaped, NTriplesUtil.unescapeLiteralValue(escaped));
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|