svn-gvsig-desktop / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / panelGroup / Test1ExceptionsUsingTabbedPanel.java @ 19356
History | View | Annotate | Download (8.52 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
|
20 |
package org.gvsig.gui.beans.panelGroup; |
21 |
|
22 |
import junit.framework.TestCase; |
23 |
|
24 |
import org.gvsig.exceptions.BaseException; |
25 |
import org.gvsig.gui.beans.Messages; |
26 |
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList; |
27 |
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data; |
28 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
29 |
|
30 |
/**
|
31 |
* <p>Tests the loading of layers using a {@link TabbedPanel TabbedPanel} object and a {@link PanelGroupLoaderFromList PanelGroupLoaderFromList} loader
|
32 |
* Tests also the managing of the different kind of exceptions which could be launched during this process.</p>
|
33 |
*
|
34 |
* @version 29/11/2007
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
36 |
*/
|
37 |
public class Test1ExceptionsUsingTabbedPanel extends TestCase { |
38 |
private TabbedPanel panelGroup;
|
39 |
private PanelGroupManager manager;
|
40 |
private PanelGroupLoaderFromList loader;
|
41 |
private String validationText; |
42 |
private String localizedMessage; |
43 |
|
44 |
/*
|
45 |
* (non-Javadoc)
|
46 |
* @see junit.framework.TestCase#setUp()
|
47 |
*/
|
48 |
protected void setUp() throws Exception { |
49 |
super.setUp();
|
50 |
|
51 |
manager = PanelGroupManager.getManager(); |
52 |
manager.registerPanelGroup(TabbedPanel.class); |
53 |
manager.setDefaultType(TabbedPanel.class); |
54 |
panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_Data.REFERENCE3); |
55 |
} |
56 |
|
57 |
/*
|
58 |
* (non-Javadoc)
|
59 |
* @see junit.framework.TestCase#tearDown()
|
60 |
*/
|
61 |
protected void tearDown() throws Exception { |
62 |
super.tearDown();
|
63 |
manager.deregisterPanelGroup(TabbedPanel.class); |
64 |
} |
65 |
|
66 |
/**
|
67 |
* <p>Test the 'PanelGroup' exceptions </p>
|
68 |
*/
|
69 |
public void test1() { |
70 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n Error cargando un panel: / by zero."; |
71 |
|
72 |
try {
|
73 |
System.out.println("----- Test 1 -----"); |
74 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST4_CLASSES);
|
75 |
|
76 |
// Begin: Test the normal load
|
77 |
panelGroup.loadPanels(loader); |
78 |
// End: Test the normal load
|
79 |
} catch (BaseException bE) {
|
80 |
localizedMessage = bE.getLocalizedMessageStack(); |
81 |
System.out.println(localizedMessage);
|
82 |
System.out.println("------------------"); |
83 |
assertEquals(localizedMessage, validationText); |
84 |
return;
|
85 |
} catch (Exception e) { |
86 |
e.printStackTrace(); |
87 |
System.out.println("------------------"); |
88 |
fail(); |
89 |
return;
|
90 |
} |
91 |
|
92 |
System.out.println("------------------"); |
93 |
fail(); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* <p>Test the 'PanelGroup' exceptions </p>
|
98 |
*/
|
99 |
public void test2() { |
100 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n Panel de etiqueta Information_LABEL sin tama?o inicial definido."; |
101 |
|
102 |
try {
|
103 |
System.out.println("----- Test 2 -----"); |
104 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST5_CLASSES);
|
105 |
|
106 |
// Begin: Test the normal load
|
107 |
panelGroup.loadPanels(loader); |
108 |
// End: Test the normal load
|
109 |
} catch (BaseException bE) {
|
110 |
localizedMessage = bE.getLocalizedMessageStack(); |
111 |
System.out.println(localizedMessage);
|
112 |
System.out.println("------------------"); |
113 |
assertEquals(localizedMessage, validationText); |
114 |
return;
|
115 |
} catch (Exception e) { |
116 |
e.printStackTrace(); |
117 |
System.out.println("------------------"); |
118 |
fail(); |
119 |
return;
|
120 |
} |
121 |
|
122 |
System.out.println("------------------"); |
123 |
fail(); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* <p>Test the 'PanelGroup' exceptions </p>
|
128 |
*/
|
129 |
public void test3() { |
130 |
validationText = Messages.getText("empty_panel_group_exception");
|
131 |
|
132 |
try {
|
133 |
System.out.println("----- Test 3 -----"); |
134 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST6_CLASSES);
|
135 |
|
136 |
// Begin: Test the normal load
|
137 |
panelGroup.loadPanels(loader); |
138 |
// End: Test the normal load
|
139 |
} catch (BaseException bE) {
|
140 |
localizedMessage = bE.getLocalizedMessageStack(); |
141 |
System.out.println(localizedMessage);
|
142 |
System.out.println("------------------"); |
143 |
assertEquals(localizedMessage, validationText); |
144 |
return;
|
145 |
} catch (Exception e) { |
146 |
e.printStackTrace(); |
147 |
System.out.println("------------------"); |
148 |
fail(); |
149 |
return;
|
150 |
} |
151 |
|
152 |
System.out.println("------------------"); |
153 |
fail(); |
154 |
} |
155 |
|
156 |
/**
|
157 |
* <p>Test the 'PanelGroup' exceptions </p>
|
158 |
*/
|
159 |
public void test4() { |
160 |
validationText = Messages.getText("empty_panel_group_gui_exception");
|
161 |
|
162 |
try {
|
163 |
System.out.println("----- Test 4 -----"); |
164 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST7_CLASSES);
|
165 |
|
166 |
// Begin: Test the normal load
|
167 |
panelGroup.loadPanels(loader); |
168 |
// End: Test the normal load
|
169 |
} catch (BaseException bE) {
|
170 |
localizedMessage = bE.getLocalizedMessageStack(); |
171 |
System.out.println(localizedMessage);
|
172 |
System.out.println("------------------"); |
173 |
assertEquals(localizedMessage, validationText); |
174 |
return;
|
175 |
} catch (Exception e) { |
176 |
e.printStackTrace(); |
177 |
System.out.println("------------------"); |
178 |
fail(); |
179 |
return;
|
180 |
} |
181 |
|
182 |
System.out.println("------------------"); |
183 |
fail(); |
184 |
} |
185 |
|
186 |
/**
|
187 |
* <p>Test the 'PanelGroup' exceptions </p>
|
188 |
*/
|
189 |
public void test5() { |
190 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n Error cargando un panel: / by zero.\n Panel de etiqueta Information_LABEL sin tama?o inicial definido.\n " + Messages.getText("empty_panel_group_exception"); |
191 |
|
192 |
try {
|
193 |
System.out.println("----- Test 5 -----"); |
194 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST8_CLASSES);
|
195 |
|
196 |
// Begin: Test the normal load
|
197 |
panelGroup.loadPanels(loader); |
198 |
// End: Test the normal load
|
199 |
} catch (BaseException bE) {
|
200 |
localizedMessage = bE.getLocalizedMessageStack(); |
201 |
System.out.println(localizedMessage);
|
202 |
System.out.println("------------------"); |
203 |
assertEquals(localizedMessage, validationText); |
204 |
return;
|
205 |
} catch (Exception e) { |
206 |
e.printStackTrace(); |
207 |
System.out.println("------------------"); |
208 |
fail(); |
209 |
return;
|
210 |
} |
211 |
|
212 |
System.out.println("------------------"); |
213 |
fail(); |
214 |
} |
215 |
|
216 |
/**
|
217 |
* <p>Test the 'PanelGroup' exceptions </p>
|
218 |
*/
|
219 |
public void test6() { |
220 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n Error cargando un panel: / by zero.\n Panel de etiqueta Information_LABEL sin tama?o inicial definido.\n " + Messages.getText("empty_panel_group_gui_exception"); |
221 |
|
222 |
try {
|
223 |
System.out.println("----- Test 6 -----"); |
224 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST9_CLASSES);
|
225 |
|
226 |
// Begin: Test the normal load
|
227 |
panelGroup.loadPanels(loader); |
228 |
// End: Test the normal load
|
229 |
} catch (BaseException bE) {
|
230 |
localizedMessage = bE.getLocalizedMessageStack(); |
231 |
System.out.println(localizedMessage);
|
232 |
System.out.println("------------------"); |
233 |
assertEquals(localizedMessage, validationText); |
234 |
return;
|
235 |
} catch (Exception e) { |
236 |
e.printStackTrace(); |
237 |
System.out.println("------------------"); |
238 |
fail(); |
239 |
return;
|
240 |
} |
241 |
|
242 |
System.out.println("------------------"); |
243 |
fail(); |
244 |
} |
245 |
|
246 |
/**
|
247 |
* <p>Test the 'PanelGroup' exceptions </p>
|
248 |
*/
|
249 |
public void test7() { |
250 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n Error cargando un panel: / by zero.\n Panel de etiqueta Information_LABEL sin tama?o inicial definido."; |
251 |
|
252 |
try {
|
253 |
System.out.println("----- Test 7 -----"); |
254 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST10_CLASSES);
|
255 |
|
256 |
// Begin: Test the normal load
|
257 |
panelGroup.loadPanels(loader); |
258 |
// End: Test the normal load
|
259 |
} catch (BaseException bE) {
|
260 |
localizedMessage = bE.getLocalizedMessageStack(); |
261 |
System.out.println(localizedMessage);
|
262 |
System.out.println("------------------"); |
263 |
assertEquals(localizedMessage, validationText); |
264 |
return;
|
265 |
} catch (Exception e) { |
266 |
e.printStackTrace(); |
267 |
System.out.println("------------------"); |
268 |
fail(); |
269 |
return;
|
270 |
} |
271 |
|
272 |
System.out.println("------------------"); |
273 |
fail(); |
274 |
} |
275 |
} |