KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > model > MutliTypeTableTest


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.designer.model;
5
6 import junit.framework.TestCase;
7
8 import org.oddjob.designer.elements.ListDE;
9 import org.oddjob.designer.elements.ValueDE;
10 import org.oddjob.designer.elements.simple.SimpleTextAttribute;
11
12 /**
13  *
14  */

15 public class MutliTypeTableTest extends TestCase {
16     
17     
18     public void test1() {
19         ListDE parent = new ListDE();
20         ValueDE de1 = new ValueDE();
21         de1.type("value");
22         SimpleTextAttribute a1 = new SimpleTextAttribute();
23         a1.attribute("text1");
24         de1.setName(a1);
25         parent.addChild(de1);
26         
27         MultiTypeTable test = new MultiTypeTable("Test", parent);
28
29         assertEquals(1, test.childCount());
30         assertEquals("value", test.getChildType(0));
31         assertEquals("text1", test.getChildName(0));
32         
33         TextInput ti = (TextInput) test.getChildValue(0).detail();
34         ti.setText("OK");
35
36         assertEquals("OK", ((ValueDE) test.getChildValue(0)).getValue());
37         
38         test.insertChild(1, "file");
39         assertEquals(2, test.childCount());
40         assertEquals("file", test.getChildType(1));
41         assertEquals(null, test.getChildName(1));
42
43         test.removeChild(0);
44         test.insertChild(0, "buffer");
45         assertEquals(2, test.childCount());
46         assertEquals("buffer", test.getChildType(0));
47         assertEquals(null, test.getChildName(0));
48
49         test.removeChild(0);
50         
51         assertEquals(1, test.childCount());
52     }
53     
54 }
55
Popular Tags