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 CustomAttributesTest.java RepositoryPersistorTest.java
Date Tue, 24 Dec 2002 14:05:36 GMT
arminw      2002/12/24 06:05:36

  Modified:    src/test/org/apache/ojb/broker/metadata/auto
                        AutoBuildDb.java
               src/test/org/apache/ojb/broker/metadata/torque
                        TableDescriptorTest.java
                        TorqueFieldGeneratorTest.java
                        TorqueForeignKeyGeneratorTest.java
                        TorqueRepositoryGeneratorTest.java
                        TorqueTableGeneratorTest.java
                        TorqueTablePreprocessorTest.java
               src/test/org/apache/ojb/broker/metadata
                        CustomAttributesTest.java
                        RepositoryPersistorTest.java
  Log:
  update tool test cases
  
  Revision  Changes    Path
  1.6       +22 -17    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AutoBuildDb.java	1 Dec 2002 11:49:02 -0000	1.5
  +++ AutoBuildDb.java	24 Dec 2002 14:05:35 -0000	1.6
  @@ -3,28 +3,33 @@
    * @version 0.1
    * Date: Jul 8, 2002
    * Time: 2:34:03 PM
  - * 
  + *
    */
   package org.apache.ojb.broker.metadata.auto;
   
  -import java.sql.Connection;
  -
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
   
  -public class AutoBuildDb {
  -	public static void main(String args[]){
  -
  -		try {
  -			PersistenceBrokerImpl broker = (PersistenceBrokerImpl)PersistenceBrokerFactory.defaultPersistenceBroker();
  -			//broker.getDescriptorRepository().printDescriptorTable();
  -			Connection conn = broker.getConnectionManager().getConnection();
  -			AutoCreatorDb.autoCreate(broker.getDescriptorRepository(), conn);
  -		}
  -		catch (Exception e) {
  -			e.printStackTrace();
  -		}
  -
  +import java.sql.Connection;
   
  -	}
  +public class AutoBuildDb
  +{
  +    public static void main(String args[])
  +    {
  +        PersistenceBrokerImpl broker = null;
  +        try
  +        {
  +            broker = (PersistenceBrokerImpl) PersistenceBrokerFactory.defaultPersistenceBroker();
  +            Connection conn = broker.serviceConnectionManager().getConnection();
  +            AutoCreatorDb.autoCreate(broker.getDescriptorRepository(), broker.serviceConnectionManager());
  +        }
  +        catch(Exception e)
  +        {
  +            e.printStackTrace();
  +        }
  +        finally
  +        {
  +            if(broker != null) broker.close();
  +        }
  +    }
   }
  
  
  
  1.2       +2 -2      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TableDescriptorTest.java
  
  Index: TableDescriptorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TableDescriptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableDescriptorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TableDescriptorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -26,7 +26,7 @@
       }
   
       public void testAddColumn() {
  -        FieldDescriptor fieldDescriptor = new FieldDescriptor(1);
  +        FieldDescriptor fieldDescriptor = new FieldDescriptor(null, 1);
           fieldDescriptor.setColumnName("JUnit 1");
           this.tableDescriptor.addColumn(fieldDescriptor);
           Vector columns = this.tableDescriptor.getColumns();
  @@ -35,7 +35,7 @@
           this.tableDescriptor.addColumn(fieldDescriptor);
           columns = this.tableDescriptor.getColumns();
           assertEquals("There was strangely not 1 element in the vector", 1, columns.size());
  -        FieldDescriptor newFieldDescriptor = new FieldDescriptor(2);
  +        FieldDescriptor newFieldDescriptor = new FieldDescriptor(null, 2);
           newFieldDescriptor.setColumnName("JUnit 2");
           this.tableDescriptor.addColumn(newFieldDescriptor);
           columns = this.tableDescriptor.getColumns();
  
  
  
  1.2       +8 -8      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueFieldGeneratorTest.java
  
  Index: TorqueFieldGeneratorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueFieldGeneratorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueFieldGeneratorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TorqueFieldGeneratorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -31,11 +31,11 @@
           StringBuffer buffer = new StringBuffer();
   
           FieldDescriptor[] descriptors = new FieldDescriptor[2];
  -        descriptors[0] = new FieldDescriptor(1);
  +        descriptors[0] = new FieldDescriptor(null, 1);
           descriptors[0].setColumnName("JUnit column 1");
           descriptors[0].setColumnType("VARCHAR");
   
  -        descriptors[1] = new FieldDescriptor(2);
  +        descriptors[1] = new FieldDescriptor(null, 2);
           descriptors[1].setColumnName("JUnit column 2");
           descriptors[1].setColumnType("DOUBLE");
           descriptors[1].setRequired(true);
  @@ -50,11 +50,11 @@
           buffer = new StringBuffer();
   
           descriptors = new FieldDescriptor[2];
  -        descriptors[0] = new FieldDescriptor(1);
  +        descriptors[0] = new FieldDescriptor(null, 1);
           descriptors[0].setColumnName("JUnit column 1");
           descriptors[0].setColumnType("VARCHAR");
   
  -        descriptors[1] = new FieldDescriptor(2);
  +        descriptors[1] = new FieldDescriptor(null, 2);
           descriptors[1].setColumnName("JUnit column 2");
           descriptors[1].setColumnType("DOUBLE");
           descriptors[1].setRequired(true);
  @@ -71,11 +71,11 @@
           StringBuffer buffer = new StringBuffer();
   
           FieldDescriptor[] descriptors = new FieldDescriptor[2];
  -        descriptors[0] = new FieldDescriptor(1);
  +        descriptors[0] = new FieldDescriptor(null, 1);
           descriptors[0].setColumnName("JUnit column 1");
           descriptors[0].setColumnType("VARCHAR");
   
  -        descriptors[1] = new FieldDescriptor(2);
  +        descriptors[1] = new FieldDescriptor(null, 2);
           descriptors[1].setColumnName("JUnit column 2");
           descriptors[1].setColumnType("DOUBLE");
           descriptors[1].setRequired(true);
  @@ -90,11 +90,11 @@
           buffer = new StringBuffer();
   
           descriptors = new FieldDescriptor[2];
  -        descriptors[0] = new FieldDescriptor(1);
  +        descriptors[0] = new FieldDescriptor(null,1);
           descriptors[0].setColumnName("JUnit column 1");
           descriptors[0].setColumnType("VARCHAR");
   
  -        descriptors[1] = new FieldDescriptor(2);
  +        descriptors[1] = new FieldDescriptor(null, 2);
           descriptors[1].setColumnName("JUnit column 2");
           descriptors[1].setColumnType("DOUBLE");
           descriptors[1].setRequired(true);
  
  
  
  1.2       +3 -2      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueForeignKeyGeneratorTest.java
  
  Index: TorqueForeignKeyGeneratorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueForeignKeyGeneratorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueForeignKeyGeneratorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TorqueForeignKeyGeneratorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -8,13 +8,14 @@
   import org.apache.ojb.broker.metadata.RepositoryPersistor;
   import org.apache.ojb.broker.metadata.torque.TableDescriptor;
   import org.apache.ojb.broker.metadata.torque.TorqueForeignKeyGenerator;
  +import org.apache.ojb.broker.TestHelper;
   
   import java.util.HashMap;
   import java.util.Vector;
   
   public class TorqueForeignKeyGeneratorTest extends TestCase {
   
  -    private static final String EXAMPLE_FILE = "repository.xml";
  +    private static final String EXAMPLE_FILE = TestHelper.DEF_REPOSITORY;
       private static final String OJB_DLIST_ENTRY_FOREIGN_KEY =
               "        <foreign-key foreignTable=\"OJB_DLIST\">\n" +
               "            <reference local=\"DLIST_ID\" foreign=\"ID\"/>\n" +
  @@ -49,7 +50,7 @@
   
       public void setUp() throws Exception {
           RepositoryPersistor repositoryPersistor = new RepositoryPersistor();
  -        DescriptorRepository descriptorRepository = repositoryPersistor.readFromFile(EXAMPLE_FILE);
  +        DescriptorRepository descriptorRepository = repositoryPersistor.readDescriptorRepository(EXAMPLE_FILE);
           this.foreignKeyGenerator = new TorqueForeignKeyGenerator(descriptorRepository);
       }
   
  
  
  
  1.2       +3 -2      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueRepositoryGeneratorTest.java
  
  Index: TorqueRepositoryGeneratorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueRepositoryGeneratorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueRepositoryGeneratorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TorqueRepositoryGeneratorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -7,13 +7,14 @@
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.RepositoryPersistor;
   import org.apache.ojb.broker.metadata.torque.TorqueRepositoryGenerator;
  +import org.apache.ojb.broker.TestHelper;
   
   import java.io.File;
   import java.io.FileReader;
   
   public class TorqueRepositoryGeneratorTest extends TestCase {
   
  -    private static final String INPUT_FILE = "repository.xml";
  +    private static final String INPUT_FILE = TestHelper.DEF_REPOSITORY;
       private static final String OUTPUT_FILE = "test-project-schema.xml";
       private static final String EXPECTED_OUTPUT_FILE = "expected-project-schema.xml";
       private TorqueRepositoryGenerator torqueRepositoryGenerator;
  @@ -25,7 +26,7 @@
   
       public void setUp() throws Exception {
           RepositoryPersistor repositoryPersistor = new RepositoryPersistor();
  -        this.repository = repositoryPersistor.readFromFile(INPUT_FILE);
  +        this.repository = repositoryPersistor.readDescriptorRepository(INPUT_FILE);
           this.torqueRepositoryGenerator = new TorqueRepositoryGenerator(INPUT_FILE, false);
       }
   
  
  
  
  1.2       +3 -2      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueTableGeneratorTest.java
  
  Index: TorqueTableGeneratorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueTableGeneratorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueTableGeneratorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TorqueTableGeneratorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -10,10 +10,11 @@
   import org.apache.ojb.broker.metadata.RepositoryPersistor;
   import org.apache.ojb.broker.metadata.torque.TableDescriptor;
   import org.apache.ojb.broker.metadata.torque.TorqueTableGenerator;
  +import org.apache.ojb.broker.TestHelper;
   
   public class TorqueTableGeneratorTest extends TestCase {
   
  -    private static final String EXAMPLE_FILE = "repository.xml";
  +    private static final String EXAMPLE_FILE = TestHelper.DEF_REPOSITORY;
       private static final String EMPTY_STANDARD_TABLE =
               "    <table name=\"null\" indexTablespace=\"JUnit indx\">\n" +
               "    </table>\n\n";
  @@ -50,7 +51,7 @@
   
       public void setUp() throws Exception {
           RepositoryPersistor repositoryPersistor = new RepositoryPersistor();
  -        this.repository = repositoryPersistor.readFromFile(EXAMPLE_FILE);
  +        this.repository = repositoryPersistor.readDescriptorRepository(EXAMPLE_FILE);
           this.torqueTableGenerator = new TorqueTableGenerator(this.repository, false);
       }
   
  
  
  
  1.2       +3 -2      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueTablePreprocessorTest.java
  
  Index: TorqueTablePreprocessorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/torque/TorqueTablePreprocessorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueTablePreprocessorTest.java	20 Jun 2002 17:07:54 -0000	1.1
  +++ TorqueTablePreprocessorTest.java	24 Dec 2002 14:05:35 -0000	1.2
  @@ -9,13 +9,14 @@
   import org.apache.ojb.broker.metadata.RepositoryPersistor;
   import org.apache.ojb.broker.metadata.torque.TableDescriptor;
   import org.apache.ojb.broker.metadata.torque.TorqueTablePreprocessor;
  +import org.apache.ojb.broker.TestHelper;
   
   import java.util.HashMap;
   import java.util.Vector;
   
   public class TorqueTablePreprocessorTest extends TestCase {
   
  -    private static final String EXAMPLE_FILE = "repository.xml";
  +    private static final String EXAMPLE_FILE = TestHelper.DEF_REPOSITORY;
       private TorqueTablePreprocessor torqueTablePreprocessor;
   
       public TorqueTablePreprocessorTest(String name) {
  @@ -24,7 +25,7 @@
   
       public void setUp() throws Exception {
           RepositoryPersistor repositoryPersistor = new RepositoryPersistor();
  -        DescriptorRepository descriptorRepository = repositoryPersistor.readFromFile(EXAMPLE_FILE);
  +        DescriptorRepository descriptorRepository = repositoryPersistor.readDescriptorRepository(EXAMPLE_FILE);
           this.torqueTablePreprocessor = new TorqueTablePreprocessor(descriptorRepository);
       }
   
  
  
  
  1.3       +3 -6      jakarta-ojb/src/test/org/apache/ojb/broker/metadata/CustomAttributesTest.java
  
  Index: CustomAttributesTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/metadata/CustomAttributesTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CustomAttributesTest.java	30 Oct 2002 20:44:06 -0000	1.2
  +++ CustomAttributesTest.java	24 Dec 2002 14:05:36 -0000	1.3
  @@ -4,7 +4,7 @@
   
   import org.apache.ojb.broker.Article;
   
  -/** 
  +/**
    * This TestClass tests the RepositoryPersitors facilities for
    * reading and writing a valid repository.
    */
  @@ -48,7 +48,7 @@
   	/** Test storing repository.*/
   	public void testReadCustomAttributes()
   	{
  -		DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +		DescriptorRepository repository = MetadataManager.getInstance().getRepository();
   
   		ClassDescriptor cld = repository.getDescriptorFor(Article.class);
   		assertTrue("blue".equals(cld.getAttribute("color")));
  @@ -58,13 +58,10 @@
   		assertTrue("green".equals(fld.getAttribute("color")));
   		assertTrue("small".equals(fld.getAttribute("size")));
   
  -		
  +
   		ObjectReferenceDescriptor ord = cld.getObjectReferenceDescriptorByName("productGroup");
   		assertNotNull("did not find ord for 'productGroup'!", ord);
   		assertTrue("red".equals(ord.getAttribute("color")));
   		assertTrue("tiny".equals(ord.getAttribute("size")));
  -		
  -
   	}
  -
   }
  
  
  
  1.5       +38 -25    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RepositoryPersistorTest.java	8 Nov 2002 14:01:28 -0000	1.4
  +++ RepositoryPersistorTest.java	24 Dec 2002 14:05:36 -0000	1.5
  @@ -3,6 +3,7 @@
   import java.util.Iterator;
   
   import junit.framework.TestCase;
  +import org.apache.ojb.broker.TestHelper;
   
   /**
    * This TestClass tests the RepositoryPersitors facilities for
  @@ -45,36 +46,48 @@
   
   	}
   
  -
  -
   	/** Test storing repository.*/
   	public void testStoreRepository() throws Exception
   	{
  -		String filename = "test.xml";
  -	        DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +		String filename = "test_respository.xml";
  +        DescriptorRepository repository = MetadataManager.getInstance().getRepository();
   
  -	        Iterator iter = repository.iterator();
  -	        int numClasses = 0;
  -	        while (iter.hasNext())
  -	        {
  -	        	iter.next();
  -	        	numClasses++;
  -	        }
  -
  -	        RepositoryPersistor persistor = new RepositoryPersistor();
  -	        persistor.writeToFile(repository, filename);
  -
  -	        DescriptorRepository second = persistor.readFromFile(filename);
  -	        iter = second.iterator();
  -	        int numClasses2 = 0;
  -	        while (iter.hasNext())
  -	        {
  -	        	iter.next();
  -	        	numClasses2++;
  -	        }
  -	        assertEquals("read in persisted repository should have same number of classes",
  -	        	numClasses, numClasses2);
  +        Iterator iter = repository.iterator();
  +        int numClasses = 0;
  +        while (iter.hasNext())
  +        {
  +            iter.next();
  +            numClasses++;
  +        }
  +
  +        RepositoryPersistor persistor = new RepositoryPersistor();
  +        persistor.writeToFile(repository, filename);
  +
  +        DescriptorRepository second = persistor.readDescriptorRepository(filename);
  +        iter = second.iterator();
  +        int numClasses2 = 0;
  +        while (iter.hasNext())
  +        {
  +            iter.next();
  +            numClasses2++;
  +        }
  +        assertEquals("read in persisted repository should have same number of classes",
  +            numClasses, numClasses2);
   	}
   
  +    /** Test storing repository.*/
  +	public void testStoreConnectionRepository() throws Exception
  +	{
  +		String filename = "test_repository_database.xml";
  +        ConnectionRepository repository = MetadataManager.getInstance().connectionRepository();
  +        int connectionCount = repository.getAllDescriptor().size();
  +        RepositoryPersistor persistor = new RepositoryPersistor();
  +        persistor.writeToFile(repository, 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);
  +	}
   }
  
  
  

Mime
View raw message