KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > metadata > torque > TorqueTablePreprocessorTest


1 package org.apache.ojb.broker.metadata.torque;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6 import junit.textui.TestRunner;
7 import org.apache.ojb.broker.metadata.DescriptorRepository;
8 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
9 import org.apache.ojb.broker.metadata.RepositoryPersistor;
10 import org.apache.ojb.broker.metadata.torque.TableDescriptor;
11 import org.apache.ojb.broker.metadata.torque.TorqueTablePreprocessor;
12 import org.apache.ojb.broker.TestHelper;
13
14 import java.util.HashMap JavaDoc;
15 import java.util.Vector JavaDoc;
16
17 public class TorqueTablePreprocessorTest extends TestCase {
18
19     private static final String JavaDoc EXAMPLE_FILE = TestHelper.DEF_REPOSITORY;
20     private TorqueTablePreprocessor torqueTablePreprocessor;
21
22     public TorqueTablePreprocessorTest(String JavaDoc name) {
23         super(name);
24     }
25
26     public void setUp() throws Exception JavaDoc {
27         RepositoryPersistor repositoryPersistor = new RepositoryPersistor();
28         DescriptorRepository descriptorRepository = repositoryPersistor.readDescriptorRepository(EXAMPLE_FILE);
29         this.torqueTablePreprocessor = new TorqueTablePreprocessor(descriptorRepository);
30     }
31
32     public void tearDown() throws Exception JavaDoc {
33         this.torqueTablePreprocessor = null;
34     }
35
36     public void testBuildStandardTables() {
37         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
38         this.torqueTablePreprocessor.buildStandardTables();
39         HashMap JavaDoc standardTables = this.torqueTablePreprocessor.getStandardTables();
40         assertNotNull(standardTables);
41         TableDescriptor tableDescriptor = (TableDescriptor) standardTables.get("Artikel");
42         assertEquals("Artikel", tableDescriptor.getName());
43         assertTrue(tableDescriptor.getIndices().isEmpty());
44         Vector JavaDoc columns = tableDescriptor.getColumns();
45         assertNotNull(columns);
46         assertEquals(10, columns.size());
47         Vector JavaDoc references = tableDescriptor.getReferences();
48         assertNotNull(references);
49         assertEquals(2, references.size());
50         ObjectReferenceDescriptor ord = ((ObjectReferenceDescriptor) references.get(0));
51
52         assertTrue(org.apache.ojb.odmg.shared.ProductGroup.class == ord.getItemClass() || org.apache.ojb.broker.ProductGroup.class == ord.getItemClass());
53         ord = ((ObjectReferenceDescriptor) references.get(1));
54         assertTrue(org.apache.ojb.odmg.shared.ProductGroup.class == ord.getItemClass() || org.apache.ojb.broker.ProductGroup.class == ord.getItemClass());
55     }
56
57
58     public static void main(String JavaDoc[] args) {
59         TestRunner.run(suite());
60     }
61
62     public static Test suite() {
63         return new TestSuite(TorqueTablePreprocessorTest.class);
64     }
65
66 }
67
Popular Tags