db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/test/org/apache/ojb/broker/metadata/auto AutoBuildDb.java
Date Thu, 09 Jan 2003 17:20:15 GMT
arminw      2003/01/09 09:20:15

  Modified:    src/test/org/apache/ojb/broker AllTests.java
               src/test/org/apache/ojb/broker/sequence
                        SequenceManagerTest.java
               src/test/org/apache/ojb/broker/metadata
                        RepositoryPersistorTest.java
               src/test/org/apache/ojb/broker/metadata/auto
                        AutoBuildDb.java
  Added:       src/test/org/apache/ojb/broker/metadata MetadataTest.java
  Log:
  - update tests after kernel changes
  - remove double defined test cases
  from AllTests.java
  
  Revision  Changes    Path
  1.16      +1 -1      jakarta-ojb/src/test/org/apache/ojb/broker/AllTests.java
  
  Index: AllTests.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AllTests.java	22 Nov 2002 19:52:51 -0000	1.15
  +++ AllTests.java	9 Jan 2003 17:20:14 -0000	1.16
  @@ -1,4 +1,4 @@
   package org.apache.ojb.broker;
import org.apache.ojb.broker.metadata.*;
   import org.apache.ojb.broker.sequence.SequenceManagerTest;
   
  -import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * the facade to all
TestCases in this package.
 *
 * @author: Thomas Mahler
 */
public class AllTests extends
junit.framework.TestSuite
{
    /** static reference to .class.
     * Java does not provide
any way to obtain the Class object from
     * static method without naming it.
     */
 
   private static Class CLASS = AllTests.class;

    /**
     * runs the suite in a junit.textui.TestRunner.
    */
     public static void main(String[] args)
    {
        String[] arr = { CLASS.getName()};
       junit.textui.TestRunner.main(arr);
    }

    /** build a TestSuite from all the TestCases
in this package*/
    public static Test suite()
    {
        TestSuite suite = new TestSuite();
       suite.addTest(new TestSuite(PersistenceBrokerTest.class));
        suite.addTest(new
TestSuite(BrokerExamples.class));
        suite.addTest(new TestSuite(ProxyExamples.class));
       suite.addTest(new TestSuite(PolymorphicExtents.class));
        suite.addTest(new TestSuite(TreeTest.class));
       suite.addTest(new TestSuite(TypedCollectionsTest.class));
        suite.addTest(new
TestSuite(MtoNMapping.class));
        suite.addTest(new TestSuite(AutomaticForeignKeys.class));
       suite.addTest(new TestSuite(OptimisticLockingTest.class));
        suite.addTest(new
TestSuite(QueryTest.class));
        suite.addTest(new TestSuite(GraphTest.class));
    	suite.addTest(new
TestSuite(PBAwareTest.class));
        suite.addTest(new TestSuite(ContractVersionEffectivenessTest.class));
       suite.addTest(new TestSuite(ComplexMultiMappedTableTest.class));
        suite.addTest(new
TestSuite(ComplexMultiMappedTableWithCollectionByQueryTest.class));
        suite.addTest(new
TestSuite(BidirectionalAssociationTest.class));
        suite.addTest(new TestSuite(AutoIncrementWithRelatedObjectTest.class));
       suite.addTest(new TestSuite(OneToManyTest.class));
        suite.addTest(new TestSuite(PBRollbackTest.class));
       suite.addTest(new TestSuite(TransactionDemarcationTest.class));
        suite.addTest(new
TestSuite(MultipleDBTest.class));
        suite.addTest(new TestSuite(RepositoryPersistorTest.class));
       suite.addTest(new TestSuite(CustomAttributesTest.class));
        suite.addTest(new
TestSuite(SequenceManagerTest.class));
        suite.addTest(new TestSuite(ConvertedKeyReferenceTest.class));
	suite.addTest(new TestSuite(KeyConstraintViolationTest.class));
		suite.addTest(new TestSuite(RsIteratorTest.class));
	//suite.addTest(new TestSuite(BlobTest.class)); /* doesn't work for hsqldb */
		suite.addTest(new
TestSuite(LogServiceTest.class));
		suite.addTest(new TestSuite(ManyToManyTest.class));
	
suite.addTest(new TestSuite(OneToOneTest.class));
		suite.addTest(new TestSuite(MetaDataSerializationTest.class));
       return suite;
    }

}
  \ No newline at end of file
  +import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * the facade to all
TestCases in this package.
 *
 * @author: Thomas Mahler
 */
public class AllTests extends
junit.framework.TestSuite
{
    /** static reference to .class.
     * Java does not provide
any way to obtain the Class object from
     * static method without naming it.
     */
 
   private static Class CLASS = AllTests.class;

    /**
     * runs the suite in a junit.textui.TestRunner.
    */
     public static void main(String[] args)
    {
        String[] arr = { CLASS.getName()};
       junit.textui.TestRunner.main(arr);
    }

    /** build a TestSuite from all the TestCases
in this package*/
    public static Test suite()
    {
        TestSuite suite = new TestSuite();
       suite.addTest(new TestSuite(PersistenceBrokerTest.class));
        suite.addTest(new
TestSuite(BrokerExamples.class));
        suite.addTest(new TestSuite(ProxyExamples.class));
       suite.addTest(new TestSuite(PolymorphicExtents.class));
        suite.addTest(new TestSuite(TreeTest.class));
       suite.addTest(new TestSuite(TypedCollectionsTest.class));
        suite.addTest(new
TestSuite(MtoNMapping.class));
        suite.addTest(new TestSuite(AutomaticForeignKeys.class));
       suite.addTest(new TestSuite(OptimisticLockingTest.class));
        suite.addTest(new
TestSuite(QueryTest.class));
        suite.addTest(new TestSuite(GraphTest.class));
    	suite.addTest(new
TestSuite(PBAwareTest.class));
        suite.addTest(new TestSuite(ContractVersionEffectivenessTest.class));
       suite.addTest(new TestSuite(ComplexMultiMappedTableTest.class));
        suite.addTest(new
TestSuite(ComplexMultiMappedTableWithCollectionByQueryTest.class));
        suite.addTest(new
TestSuite(BidirectionalAssociationTest.class));
        suite.addTest(new TestSuite(AutoIncrementWithRelatedObjectTest.class));
       suite.addTest(new TestSuite(OneToManyTest.class));
        suite.addTest(new TestSuite(PBRollbackTest.class));
       suite.addTest(new TestSuite(TransactionDemarcationTest.class));
        suite.addTest(new
TestSuite(MultipleDBTest.class));
        suite.addTest(new TestSuite(RepositoryPersistorTest.class));
       suite.addTest(new TestSuite(CustomAttributesTest.class));
        suite.addTest(new
TestSuite(SequenceManagerTest.class));
        suite.addTest(new TestSuite(ConvertedKeyReferenceTest.class));
	suite.addTest(new TestSuite(KeyConstraintViolationTest.class));
		suite.addTest(new TestSuite(RsIteratorTest.class));
	//suite.addTest(new TestSuite(BlobTest.class)); /* doesn't work for hsqldb */
		suite.addTest(new
TestSuite(LogServiceTest.class));
		suite.addTest(new TestSuite(ManyToManyTest.class));
	
suite.addTest(new TestSuite(OneToOneTest.class));
		suite.addTest(new TestSuite(MetaDataSerializationTest.class));
	suite.addTest(new TestSuite(MetadataTest.class));
        return suite;
    }

}
  \ No newline at end of file
  
  
  
  1.13      +23 -8     jakarta-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java
  
  Index: SequenceManagerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SequenceManagerTest.java	24 Dec 2002 14:06:45 -0000	1.12
  +++ SequenceManagerTest.java	9 Jan 2003 17:20:15 -0000	1.13
  @@ -3,16 +3,18 @@
   import junit.framework.TestCase;
   import org.apache.ojb.broker.*;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  +import org.apache.ojb.broker.metadata.SequenceDescriptor;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
  -import org.apache.ojb.broker.util.sequence.SequenceConfiguration;
   import org.apache.ojb.broker.util.sequence.SequenceManager;
   import org.apache.ojb.broker.util.sequence.SequenceManagerException;
   import org.apache.ojb.broker.util.sequence.SequenceManagerFactory;
   import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
   import org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerSeqHiLoImpl;
   
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -83,15 +85,26 @@
               return;
           else
           {
  +
  +            PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +            SequenceManager sm = broker.serviceSequenceManager();
  +            int seqGrabSize = 0;
               // we need the SM grab size
  -            SequenceConfiguration conf =
  -                    (SequenceConfiguration) OjbConfigurator.getInstance().getConfigurationFor(null);
  -            int seqGrabSize = conf.getSequenceManagerGrabSize();
  +            if(sm instanceof SequenceManagerSeqHiLoImpl || sm instanceof SequenceManagerHighLowImpl)
  +            {
  +                SequenceDescriptor sd = broker.serviceConnectionManager().getConnectionDescriptor().getSequenceDescriptor();
  +                String strSize = sd.getConfigurationProperty(SequenceManagerHighLowImpl.PROPERTY_GRAB_SIZE);
  +                if(strSize != null)
  +                {
  +                    seqGrabSize = new Integer(strSize).intValue();
  +                }
  +            }
  +            broker.close();
   
               // the grab size have to be a factor of the loops number
  -            // to pass the 'testForLostKeys' test
  +            // to pass the 'testForLostKeys' test because we
               if (loops < seqGrabSize) loops = seqGrabSize;
  -            loops = (loops / seqGrabSize) * seqGrabSize;
  +            if(seqGrabSize != 0) loops = (loops / seqGrabSize) * seqGrabSize;
   
               brokers = new PersistenceBroker[instances];
               for (int i = 0; i < instances; i++)
  @@ -468,7 +481,9 @@
           TreeSet set = new TreeSet((List) generatedKeys.clone());
           if (set.isEmpty()) fail("No generated keys found");
           int result = ((Integer) set.last()).intValue() - ((Integer) set.first()).intValue()
+ 1;
  -        assertEquals("You have lost sequence numbers", keyCount, result);
  +        assertEquals("Sequence manager lost sequence numbers, this could be a failure or
could be"+
  +                " the volitional behaviour of the sequence manager"+
  +                " - retry test case, check test case, check sequence manager implementation.",
keyCount, result);
       }
   
       private void generateKeys()
  
  
  
  1.7       +17 -20    jakarta-ojb/src/test/org/apache/ojb/broker/metadata/RepositoryPersistorTest.java
  
  Index: RepositoryPersistorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/RepositoryPersistorTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RepositoryPersistorTest.java	26 Dec 2002 19:34:45 -0000	1.6
  +++ RepositoryPersistorTest.java	9 Jan 2003 17:20:15 -0000	1.7
  @@ -13,13 +13,10 @@
   {
   	public static void main(String[] args)
   	{
  -		String[] arr = { CLASS.getName()};
  +		String[] arr = { RepositoryPersistorTest.class.getName()};
   		junit.textui.TestRunner.main(arr);
   	}
   
  -	//PersistenceBroker broker;
  -	private static Class CLASS = RepositoryPersistorTest.class;
  -
   	/**
   	 * Insert the method's description here.
   	 * Creation date: (24.12.2000 00:33:40)
  @@ -75,20 +72,20 @@
               numClasses, numClasses2);
   	}
   
  -    /** Test storing repository.*/
  -	public void testStoreConnectionRepository() throws Exception
  -	{
  -		String filename = "test_repository_database.xml";
  -        DescriptorRepository repository = MetadataManager.getInstance().getRepository();
  -        ConnectionRepository conRepository = MetadataManager.getInstance().connectionRepository();
  -        int connectionCount = conRepository.getAllDescriptor().size();
  -        RepositoryPersistor persistor = new RepositoryPersistor();
  -        persistor.writeToFile(repository, conRepository, filename);
  -
  -        ConnectionRepository second = persistor.readConnectionRepository(filename);
  -        int connectionCount2 = second.getAllDescriptor().size();
  -
  -        assertEquals("read in persisted connection repository should have same number of
classes",
  -            connectionCount, connectionCount2);
  -	}
  +//    /** Test storing repository.*/
  +//	public void testStoreConnectionRepository() throws Exception
  +//	{
  +//		String filename = "test_repository_database.xml";
  +//        DescriptorRepository repository = MetadataManager.getInstance().getRepository();
  +//        ConnectionRepository conRepository = MetadataManager.getInstance().connectionRepository();
  +//        int connectionCount = conRepository.getAllDescriptor().size();
  +//        RepositoryPersistor persistor = new RepositoryPersistor();
  +//        persistor.writeToFile(repository, conRepository, filename);
  +//
  +//        ConnectionRepository second = persistor.readConnectionRepository(filename);
  +//        int connectionCount2 = second.getAllDescriptor().size();
  +//
  +//        assertEquals("read in persisted connection repository should have same number
of classes",
  +//            connectionCount, connectionCount2);
  +//	}
   }
  
  
  
  1.1                  jakarta-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
  
  Index: MetadataTest.java
  ===================================================================
  package org.apache.ojb.broker.metadata;
  
  import java.util.Iterator;
  
  import junit.framework.TestCase;
  import org.apache.ojb.broker.TestHelper;
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl;
  
  /**
   * This TestClass tests the RepositoryPersitors facilities for
   * reading and writing a valid repository.
   */
  public class MetadataTest extends TestCase
  {
  	public static void main(String[] args)
  	{
  		String[] arr = { MetadataTest.class.getName()};
  		junit.textui.TestRunner.main(arr);
  	}
  
  	/**
  	 * Insert the method's description here.
  	 * Creation date: (24.12.2000 00:33:40)
  	 */
  	public MetadataTest(String name)
  	{
  		super(name);
  	}
  
  	/**
  	 * Insert the method's description here.
  	 * Creation date: (06.12.2000 21:58:53)
  	 */
  	public void setUp()
  	{
  	}
  
  	/**
  	 * Insert the method's description here.
  	 * Creation date: (06.12.2000 21:59:14)
  	 */
  	public void tearDown()
  	{
  
  	}
  
  	public void testReadConnectionDescriptor()
      {
          JdbcConnectionDescriptor jcd = MetadataManager.getInstance().connectionRepository().
                                          getDescriptor(new PBKey("testConnection", "a user",
"a password"));
          /* descriptor snip
  
          <jdbc-connection-descriptor
          jcd-alias="testConnection"
          default-connection="true"
          platform="Oracle"
          jdbc-level="1.0"
          driver="a driver"
          protocol="a protocol"
          subprotocol="a subprotocol"
          dbalias="myDbalias"
          username="a user"
          password="a password"
          eager-release="true"
          batch-mode="true"
          useAutoCommit="0"
          ignoreAutoCommitExceptions="true"
      >
          <connection-pool
              maxActive="1"
              maxIdle="2"
              maxWait="3"
              minEvictableIdleTimeMillis="4"
              numTestsPerEvictionRun="5"
              testOnBorrow="true"
              testOnReturn="true"
              testWhileIdle="true"
              timeBetweenEvictionRunsMillis="6"
              whenExhaustedAction="2"
              validationQuery="a query"
              logAbandoned="true"
              removeAbandoned="true"
              removeAbandonedTimeout="8"
          />
  
          <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
              <attribute attribute-name="key1" attribute-value="value1"/>
              <attribute attribute-name="key2" attribute-value="value2"/>
          </sequence-manager>
      </jdbc-connection-descriptor>
          */
          assertEquals(true, jcd.isDefaultConnection());
  
          assertNotNull(jcd.getDbms());
          assertEquals("Oracle", jcd.getDbms());
          assertEquals(1.0d, jcd.getJdbcLevel(), 0.1);
  
          assertNotNull(jcd.getDriver());
          assertEquals("a driver", jcd.getDriver());
  
          assertNotNull(jcd.getProtocol());
          assertEquals("a protocol", jcd.getProtocol());
  
          assertNotNull(jcd.getSubProtocol());
          assertEquals("a subprotocol", jcd.getSubProtocol());
  
          assertNotNull(jcd.getDbAlias());
          assertEquals("myDbalias", jcd.getDbAlias());
  
          assertNotNull(jcd.getUserName());
          assertEquals("a user", jcd.getUserName());
  
          assertNotNull(jcd.getPassWord());
          assertEquals("a password", jcd.getPassWord());
  
          assertEquals(true, jcd.getEagerRelease());
  
          assertEquals(true, jcd.getBatchMode());
  
          assertEquals(0, jcd.getUseAutoCommit());
          assertEquals(true, jcd.isIgnoreAutoCommitExceptions());
  
  
          ConnectionPoolDescriptor cpd = jcd.getConnectionPoolDescriptor();
          assertEquals(1, cpd.getMaxActive());
          assertEquals(2, cpd.getMaxIdle());
          assertEquals(3, cpd.getMaxWait());
          assertEquals(4, cpd.getMinEvictableIdleTimeMillis());
          assertEquals(5, cpd.getNumTestsPerEvictionRun());
          assertEquals(true, cpd.isTestOnBorrow());
          assertEquals(true, cpd.isTestOnReturn());
          assertEquals(true, cpd.isTestWhileIdle());
          assertEquals(6, cpd.getTimeBetweenEvictionRunsMillis());
          assertEquals(2, cpd.getWhenExhaustedAction());
  
          assertNotNull(cpd.getValidationQuery());
          assertEquals("a query", cpd.getValidationQuery());
  
          assertEquals(true, cpd.isLogAbandoned());
          assertEquals(true, cpd.isRemoveAbandoned());
          assertEquals(8, cpd.getRemoveAbandonedTimeout());
  
          SequenceDescriptor seq = jcd.getSequenceDescriptor();
          assertEquals(SequenceManagerHighLowImpl.class.getName(), seq.getSequenceManagerClass().getName());
  
          assertNotNull(seq.getConfigurationProperty("key1"));
          assertEquals("value1", seq.getConfigurationProperty("key1"));
  
          assertNotNull(seq.getConfigurationProperty("key2"));
          assertEquals("value2", seq.getConfigurationProperty("key2"));
      }
  }
  
  
  
  1.7       +5 -5      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/auto/AutoBuildDb.java
  
  Index: AutoBuildDb.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/auto/AutoBuildDb.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AutoBuildDb.java	24 Dec 2002 14:05:35 -0000	1.6
  +++ AutoBuildDb.java	9 Jan 2003 17:20:15 -0000	1.7
  @@ -7,8 +7,8 @@
    */
   package org.apache.ojb.broker.metadata.auto;
   
  +import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
   
   import java.sql.Connection;
   
  @@ -16,20 +16,20 @@
   {
       public static void main(String args[])
       {
  -        PersistenceBrokerImpl broker = null;
  +        PersistenceBroker broker = null;
           try
           {
  -            broker = (PersistenceBrokerImpl) PersistenceBrokerFactory.defaultPersistenceBroker();
  +            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
               Connection conn = broker.serviceConnectionManager().getConnection();
               AutoCreatorDb.autoCreate(broker.getDescriptorRepository(), broker.serviceConnectionManager());
           }
  -        catch(Exception e)
  +        catch (Exception e)
           {
               e.printStackTrace();
           }
           finally
           {
  -            if(broker != null) broker.close();
  +            if (broker != null) broker.close();
           }
       }
   }
  
  
  

Mime
View raw message