vgritsenko    2003/12/11 06:07:49

  Modified:    java/tests/src/org/apache/xindice/integration/client/basic
                        CollectionTest.java
  Log:
  harden collection test: test returned error code.
  
  Revision  Changes    Path
  1.12      +19 -22    
xml-xindice/java/tests/src/org/apache/xindice/integration/client/basic/CollectionTest.java
  
  Index: CollectionTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/basic/CollectionTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CollectionTest.java       9 Aug 2003 03:25:45 -0000       1.11
  +++ CollectionTest.java       11 Dec 2003 14:07:49 -0000      1.12
  @@ -61,6 +61,7 @@
   
   import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
   import org.apache.xindice.integration.client.XmlDbClientSetup;
  +import org.apache.xindice.core.FaultCodes;
   
   import org.xmldb.api.base.XMLDBException;
   import org.xmldb.api.base.Collection;
  @@ -99,7 +100,7 @@
               assertTrue(col.contains("system"));
               assertTrue(col.contains("meta"));
           } else {
  -            fail("Initial number of collections should be 2, or 3 with 
meta");
  +            fail("Initial number of collections should be 2, or 3 if meta 
enabled");
           }
       }
   
  @@ -124,9 +125,8 @@
           this.client.createCollection(TEST_COLLECTION_PATH, "duplicate");
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, "duplicate");
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "Duplicate Collection" 
) > 0 );
  +        } catch (XMLDBException e) {
  +            assertTrue(e.vendorErrorCode == 
FaultCodes.COL_DUPLICATE_COLLECTION);
           }
   
           this.client.dropCollection(TEST_COLLECTION_PATH, "duplicate");
  @@ -135,9 +135,9 @@
       public void testCreateCollectionEmptyName() throws Exception {
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, "");
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "Duplicate Collection" 
) > 0 );
  +        } catch (XMLDBException e) {
  +            assertTrue(e.vendorErrorCode == FaultCodes.COL_CANNOT_CREATE);
  +            assertTrue(e.getMessage().lastIndexOf("No name specified") > 0);
               return;
           }
           fail();
  @@ -146,9 +146,8 @@
       public void testCreateCollectionNullName() throws Exception {
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, null);
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "Duplicate Collection" 
) > 0 );
  +        } catch (XMLDBException e) {
  +            // TODO assertTrue(e.vendorErrorCode == 
FaultCodes.COL_CANNOT_CREATE);
               return;
           }
           fail();
  @@ -160,9 +159,8 @@
           this.client.dropCollection(TEST_COLLECTION_PATH, "droptwice");
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, "droptwice");
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "could not be found" ) 
> 0 );
  +        } catch (XMLDBException e) {
  +            assertTrue(e.vendorErrorCode == 
FaultCodes.COL_COLLECTION_NOT_FOUND);
               return;
           }
           fail();
  @@ -171,9 +169,8 @@
       public void testDropCollectionNullName() throws Exception {
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, null);
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "could not be found" ) 
> 0 );
  +        } catch (XMLDBException e) {
  +            // TODO assertTrue(e.vendorErrorCode == 
FaultCodes.COL_CANNOT_DROP);
               return;
           }
           fail();
  @@ -182,9 +179,8 @@
       public void testDropCollectionEmptyName() throws Exception {
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, "");
  -        }
  -        catch (XMLDBException e) {
  -            //assertTrue( e.getMessage().lastIndexOf( "could not be found" ) 
> 0 );
  +        } catch (XMLDBException e) {
  +            assertTrue(e.vendorErrorCode == 
FaultCodes.COL_COLLECTION_NOT_FOUND);
               return;
           }
           fail("Dropping a collection with empty name should throw an 
exception.");
  @@ -250,7 +246,8 @@
           // TODO: is this assertion correct? The xml rpc driver exposes the 
"db" collection
           // the embeded doesn't. I think the xmlrpc driver is correct, and 
the test
           // is wrong, just looking for someone to confirm this.
  -        // assertNull(parent);
  +        // http://marc.theaimsgroup.com/?l=xindice-dev&m=106040091508016&w=2
  +        assertNotNull(parent);
   
           this.client.dropCollection(TEST_COLLECTION_PATH, "childcol");
       }
  
  
  

Reply via email to