KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > core > comp > TestCompCreate


1 /*
2  * Copyright (C) 2003 Christian Cryder [christianc@granitepeaks.com]
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * $Id: TestCompCreate.java,v 1.11 2004/02/01 05:16:32 christianc Exp $
19  */

20 package org.enhydra.barracuda.core.comp;
21
22 import java.io.*;
23 import java.util.*;
24
25 import org.w3c.dom.*;
26 import junit.framework.*;
27
28 //import org.enhydra.barracuda.plankton.*;
29
//import org.enhydra.barracuda.plankton.data.*;
30
import org.enhydra.barracuda.core.util.dom.*;
31 import org.apache.log4j.*;
32 import org.enhydra.barracuda.core.view.*;
33 import org.enhydra.barracuda.examples.xmlc.*;
34 import org.enhydra.barracuda.testbed.*;
35
36
37 /**
38  * This test verifies that components get created correctly
39  */

40 public class TestCompCreate extends DefaultTestCase {
41     //common vars (customize for every test class)
42
private static String JavaDoc testClass = TestCompCreate.class.getName();
43     private static Logger logger = Logger.getLogger("test."+testClass);
44
45     //variables
46

47     //-------------------- Basics --------------------------------
48
/**
49      * Public Constructor
50      */

51     public TestCompCreate(String JavaDoc name) {
52         super(name);
53     }
54
55     /**
56      * Every test class should have a main method so it can be run
57      * directly (when debugging tests you often will not want to run
58      * the whole suite)
59      *
60      * @param args defined in test.util.TestUtil
61      */

62     public static void main(String JavaDoc args[]) {
63         //check for standard runtime parameters
64
TestUtil.parseParams(args);
65
66         //launch the test
67
if (TestUtil.BATCH_MODE) junit.textui.TestRunner.main(new String JavaDoc[] {testClass});
68         else junit.swingui.TestRunner.main(new String JavaDoc[] {testClass});
69     }
70
71     
72     //-------------------- Actual Tests --------------------------
73
//Note: all the methods herein should follow the testXXXX naming convention
74
//Also keep in mind that local vars set in one test method are NOT retained
75
//when the next method is invoked because JUnit makes a separate instance of
76
//the test class for each testXXXX method!!!
77

78     /**
79      * Simple test to make sure BComponents are instantiated correctly
80      */

81     public void testBComponentCreate() {
82         //make sure we can instantiate (ie. that its never declared abstract)
83
BComponent comp = new BComponent();
84     
85         //ensure that the basic characteristics are as we expect
86
performGeneralChecks(comp);
87     }
88     
89     /**
90      * Simple test to make sure BText are instantiated correctly
91      */

92     public void testBTextCreate() {
93         //make sure we can instantiate (ie. that its never declared abstract)
94
BText comp = new BText();
95     
96         //ensure that the basic characteristics are as we expect
97
performGeneralChecks(comp);
98     }
99     
100     /**
101      * Simple test to make sure BAction are instantiated correctly
102      */

103     public void testBActionCreate() {
104         //make sure we can instantiate (ie. that its never declared abstract)
105
BAction comp = new BAction();
106     
107         //ensure that the basic characteristics are as we expect
108
performGeneralChecks(comp);
109     }
110     
111     /**
112      * Simple test to make sure BLink are instantiated correctly
113      */

114     public void testBLinkCreate() {
115         //make sure we can instantiate (ie. that its never declared abstract)
116
BLink comp = new BLink();
117     
118         //ensure that the basic characteristics are as we expect
119
performGeneralChecks(comp);
120     }
121     
122     /**
123      * Simple test to make sure BInput are instantiated correctly
124      */

125     public void testBInputCreate() {
126         //make sure we can instantiate (ie. that its never declared abstract)
127
BInput comp = new BInput();
128     
129         //ensure that the basic characteristics are as we expect
130
performGeneralChecks(comp);
131     }
132     
133     /**
134      * Simple test to make sure BToggleButton are instantiated correctly
135      */

136     public void testBToggleButtonCreate() {
137         //make sure we can instantiate (ie. that its never declared abstract)
138
BToggleButton comp = new BToggleButton();
139     
140         //ensure that the basic characteristics are as we expect
141
performGeneralChecks(comp);
142     }
143     
144     /**
145      * Simple test to make sure BTemplate are instantiated correctly
146      */

147     public void testBTemplateCreate() {
148         //make sure we can instantiate (ie. that its never declared abstract)
149
BTemplate comp = new BTemplate();
150     
151         //ensure that the basic characteristics are as we expect
152
performGeneralChecks(comp);
153     }
154     
155     /**
156      * Simple test to make sure BTable are instantiated correctly
157      */

158     public void testBTableCreate() {
159         //make sure we can instantiate (ie. that its never declared abstract)
160
BTable comp = new BTable();
161     
162         //ensure that the basic characteristics are as we expect
163
performGeneralChecks(comp);
164     }
165     
166     /**
167      * Simple test to make sure BList are instantiated correctly
168      */

169     public void testBListCreate() {
170         //make sure we can instantiate (ie. that its never declared abstract)
171
BList comp = new BList();
172     
173         //ensure that the basic characteristics are as we expect
174
performGeneralChecks(comp);
175     }
176     
177     /**
178      * Simple test to make sure BSelect are instantiated correctly
179      */

180     public void testBSelectCreate() {
181         //make sure we can instantiate (ie. that its never declared abstract)
182
BSelect comp = new BSelect();
183     
184         //ensure that the basic characteristics are as we expect
185
performGeneralChecks(comp);
186     }
187     
188     protected void performGeneralChecks(BComponent comp) {
189         //make sure that a newly created component never has a name set. This is
190
//important, because if we ever start defaulting the name then it will
191
//automatically set the name attribute in views (see the HTMLComponentRenderer
192
//for details). The name attribute should only get set when the name is
193
//specifically set.
194
assertNull("Default component name not null", comp.getName());
195     }
196 }
197
Popular Tags