kward 2002/06/11 19:11:40
Modified: java/scratchpad/tests/src CollectionManagerTest.java
Log:
cleaned up tests
Revision Changes Path
1.4 +12 -53
xml-xindice/java/scratchpad/tests/src/CollectionManagerTest.java
Index: CollectionManagerTest.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/tests/src/CollectionManagerTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CollectionManagerTest.java 11 Jun 2002 04:28:58 -0000 1.3
+++ CollectionManagerTest.java 12 Jun 2002 02:11:40 -0000 1.4
@@ -77,34 +77,22 @@
public void testCreateCollection() throws Exception {
+ String result = null;
+
try {
- createCollection("child1");
+ result = createCollection("child1");
} catch(Exception e) {
fail( e.getMessage() );
}
- // see if the collection was created
- Hashtable message = new Hashtable();
- message.put("message", "ListCollections");
- message.put("collection", "/" + INSTANCE_NAME + "/" +
TEST_COLLECTION_NAME);
-
- Vector params = new Vector();
- params.addElement(message);
-
- Hashtable result = (Hashtable) client.execute("run", params);
-
- Vector list = (Vector) result.get("result");
- Enumeration enum = list.elements();
- while ( enum.hasMoreElements() ) {
- assert(((String) enum.nextElement()).equals("child1"));
- }
+ assertTrue(result.equals("child1"));
// try creating the same collection, should generate a duplicate error
try {
createCollection("child1");
} catch(Exception e) {
- assert(e.getMessage().lastIndexOf("Duplicate Collection") > 0);
+ assertTrue(e.getMessage().lastIndexOf("Duplicate Collection") > 0);
}
// try creating a nameless collection, should generate a no name error
@@ -122,7 +110,7 @@
try {
client.execute("run", badparams);
} catch(Exception e) {
- assert(e.getMessage().lastIndexOf("No name specified") > 0);
+ assertTrue(e.getMessage().lastIndexOf("No name specified") > 0);
}
dropCollection("child1");
@@ -133,21 +121,6 @@
createCollection("coltodrop");
- Hashtable message = new Hashtable();
- message.put("message", "ListCollections");
- message.put("collection", "/" + INSTANCE_NAME + "/" +
TEST_COLLECTION_NAME);
-
- Vector params = new Vector();
- params.addElement(message);
-
- Hashtable result = (Hashtable) client.execute("run", params);
-
- Vector list = (Vector) result.get("result");
- Enumeration enum = list.elements();
- while ( enum.hasMoreElements() ) {
- assert(((String) enum.nextElement()).equals("coltodrop"));
- }
-
try {
dropCollection("coltodrop");
} catch( Exception e ) {
@@ -159,7 +132,7 @@
try {
dropCollection("coltodrop");
} catch(Exception e) {
- assert(e.getMessage().lastIndexOf("could not be found") > 0);
+ assertTrue(e.getMessage().lastIndexOf("could not be found") > 0);
}
// Try dropping a collection with an empty name
@@ -176,36 +149,22 @@
try {
client.execute("run", badparams);
} catch(Exception e) {
- assert(e.getMessage().lastIndexOf("Collection name must begin with
a '/'") > 0);
+ assertTrue(e.getMessage().lastIndexOf("Collection name must begin
with a '/'") > 0);
}
}
public void testCreateIndexer() throws Exception {
-
+ String result = null;
// try a normal index
try {
- createIndexer( "goodindexer", "goodindexer" );
+ result = createIndexer( "goodindexer", "goodindexer" );
} catch( Exception e ) {
fail( e.getMessage() );
}
- // now see if it's there
- Hashtable message = new Hashtable();
- message.put("message", "ListIndexers");
- message.put("collection", "/" + INSTANCE_NAME + "/" +
TEST_COLLECTION_NAME);
-
- Vector params = new Vector();
- params.addElement(message);
-
- Hashtable result = (Hashtable) client.execute("run", params);
-
- Vector list = (Vector) result.get("result");
- Enumeration enum = list.elements();
- while ( enum.hasMoreElements() ) {
- assertTrue(((String) enum.nextElement()).equals("goodindexer"));
- }
+ assertTrue(result.equals("goodindexer"));
// try adding the same index
try {