Permalink
Browse files

Fixes to tests so that they use the new JUnit annotations. The biggest

problem was in isolating dependencies through tests in the same class.
Tests SHOULD NOT assume an order of execution!
  • Loading branch information...
1 parent 820a47e commit 7eb5e3fb4e47ba65f908b02af05534ac0537dfa4 @adamretter adamretter committed Jan 23, 2014
Showing with 355 additions and 286 deletions.
  1. +1 −1 test/src/org/exist/http/RESTServiceTest.java
  2. +1 −1 test/src/org/exist/security/RestApiSecurityTest.java
  3. +1 −1 test/src/org/exist/security/XMLDBSecurityTest.java
  4. +1 −1 test/src/org/exist/security/XmldbApiSecurityTest.java
  5. +1 −1 test/src/org/exist/soap/CopyMoveTest.java
  6. +1 −1 test/src/org/exist/soap/XQueryTest.java
  7. +10 −10 test/src/org/exist/storage/AbstractUpdateTest.java
  8. +4 −6 test/src/org/exist/storage/AppendTest.java
  9. +10 −15 test/src/org/exist/storage/CollectionTest.java
  10. +38 −20 test/src/org/exist/storage/CopyCollectionTest.java
  11. +62 −35 test/src/org/exist/storage/CopyResourceTest.java
  12. +24 −26 test/src/org/exist/storage/MoveResourceTest.java
  13. +1 −1 test/src/org/exist/storage/NodePathTest.java
  14. +25 −16 test/src/org/exist/storage/RecoverBinaryTest.java
  15. +25 −15 test/src/org/exist/storage/RecoverBinaryTest2.java
  16. +29 −23 test/src/org/exist/storage/RecoveryTest.java
  17. +5 −6 test/src/org/exist/storage/RemoveTest.java
  18. +5 −6 test/src/org/exist/storage/RenameTest.java
  19. +5 −6 test/src/org/exist/storage/ReplaceTest.java
  20. +29 −25 test/src/org/exist/storage/ResourceTest.java
  21. +10 −16 test/src/org/exist/storage/ShutdownTest.java
  22. +5 −5 test/src/org/exist/storage/UpdateAttributeTest.java
  23. +29 −16 test/src/org/exist/storage/UpdateRecoverTest.java
  24. +5 −5 test/src/org/exist/storage/UpdateTest.java
  25. +1 −1 test/src/org/exist/storage/XIncludeSerializerTest.java
  26. +3 −3 test/src/org/exist/validation/ValidationFunctions_DTD_Test.java
  27. +3 −3 test/src/org/exist/validation/ValidationFunctions_Node_Test.java
  28. +1 −1 test/src/org/exist/validation/ValidationFunctions_XSD_Test.java
  29. +1 −1 test/src/org/exist/xmldb/BinaryResourceUpdateTest.java
  30. +1 −1 test/src/org/exist/xmldb/ContentAsDOMTest.java
  31. +1 −1 test/src/org/exist/xmldb/CopyMoveTest.java
  32. +1 −1 test/src/org/exist/xmldb/DOMTest.java
  33. +2 −2 test/src/org/exist/xmldb/DOMTestJUnit.java
  34. +2 −2 test/src/org/exist/xmldb/RemoteCollectionTest.java
  35. +2 −2 test/src/org/exist/xmldb/RemoteDatabaseImplTest.java
  36. +1 −1 test/src/org/exist/xmldb/ShutdownTest.java
  37. +2 −2 test/src/org/exist/xmldb/StorageStressTest.java
  38. +1 −1 test/src/org/exist/xmldb/TestEXistXMLSerialize.java
  39. +1 −1 test/src/org/exist/xmlrpc/MoveResourceTest.java
  40. +2 −2 test/src/org/exist/xmlrpc/XmlRpcTest.java
  41. +1 −1 test/src/org/exist/xquery/SAXStorageTest.java
  42. +1 −1 test/src/org/exist/xquery/xqts/QT3TS_To_junit.java
  43. +1 −1 test/src/org/exist/xquery/xqts/XQTS_To_junit.java
@@ -161,7 +161,7 @@ public final static void createCredentials() {
@Before
public void setUp() throws Exception {
- //Don't worry about closing the server : the shutdown hook will do the job
+ //Don't worry about closing the server : the shutdownDB hook will do the job
if (server == null) {
server = new JettyStart();
System.out.println("Starting standalone server...");
@@ -164,7 +164,7 @@ protected void createBinResource(final String resourceUri, final byte[] content,
@BeforeClass
public static void startServer() throws InterruptedException {
- //Don't worry about closing the server : the shutdown hook will do the job
+ //Don't worry about closing the server : the shutdownDB hook will do the job
if (server == null) {
server = new JettyStart();
System.out.println("Starting standalone server...");
@@ -685,7 +685,7 @@ public static void stopServer() {
// Collection root = DatabaseManager.getCollection("xmldb:exist:///db", "admin", "");
// DatabaseInstanceManager mgr =
// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0");
-// mgr.shutdown();
+// mgr.shutdownDB();
// } catch (XMLDBException e) {
// e.printStackTrace();
// }
@@ -380,7 +380,7 @@ public static void stopServer() {
// Collection root = DatabaseManager.getCollection("xmldb:exist:///db", "admin", "");
// DatabaseInstanceManager mgr =
// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0");
-// mgr.shutdown();
+// mgr.shutdownDB();
// } catch (XMLDBException e) {
// e.printStackTrace();
// }
@@ -46,7 +46,7 @@ protected void tearDown() throws Exception {
rex.printStackTrace();
}
- //mn.shutdown();
+ //mn.shutdownDB();
}
private void setupTestCollection() throws RemoteException {
@@ -147,7 +147,7 @@ protected void tearDown() throws Exception {
} catch (RemoteException rex) {
rex.printStackTrace();
}
- //mn.shutdown();
+ //mn.shutdownDB();
}
public void testRemoveThisEmptyTest() throws Exception {
@@ -21,8 +21,6 @@
*/
package org.exist.storage;
-import junit.framework.TestCase;
-
import org.exist.collections.Collection;
import org.exist.collections.IndexInfo;
import org.exist.dom.DocumentImpl;
@@ -38,15 +36,20 @@
import org.exist.xquery.value.NodeValue;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.SequenceIterator;
+import org.junit.After;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
-public abstract class AbstractUpdateTest extends TestCase {
+public abstract class AbstractUpdateTest {
protected static XmldbURI TEST_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append("test");
protected static String TEST_XML =
"<?xml version=\"1.0\"?>" +
"<products/>";
- public void testRead() {
+ @Test
+ public void read() {
BrokerPool.FORCE_CORRUPTION = false;
BrokerPool pool = null;
@@ -121,11 +124,8 @@ protected BrokerPool startDB() {
return null;
}
- protected void tearDown() {
- try {
- BrokerPool.stopAll(false);
- } catch (Exception e) {
- fail(e.getMessage());
- }
+ @After
+ public void tearDown() {
+ BrokerPool.stopAll(false);
}
}
@@ -21,7 +21,6 @@
*/
package org.exist.storage;
-import junit.textui.TestRunner;
import org.exist.collections.IndexInfo;
import org.exist.dom.DefaultDocumentSet;
import org.exist.dom.MutableDocumentSet;
@@ -31,16 +30,15 @@
import org.exist.xupdate.Modification;
import org.exist.xupdate.XUpdateProcessor;
import org.xml.sax.InputSource;
+import org.junit.Test;
+import static org.junit.Assert.fail;
import java.io.StringReader;
public class AppendTest extends AbstractUpdateTest {
- public static void main(String[] args) {
- TestRunner.run(AppendTest.class);
- }
-
- public void testUpdate() {
+ @Test
+ public void update() {
BrokerPool.FORCE_CORRUPTION = true;
BrokerPool pool = null;
DBBroker broker = null;
@@ -25,22 +25,23 @@
import java.io.Writer;
import java.util.Iterator;
-import junit.framework.TestCase;
-import junit.textui.TestRunner;
-
import org.exist.collections.Collection;
import org.exist.dom.DocumentImpl;
import org.exist.storage.btree.BTree;
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.util.Configuration;
import org.exist.xmldb.XmldbURI;
+import org.junit.After;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
/**
* @author wolf
*
*/
-public class CollectionTest extends TestCase {
+public class CollectionTest {
@SuppressWarnings("unused")
private static String docs[] = { "hamlet.xml", "r_and_j.xml", "macbeth.xml" };
@@ -54,12 +55,9 @@
" <title>Hello</title>" +
" <para>Hello World!</para>" +
"</test>";
-
- public static void main(String[] args) {
- TestRunner.run(CollectionTest.class);
- }
- public void testStoreRead() {
+ @Test
+ public void storeRead() {
store();
BrokerPool.stopAll(false);
read();
@@ -134,11 +132,8 @@ protected BrokerPool startDB() {
return null;
}
- protected void tearDown() {
- try {
- BrokerPool.stopAll(false);
- } catch (Exception e) {
- fail(e.getMessage());
- }
+ @After
+ public void tearDown() {
+ BrokerPool.stopAll(false);
}
}
@@ -22,10 +22,6 @@
package org.exist.storage;
import java.io.File;
-
-import junit.framework.TestCase;
-import junit.textui.TestRunner;
-
import org.exist.collections.Collection;
import org.exist.collections.IndexInfo;
import org.exist.dom.DocumentImpl;
@@ -37,18 +33,39 @@
import org.exist.util.Configuration;
import org.exist.xmldb.CollectionManagementServiceImpl;
import org.exist.xmldb.XmldbURI;
+import org.junit.After;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import org.xml.sax.InputSource;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.Resource;
-public class CopyCollectionTest extends TestCase {
+public class CopyCollectionTest {
- public static void main(String[] args) {
- TestRunner.run(CopyCollectionTest.class);
+ @Test
+ public void storeAndRead() {
+ store();
+ tearDown();
+ read();
}
-
- public void testStore() {
+
+ @Test
+ public void storeAndReadAborted() {
+ storeAborted();
+ tearDown();
+ readAborted();
+ }
+
+ @Test
+ public void storeAndReadXmldb() {
+ xmldbStore();
+ tearDown();
+ xmldbRead();
+ }
+
+ private void store() {
BrokerPool.FORCE_CORRUPTION = true;
BrokerPool pool = startDB();
DBBroker broker = null;
@@ -87,8 +104,8 @@ public void testStore() {
pool.release(broker);
}
}
-
- public void testRead() {
+
+ private void read() {
BrokerPool.FORCE_CORRUPTION = false;
BrokerPool pool = null;
DBBroker broker = null;
@@ -115,8 +132,8 @@ public void testRead() {
if (pool != null) pool.release(broker);
}
}
-
- public void testStoreAborted() {
+
+ private void storeAborted() {
BrokerPool.FORCE_CORRUPTION = true;
BrokerPool pool = null;
@@ -168,8 +185,8 @@ public void testStoreAborted() {
if (pool != null) pool.release(broker);
}
}
-
- public void testReadAborted() {
+
+ private void readAborted() {
BrokerPool.FORCE_CORRUPTION = false;
BrokerPool pool = null;
DBBroker broker = null;
@@ -192,8 +209,8 @@ public void testReadAborted() {
pool.release(broker);
}
}
-
- public void testXMLDBStore() {
+
+ private void xmldbStore() {
BrokerPool.FORCE_CORRUPTION = false;
BrokerPool pool = null;
try {
@@ -232,8 +249,8 @@ public void testXMLDBStore() {
fail(e.getMessage());
}
}
-
- public void testXMLDBRead() {
+
+ private void xmldbRead() {
BrokerPool.FORCE_CORRUPTION = false;
BrokerPool pool = null;
@@ -274,7 +291,8 @@ protected BrokerPool startDB() {
return null;
}
- protected void tearDown() {
+ @After
+ public void tearDown() {
BrokerPool.stopAll(false);
}
}
Oops, something went wrong.

0 comments on commit 7eb5e3f

Please sign in to comment.