01: package org.apache.ojb.broker.metadata.torque;
02:
03: import junit.framework.Test;
04: import junit.framework.TestCase;
05: import junit.framework.TestSuite;
06: import junit.textui.TestRunner;
07: import org.apache.ojb.broker.metadata.FieldDescriptor;
08: import org.apache.ojb.broker.metadata.torque.TableDescriptor;
09:
10: import java.util.Vector;
11:
12: public class TableDescriptorTest extends TestCase {
13:
14: private TableDescriptor tableDescriptor;
15:
16: public TableDescriptorTest(String name) {
17: super (name);
18: }
19:
20: public void setUp() throws Exception {
21: this .tableDescriptor = new TableDescriptor();
22: }
23:
24: public void tearDown() throws Exception {
25: this .tableDescriptor = null;
26: }
27:
28: public void testAddColumn() {
29: FieldDescriptor fieldDescriptor = new FieldDescriptor(null, 1);
30: fieldDescriptor.setColumnName("JUnit 1");
31: this .tableDescriptor.addColumn(fieldDescriptor);
32: Vector columns = this .tableDescriptor.getColumns();
33: assertNotNull("The vector of columns is strangely null",
34: columns);
35: assertEquals("There was strangely not 1 element in the vector",
36: 1, columns.size());
37: this .tableDescriptor.addColumn(fieldDescriptor);
38: columns = this .tableDescriptor.getColumns();
39: assertEquals("There was strangely not 1 element in the vector",
40: 1, columns.size());
41: FieldDescriptor newFieldDescriptor = new FieldDescriptor(null,
42: 2);
43: newFieldDescriptor.setColumnName("JUnit 2");
44: this .tableDescriptor.addColumn(newFieldDescriptor);
45: columns = this .tableDescriptor.getColumns();
46: assertEquals("There was strangely not 1 element in the vector",
47: 2, columns.size());
48: }
49:
50: public static void main(String[] args) {
51: TestRunner.run(suite());
52: }
53:
54: public static Test suite() {
55: return new TestSuite(TableDescriptorTest.class);
56: }
57:
58: }
|