1
2
3
4
5
6
7 package test.org.asyrinx.joey.gen.command.rdb;
8
9 import junit.framework.TestCase;
10
11 import org.asyrinx.joey.gen.command.rdb.CheckColumnType;
12 import org.asyrinx.joey.gen.model.command.ValidationError;
13 import org.asyrinx.joey.gen.model.rdb.Column;
14 import org.asyrinx.joey.gen.model.rdb.Table;
15 import org.asyrinx.joey.gen.model.rdb.visitor.RdbVisitorAdapter;
16 import org.asyrinx.joey.gen.model.rdb.visitor.RdbTopDownVisitor;
17
18 /***
19 * @author akima
20 */
21 public class CheckColumnTypeTest extends TestCase {
22
23 public static void main(String[] args) {
24 junit.swingui.TestRunner.run(CheckColumnTypeTest.class);
25 }
26
27 public void testNormal() {
28 final Table table1 = new Table("table1");
29 new Column(table1, "col1-1", "BIGINT");
30 new Column(table1, "col1-2", "INTEGER");
31 new Column(table1, "col1-3", "VARCHAR", "20");
32
33 try {
34 new RdbVisitorAdapter(new RdbTopDownVisitor(new CheckColumnType())).visit(table1);
35 } catch (Throwable e) {
36 e.printStackTrace();
37 fail();
38 }
39 }
40
41 public void testUncapitalized() {
42 final Table table1 = new Table("table1");
43 final Column col1 = new Column(table1, "col1-1", "BIGINT");
44 final Column col2 = new Column(table1, "col1-2", "int");
45 final Column col3 = new Column(table1, "col1-3", "VARCHAR", "20");
46
47 try {
48 new CheckColumnType().execute(table1);
49
50 fail();
51 } catch (ValidationError e) {
52 assertEquals(col2, e.getElement());
53 } catch (Throwable e) {
54 e.printStackTrace();
55 fail();
56 }
57
58 col2.setType("integer");
59 try {
60 new CheckColumnType().execute(table1);
61 fail();
62 } catch (ValidationError e) {
63 assertEquals(col2, e.getElement());
64 } catch (Throwable e) {
65 e.printStackTrace();
66 fail();
67 }
68
69 col2.setType("INTEGER");
70 try {
71 new CheckColumnType().execute(table1);
72 } catch (Throwable e) {
73 e.printStackTrace();
74 fail();
75 }
76
77 }
78 }