1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7 package com.tirsen.angkor.test.unit;
8
9 import junit.framework.TestCase;
10 import com.tirsen.angkor.Application;
11 import com.tirsen.angkor.ViewLink;
12 import com.tirsen.angkor.ViewFactory;
13 import com.tirsen.angkor.View;
14 import com.tirsen.angkor.widget.TextLabel;
15
16 /***
17 * TODO document ApplicationTest
18 *
19 * <!-- $Id: ApplicationTest.java,v 1.1 2002/10/13 13:37:26 tirsen Exp $ -->
20 *
21 * @author $Author: tirsen $
22 * @version $Revision: 1.1 $
23 */
24 public class ApplicationTest extends TestCase
25 {
26 Application application = new Application();
27 public ViewFactory viewFactory = new ViewFactory()
28 {
29 public View getView()
30 {
31 return null;
32 }
33 };
34
35 public void testMethods()
36 {
37 // test valueUnbound method
38 application.valueUnbound(null);
39
40 // test getWindowTitle method
41 assertNull(application.getWindowTitle());
42 }
43
44 public void testRegisterComponent()
45 {
46 try
47 {
48 application.getComponent("no-component-here");
49 fail();
50 }
51 catch (IllegalArgumentException shouldHappen)
52 {
53 }
54
55 application.registerComponent("test", viewFactory);
56 assertSame(viewFactory, application.getComponent("test"));
57 try
58 {
59 application.registerComponent("test", viewFactory);
60 fail();
61 }
62 catch (IllegalStateException shouldHappen)
63 {
64 }
65 }
66
67 public void testAllocateUniqueID()
68 {
69 TextLabel view = new TextLabel();
70 view.setId("test");
71 // allocate same to same id twice should work
72 application.allocateUniqueID("test", view);
73 application.allocateUniqueID("test", view);
74
75 try
76 {
77 application.allocateUniqueID("test", new TextLabel());
78 fail("allocate other to same id should not work");
79 }
80 catch (IllegalArgumentException shouldHappen)
81 {
82 }
83 }
84
85 public void testViewLink()
86 {
87 application.registerLink("link", viewFactory);
88 assertSame(viewFactory, application.getComponent("link"));
89
90 ViewFactory viewFactory2 = new ViewFactory()
91 {
92 public View getView()
93 {
94 return null;
95 }
96 };
97 application.relink("link", viewFactory2);
98 assertSame(viewFactory2, application.getComponent("link"));
99 }
100 }
This page was automatically generated by Maven