db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker/metadata MetadataTest.java MetadataMultithreadedTest.java
Date Sat, 24 May 2003 01:42:00 GMT
arminw      2003/05/23 18:41:59

  Modified:    src/test/org/apache/ojb/broker/metadata MetadataTest.java
                        MetadataMultithreadedTest.java
  Log:
  update test case
  
  Revision  Changes    Path
  1.9       +8 -2      db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
  
  Index: MetadataTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MetadataTest.java	24 May 2003 00:56:38 -0000	1.8
  +++ MetadataTest.java	24 May 2003 01:41:59 -0000	1.9
  @@ -52,7 +52,13 @@
   
       public void tearDown()
       {
  -
  +        try
  +        {
  +            MetadataManager.getInstance().setEnablePerThreadChanges(false);
  +        }
  +        catch (Exception e)
  +        {
  +        }
       }
   
       public void testLoadingProfiles() throws Exception
  @@ -64,7 +70,7 @@
               mm.setEnablePerThreadChanges(true);
               DescriptorRepository dr_1 = mm.readDescriptorRepository(TEST_CLASS_DESCRIPTOR);
               // add some profiles
  -            mm.addProfile("global", mm.getGlobalRepository());
  +            mm.addProfile("global", mm.copyOfGlobalRepository());
               mm.addProfile("test", dr_1);
   
               // now load a specific profile
  
  
  
  1.2       +40 -21    db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java
  
  Index: MetadataMultithreadedTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MetadataMultithreadedTest.java	22 May 2003 19:39:42 -0000	1.1
  +++ MetadataMultithreadedTest.java	24 May 2003 01:41:59 -0000	1.2
  @@ -28,6 +28,17 @@
           junit.textui.TestRunner.main(arr);
       }
   
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +    }
  +
  +    protected void tearDown() throws Exception
  +    {
  +        super.tearDown();
  +        MetadataManager.getInstance().setEnablePerThreadChanges(false);
  +    }
  +
       private String getTestObjectString()
       {
           return oldTestObjectString;
  @@ -42,29 +53,37 @@
               // enable the per thread changes of metadata
               MetadataManager.getInstance().setEnablePerThreadChanges(true);
   
  -            long period = System.currentTimeMillis();
  -            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -            ClassDescriptor cld = broker.getClassDescriptor(targetTestClass);
  +            ClassDescriptor cld;
   
  -            // we manipulate the schema name of the class
  -            // thus we note the original value
  -            oldTestObjectString = cld.getSchema();
  -            broker.close();
  +            try
  +            {
  +                long period = System.currentTimeMillis();
  +                broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +                cld = broker.getClassDescriptor(targetTestClass);
  +
  +                // we manipulate the schema name of the class
  +                // thus we note the original value
  +                oldTestObjectString = cld.getSchema();
  +                broker.close();
  +
  +                TestCaseRunnable tct [] = new TestCaseRunnable[10];
  +                for (int i = 0; i < 10; i++)
  +                {
  +                    if (i < 5)
  +                        tct[i] = new ThreadedUsingBroker(loops);
  +                    else
  +                        tct[i] = new GlobalUsingBroker(loops);
  +                }
  +                // run test classes
  +                runTestCaseRunnables(tct);
   
  -            TestCaseRunnable tct [] = new TestCaseRunnable[10];
  -            for (int i = 0; i < 10; i++)
  +                period = System.currentTimeMillis() - period;
  +                System.out.println("RuntimeMetadataChanges test take: " + period + " ms");
  +            }
  +            finally
               {
  -                if (i < 5)
  -                    tct[i] = new ThreadedUsingBroker(loops);
  -                else
  -                    tct[i] = new GlobalUsingBroker(loops);
  +                MetadataManager.getInstance().setEnablePerThreadChanges(false);
               }
  -            // run test classes
  -            runTestCaseRunnables(tct);
  -
  -            period = System.currentTimeMillis() - period;
  -            System.out.println("RuntimeMetadataChanges test take: " + period + " ms");
  -            MetadataManager.getInstance().setEnablePerThreadChanges(false);
   
               broker = PersistenceBrokerFactory.defaultPersistenceBroker();
               cld = broker.getClassDescriptor(targetTestClass);
  @@ -102,7 +121,7 @@
               // we change a class descriptor value
               cld.setSchema(newTestObjectString);
               // set the changed repository for this thread
  -            mm.setPerThreadDescriptor(dr);
  +            mm.setDescriptor(dr);
   
               int k = 0;
               while (k < loops)
  
  
  

Mime
View raw message