KickJava   Java API By Example, From Geeks To Geeks.

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


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.FieldDescriptor;
8 import org.apache.ojb.broker.metadata.torque.TableDescriptor;
9
10 import java.util.Vector JavaDoc;
11
12 public class TableDescriptorTest extends TestCase {
13
14     private TableDescriptor tableDescriptor;
15
16     public TableDescriptorTest(String JavaDoc name) {
17         super(name);
18     }
19
20     public void setUp() throws Exception JavaDoc {
21         this.tableDescriptor = new TableDescriptor();
22     }
23
24     public void tearDown() throws Exception JavaDoc {
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 JavaDoc columns = this.tableDescriptor.getColumns();
33         assertNotNull("The vector of columns is strangely null", columns);
34         assertEquals("There was strangely not 1 element in the vector", 1, columns.size());
35         this.tableDescriptor.addColumn(fieldDescriptor);
36         columns = this.tableDescriptor.getColumns();
37         assertEquals("There was strangely not 1 element in the vector", 1, columns.size());
38         FieldDescriptor newFieldDescriptor = new FieldDescriptor(null, 2);
39         newFieldDescriptor.setColumnName("JUnit 2");
40         this.tableDescriptor.addColumn(newFieldDescriptor);
41         columns = this.tableDescriptor.getColumns();
42         assertEquals("There was strangely not 1 element in the vector", 2, columns.size());
43     }
44
45     public static void main(String JavaDoc[] args) {
46         TestRunner.run(suite());
47     }
48
49     public static Test suite() {
50         return new TestSuite(TableDescriptorTest.class);
51     }
52
53 }
54
Popular Tags