1 24 25 package org.objectweb.cjdbc.scenario.standalone.sql.schema; 26 27 import java.sql.Types ; 28 29 import org.objectweb.cjdbc.common.sql.schema.AliasedDatabaseTable; 30 import org.objectweb.cjdbc.common.sql.schema.DatabaseColumn; 31 import org.objectweb.cjdbc.common.sql.schema.DatabaseTable; 32 import org.objectweb.cjdbc.common.sql.schema.TableColumn; 33 import org.objectweb.cjdbc.scenario.templates.NoTemplate; 34 35 38 public class SchemaTest extends NoTemplate 39 { 40 44 public void testAliasedDatabaseTable() 45 { 46 AliasedDatabaseTable at1, at2, at3, at4; 47 DatabaseTable t1 = new DatabaseTable("buy_now", 5); 48 DatabaseColumn c1 = new DatabaseColumn("id", true); 49 DatabaseColumn c2 = new DatabaseColumn("buyer_id", false); 50 DatabaseColumn c3 = new DatabaseColumn("item_id", false); 51 DatabaseColumn c4 = new DatabaseColumn("qty", false); 52 DatabaseColumn c5 = new DatabaseColumn("date", false); 53 54 t1.addColumn(c1); 55 t1.addColumn(c2); 56 t1.addColumn(c3); 57 t1.addColumn(c4); 58 t1.addColumn(c5); 59 60 DatabaseTable t2 = new DatabaseTable("buy_now2", 5); 61 t2.addColumn(c1); 62 t2.addColumn(c2); 63 t2.addColumn(c3); 64 t2.addColumn(c4); 65 t2.addColumn(c5); 66 67 at1 = new AliasedDatabaseTable(t1, "alias1"); 68 at2 = new AliasedDatabaseTable(t1, "alias2"); 69 at3 = new AliasedDatabaseTable(t2, "alias1"); 70 at4 = new AliasedDatabaseTable(t1, "alias1"); 71 72 assertTrue(at1.equals(at1)); 73 assertFalse(at1.equals(at2)); 74 assertFalse(at1.equals(at3)); 75 assertTrue(at1.equals(at4)); 76 } 77 78 82 public void testDatabaseColumn() 83 { 84 DatabaseColumn c1, c2, c3, c4, c5, c6; 85 c1 = new DatabaseColumn("foo", true); 86 c2 = new DatabaseColumn("foo", true); 87 c3 = new DatabaseColumn("foo", false); 88 89 c4 = new DatabaseColumn("foo", true, Types.INTEGER); 90 c5 = new DatabaseColumn("foo", true, Types.VARCHAR); 91 c6 = new DatabaseColumn("foo", true, Types.NULL); 92 93 assertTrue(c1.equals(c2)); 95 assertFalse(c1.equals(c3)); 96 assertFalse(c1.equals(c4)); 97 assertFalse(c1.equals(c5)); 98 assertTrue(c1.equals(c6)); 99 100 assertTrue(c1.equalsIgnoreType(c2)); 102 assertFalse(c1.equalsIgnoreType(c3)); 103 assertTrue(c1.equalsIgnoreType(c4)); 104 assertTrue(c1.equalsIgnoreType(c5)); 105 assertTrue(c1.equalsIgnoreType(c6)); 106 assertTrue(c4.equalsIgnoreType(c5)); 107 assertTrue(c4.equalsIgnoreType(c6)); 108 109 } 110 111 115 public void testTableColumn() 116 { 117 TableColumn t1, t2, t3, t4; 118 t1 = new TableColumn("table1", "name1"); 119 t2 = new TableColumn("table1", "name1"); 120 t3 = new TableColumn("table1", "name2"); 121 t4 = new TableColumn("table2", "name1"); 122 123 assertTrue(t1.equals(t1)); 124 assertTrue(t1.equals(t2)); 125 assertFalse(t1.equals(t3)); 126 assertFalse(t1.equals(t4)); 127 } 128 } | Popular Tags |