Package org.dbxml.core.corba.db

Examples of org.dbxml.core.corba.db.Collection


      }
   }

   public void testGetCollection() {
  
      Collection gottencol = null;
     
      try {
     
         // Retrieve an instance of our test collection
         gottencol = db.getCollection(TEST_COLLECTION_NAME);
        
         // Verify that the correct col was returned
         assertTrue( gottencol.getName().equals(TEST_COLLECTION_NAME) );
        
         // Try getting a collection with the empty string as the name
         try {
            exceptioncaught = false;
            gottencol = db.getCollection("");
         } catch(APIException e) {
            exceptioncaught=true;
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         } finally {
            assertTrue( exceptioncaught );
         }
        
         // Try getting a collection with a bogus name
         try {
            exceptioncaught = false;
            gottencol = db.getCollection("totallybogusname");
         } catch(APIException e) {
            exceptioncaught=true;
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         } finally {
            assertTrue( exceptioncaught );
         }

      } catch (Exception e) {
         fail( e.getMessage() );
      } finally {
         gottencol.remove();
      }
   }
View Full Code Here


  
   }
  
   public void testCreateCollection() {
  
      Collection tempcol = null;
  
      try {
     
         // Name of the valid collection to create
         String newcolname = "testchild";
         // Config XML for valid collection created
         String colconf = "<collection compressed=\"true\" name=\"" + newcolname + "\" >" ;
            colconf = colconf + "<filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\"/>" ;
            colconf = colconf + "</collection>" ;
         EncodedBuffer colconfbuf = new EncodedBuffer(-1, EmptyBytes, colconf.getBytes() );
        
         // Create the collection
         tempcol = colman.createCollection(newcolname, colconfbuf);
        
         // Verify that collection created, and that name was set correctly
         assertTrue( tempcol.getName().equals( newcolname ) );

         // Now drop the collection
         colman.dropCollection( newcolname );
                
         // Attempt to create a collection with an empty configuration
         try {
            exceptioncaught = false;
            String empty = "";
            EncodedBuffer emptybuf = new EncodedBuffer(-1, EmptyBytes, empty.getBytes() );
            tempcol = colman.createCollection("NullConfig", emptybuf );
           
         } catch( APIException e ) {
            exceptioncaught = true;
            assertTrue( e.faultCode == FaultCodes.JAVA_RUNTIME_ERROR );
         } finally {
            assertTrue( exceptioncaught );
         }
        
         // Attempt to create a collection with a malformed configuration
         try {
            exceptioncaught = false;
           
            // Bad configuration file
            String malconf = "<bad config>lkjasf";
            EncodedBuffer malconfbuf = new EncodedBuffer(-1, EmptyBytes, malconf.getBytes() );
           
            // Attempt to create the collection
            tempcol = colman.createCollection("malconf", malconfbuf );
           
         } catch( APIException e ) {
            exceptioncaught = true;
            assertTrue( e.faultCode == FaultCodes.JAVA_RUNTIME_ERROR );
         } finally {
            assertTrue( exceptioncaught );
         }

         // Attempt to create a collection with an invalid configuration, missing name attribute
         try {
            exceptioncaught = false;
           
            // Bad configuration file
            String invalidconf = "<collection>" ;
            invalidconf = invalidconf + "<filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\"/>" ;
            invalidconf = invalidconf + "</collection>" ;
           
            EncodedBuffer invalidconfbuf = new EncodedBuffer(-1, EmptyBytes, invalidconf.getBytes() );
           
            // Attempt to create the collection
            tempcol = colman.createCollection("invalid", invalidconfbuf );
           
            // Test that the collection was created by calling getName() on it
            assertTrue( tempcol.getName().equals("invalid") );
           
            colman.dropCollection("invalid");
           
         } catch( APIException e ) {
            exceptioncaught = true;
            assertTrue( e.faultCode == FaultCodes.COL_CANNOT_CREATE );
         } finally {
            assertTrue( exceptioncaught );
         }

         // Attempt to create a collection without a filer attribute, this should be allowed

         exceptioncaught = false;
        
         String nofilerconf = "<collection name=\"nofiler\">" ;
         nofilerconf = nofilerconf + "</collection>" ;
        
         EncodedBuffer nofilerconfbuf = new EncodedBuffer(-1, EmptyBytes, nofilerconf.getBytes() );
        
         // Attempt to create the collection
         tempcol = colman.createCollection("nofiler", nofilerconfbuf );
        
         colman.dropCollection("nofiler");
        
      } catch( Exception e ) {
         e.printStackTrace();
         fail(e.getMessage() );
      } finally {
         // Remove collection added so that we don't break other tests, release recources for tempcol
         tempcol.remove();
      }
  
   }
View Full Code Here

      }
  
   }

   public void testDropCollection() {
      Collection tempcol = null;
  
      try {

         // Name of the valid collection to create
         String newcolname = "coltodrop";
         // Config XML for valid collection created
         String colconf = "<collection compressed=\"true\" name=\"" + newcolname + "\">" ;
            colconf = colconf + "<filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\"/>" ;
            colconf = colconf + "</collection>" ;
         EncodedBuffer colconfbuf = new EncodedBuffer(-1, EmptyBytes, colconf.getBytes() );
        
         // Create a collection
         tempcol = colman.createCollection(newcolname, colconfbuf);
         // Verify that collection created, and that name was set correctly
         assertTrue( tempcol.getName().equals( newcolname ) );
        
         // Drop the collection
         colman.dropCollection(newcolname);

         // Try dropping the collection we just dropped
         try {
            exceptioncaught = false;
            colman.dropCollection(newcolname);
         } catch( APIException e ) {
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         }
        
         // Try dropping a collection that doesn't exist
         try {
            exceptioncaught = false;
            colman.dropCollection("boguscollectionname");
         } catch( APIException e ) {
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         }
        
         // Try dropping a collection with the empty string for a name
         try {
            exceptioncaught = false;
            colman.dropCollection("");
         } catch( APIException e ) {
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         }
              
      } catch( Exception e ) {
         e.printStackTrace();
         fail(e.getMessage() );
      } finally {
         tempcol.remove();
      }
  
   }
View Full Code Here

TOP

Related Classes of org.dbxml.core.corba.db.Collection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.