vgritsenko    2004/02/18 19:29:01

  Modified:    java/tests/src/org/apache/xindice/integration/client/basic
                        CollectionTest.java
               java/tests/src/org/apache/xindice/integration/client/services
                        IndexedSearchTest.java
  Log:
  tests improvements
  
  Revision  Changes    Path
  1.17      +24 -28    
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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CollectionTest.java       8 Feb 2004 03:57:02 -0000       1.16
  +++ CollectionTest.java       19 Feb 2004 03:29:01 -0000      1.17
  @@ -41,9 +41,8 @@
               Collection col = this.client.getCollection("doesnotexist");
               fail("Expected ErrorCodes.NO_SUCH_DATABASE (" + 
ErrorCodes.NO_SUCH_DATABASE + "), got collection: " + col);
           } catch (XMLDBException e) {
  -            if (e.errorCode != ErrorCodes.NO_SUCH_DATABASE) {
  -                fail("Expected ErrorCodes.NO_SUCH_DATABASE (" + 
ErrorCodes.NO_SUCH_DATABASE + "), got: " + e);
  -            }
  +            assertEquals("ErrorCodes.NO_SUCH_DATABASE",
  +                         ErrorCodes.NO_SUCH_DATABASE, e.errorCode);
           }
       }
   
  @@ -87,7 +86,8 @@
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, "duplicate");
           } catch (XMLDBException e) {
  -            assertTrue(e.vendorErrorCode == 
FaultCodes.COL_DUPLICATE_COLLECTION);
  +            assertEquals("FaultCodes.COL_DUPLICATE_COLLECTION",
  +                         FaultCodes.COL_DUPLICATE_COLLECTION, 
e.vendorErrorCode);
           }
   
           this.client.dropCollection(TEST_COLLECTION_PATH, "duplicate");
  @@ -96,34 +96,31 @@
       public void testCreateCollectionEmptyName() throws Exception {
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, "emptyname", 
"");
  +            fail();
           } catch (XMLDBException e) {
  -            assertTrue("Error Code (Expected " + 
FaultCodes.COL_CANNOT_CREATE + ", got " + e.vendorErrorCode,
  -                       e.vendorErrorCode == FaultCodes.COL_CANNOT_CREATE);
  -            return;
  +            assertEquals("FaultCodes.COL_CANNOT_CREATE",
  +                         FaultCodes.COL_CANNOT_CREATE, e.vendorErrorCode);
           }
  -        fail();
       }
   
       public void testCreateCollectionNullName() throws Exception {
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, "nullname", 
(String) null);
  +            fail();
           } catch (XMLDBException e) {
  -            assertTrue("Error Code (Expected " + 
FaultCodes.COL_CANNOT_CREATE + ", got " + e.vendorErrorCode,
  -                       e.vendorErrorCode == FaultCodes.COL_CANNOT_CREATE);
  -            return;
  +            assertEquals("FaultCodes.COL_CANNOT_CREATE",
  +                         FaultCodes.COL_CANNOT_CREATE, e.vendorErrorCode);
           }
  -        fail();
       }
   
       public void testCreateCollectionInvalidName() throws Exception {
           try {
               this.client.createCollection(TEST_COLLECTION_PATH, 
"invalidname", "my/collection");
  +            fail();
           } catch (XMLDBException e) {
  -            assertTrue("Error Code (Expected " + 
FaultCodes.COL_CANNOT_CREATE + ", got " + e.vendorErrorCode,
  -                       e.vendorErrorCode == FaultCodes.COL_CANNOT_CREATE);
  -            return;
  +            assertEquals("FaultCodes.COL_CANNOT_CREATE",
  +                         FaultCodes.COL_CANNOT_CREATE, e.vendorErrorCode);
           }
  -        fail();
       }
   
       public void testDropCollectionTwice() throws Exception {
  @@ -132,33 +129,32 @@
           this.client.dropCollection(TEST_COLLECTION_PATH, "droptwice");
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, "droptwice");
  +            fail();
           } catch (XMLDBException e) {
  -            assertTrue("Error Code (Expected " + 
FaultCodes.COL_COLLECTION_NOT_FOUND + ", got " + e.vendorErrorCode,
  -                       e.vendorErrorCode == 
FaultCodes.COL_COLLECTION_NOT_FOUND);
  -            return;
  +            assertEquals("FaultCodes.COL_COLLECTION_NOT_FOUND",
  +                         FaultCodes.COL_COLLECTION_NOT_FOUND, 
e.vendorErrorCode);
           }
  -        fail();
       }
   
       public void testDropCollectionNullName() throws Exception {
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, null);
  +            fail();
           } catch (XMLDBException e) {
  -            assertTrue("Error Code (Expected " + 
FaultCodes.COL_COLLECTION_NOT_FOUND + ", got " + e.vendorErrorCode,
  -                       e.vendorErrorCode == 
FaultCodes.COL_COLLECTION_NOT_FOUND);
  +            assertEquals("FaultCodes.COL_COLLECTION_NOT_FOUND",
  +                         FaultCodes.COL_COLLECTION_NOT_FOUND, 
e.vendorErrorCode);
               return;
           }
  -        fail();
       }
   
       public void testDropCollectionEmptyName() throws Exception {
           try {
               this.client.dropCollection(TEST_COLLECTION_PATH, "");
  +            fail("Dropping a collection with empty name should throw an 
exception.");
           } catch (XMLDBException e) {
  -            assertTrue(e.vendorErrorCode == 
FaultCodes.COL_COLLECTION_NOT_FOUND);
  -            return;
  +            assertEquals("FaultCodes.COL_COLLECTION_NOT_FOUND",
  +                         FaultCodes.COL_COLLECTION_NOT_FOUND, 
e.vendorErrorCode);
           }
  -        fail("Dropping a collection with empty name should throw an 
exception.");
       }
   
       public void testGetCollectionCount() throws Exception {
  
  
  
  1.8       +3 -5      
xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
  
  Index: IndexedSearchTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- IndexedSearchTest.java    8 Feb 2004 03:57:02 -0000       1.7
  +++ IndexedSearchTest.java    19 Feb 2004 03:29:01 -0000      1.8
  @@ -89,7 +89,7 @@
        * Creates 104 test documents and inserts them into the test Collection.
        */
       private void createTestDocs() throws Exception {
  -        for (int anIndex = 0; anIndex < 200; ++anIndex) {
  +        for (int anIndex = 0; anIndex < 250; ++anIndex) {
               String aNumber = String.valueOf(anIndex);
               String aDocument =
                       "<?xml version='1.0'?>" +
  @@ -297,8 +297,6 @@
               Document aDocument = aBuilder.parse(
                       new InputSource(new StringReader(theXML)));
               Element aRootElement = aDocument.getDocumentElement();
  -            org.xmldb.api.base.Collection aCollection = 
IndexedSearchTest.this.client.getCollection(
  -                    theCollectionName);
   
               final String aPrefix = "src";
               
aRootElement.setAttribute(org.apache.xindice.xml.dom.NodeImpl.XMLNS_PREFIX + 
":" + aPrefix,
  
  
  

Reply via email to