root / trunk / applications / appgvSIG / src-test / com / iver / cit / gvsig / panelGroup / Test2ExceptionsUsingTabbedPanel.java @ 20098
History | View | Annotate | Download (9.04 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 com.iver.cit.gvsig.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.PanelGroupManager; |
27 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
28 |
|
29 |
import com.iver.cit.gvsig.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint; |
30 |
import com.iver.cit.gvsig.panelGroup.samples.Samples_ExtensionPointsOfIPanels; |
31 |
|
32 |
/**
|
33 |
* <p>Tests the loading of layers using a {@link TabbedPanel TabbedPanel} object and a {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint} loader
|
34 |
* Tests also the managing of the different kind of exceptions which could be launched during this process.</p>
|
35 |
*
|
36 |
* @version 11/12/2007
|
37 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
38 |
*/
|
39 |
public class Test2ExceptionsUsingTabbedPanel extends TestCase { |
40 |
private TabbedPanel panelGroup;
|
41 |
private PanelGroupManager manager;
|
42 |
private PanelGroupLoaderFromExtensionPoint loader;
|
43 |
private String validationText; |
44 |
private String localizedMessage; |
45 |
|
46 |
/*
|
47 |
* (non-Javadoc)
|
48 |
* @see junit.framework.TestCase#setUp()
|
49 |
*/
|
50 |
protected void setUp() throws Exception { |
51 |
super.setUp();
|
52 |
|
53 |
manager = PanelGroupManager.getManager(); |
54 |
manager.registerPanelGroup(TabbedPanel.class); |
55 |
manager.setDefaultType(TabbedPanel.class); |
56 |
panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3); |
57 |
} |
58 |
|
59 |
/*
|
60 |
* (non-Javadoc)
|
61 |
* @see junit.framework.TestCase#tearDown()
|
62 |
*/
|
63 |
protected void tearDown() throws Exception { |
64 |
super.tearDown();
|
65 |
manager.deregisterPanelGroup(TabbedPanel.class); |
66 |
} |
67 |
|
68 |
/**
|
69 |
* <p>Test the 'PanelGroup' exceptions </p>
|
70 |
*/
|
71 |
public void test1() { |
72 |
Samples_ExtensionPointsOfIPanels.loadSample(); |
73 |
|
74 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n Error cargando un panel: / by zero."; |
75 |
|
76 |
try {
|
77 |
System.out.println("----- Test 1 -----"); |
78 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT4_NAME);
|
79 |
|
80 |
// Begin: Test the normal load
|
81 |
panelGroup.loadPanels(loader); |
82 |
// End: Test the normal load
|
83 |
} catch (BaseException bE) {
|
84 |
localizedMessage = bE.getLocalizedMessageStack(); |
85 |
System.out.println(localizedMessage);
|
86 |
System.out.println("------------------"); |
87 |
assertEquals(localizedMessage, validationText); |
88 |
return;
|
89 |
} catch (Exception e) { |
90 |
e.printStackTrace(); |
91 |
System.out.println("------------------"); |
92 |
fail(); |
93 |
return;
|
94 |
} |
95 |
|
96 |
System.out.println("------------------"); |
97 |
fail(); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* <p>Test the 'PanelGroup' exceptions </p>
|
102 |
*/
|
103 |
public void test2() { |
104 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n Panel de etiqueta Information_LABEL sin tama?o inicial definido."; |
105 |
|
106 |
try {
|
107 |
System.out.println("----- Test 2 -----"); |
108 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT5_NAME);
|
109 |
|
110 |
// Begin: Test the normal load
|
111 |
panelGroup.loadPanels(loader); |
112 |
// End: Test the normal load
|
113 |
} catch (BaseException bE) {
|
114 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
115 |
System.out.println(localizedMessage);
|
116 |
System.out.println("------------------"); |
117 |
assertEquals(localizedMessage, validationText); |
118 |
return;
|
119 |
} catch (Exception e) { |
120 |
e.printStackTrace(); |
121 |
System.out.println("------------------"); |
122 |
fail(); |
123 |
return;
|
124 |
} |
125 |
|
126 |
System.out.println("------------------"); |
127 |
fail(); |
128 |
} |
129 |
|
130 |
/**
|
131 |
* <p>Test the 'PanelGroup' exceptions </p>
|
132 |
*/
|
133 |
public void test3() { |
134 |
validationText = Messages.getText("empty_panel_group_exception");
|
135 |
|
136 |
try {
|
137 |
System.out.println("----- Test 3 -----"); |
138 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT6_NAME);
|
139 |
|
140 |
// Begin: Test the normal load
|
141 |
panelGroup.loadPanels(loader); |
142 |
// End: Test the normal load
|
143 |
} catch (BaseException bE) {
|
144 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
145 |
System.out.println(localizedMessage);
|
146 |
System.out.println("------------------"); |
147 |
assertEquals(localizedMessage, validationText); |
148 |
return;
|
149 |
} catch (Exception e) { |
150 |
e.printStackTrace(); |
151 |
System.out.println("------------------"); |
152 |
fail(); |
153 |
return;
|
154 |
} |
155 |
|
156 |
System.out.println("------------------"); |
157 |
fail(); |
158 |
} |
159 |
|
160 |
/**
|
161 |
* <p>Test the 'PanelGroup' exceptions </p>
|
162 |
*/
|
163 |
public void test4() { |
164 |
validationText = Messages.getText("empty_panel_group_gui_exception");
|
165 |
|
166 |
try {
|
167 |
System.out.println("----- Test 4 -----"); |
168 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT7_NAME);
|
169 |
|
170 |
// Begin: Test the normal load
|
171 |
panelGroup.loadPanels(loader); |
172 |
// End: Test the normal load
|
173 |
} catch (BaseException bE) {
|
174 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
175 |
System.out.println(localizedMessage);
|
176 |
System.out.println("------------------"); |
177 |
assertEquals(localizedMessage, validationText); |
178 |
return;
|
179 |
} catch (Exception e) { |
180 |
e.printStackTrace(); |
181 |
System.out.println("------------------"); |
182 |
fail(); |
183 |
return;
|
184 |
} |
185 |
|
186 |
System.out.println("------------------"); |
187 |
fail(); |
188 |
} |
189 |
|
190 |
/**
|
191 |
* <p>Test the 'PanelGroup' exceptions </p>
|
192 |
*/
|
193 |
public void test5() { |
194 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_extension_point_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"); |
195 |
|
196 |
try {
|
197 |
System.out.println("----- Test 5 -----"); |
198 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT8_NAME);
|
199 |
|
200 |
// Begin: Test the normal load
|
201 |
panelGroup.loadPanels(loader); |
202 |
// End: Test the normal load
|
203 |
} catch (BaseException bE) {
|
204 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
205 |
System.out.println(localizedMessage);
|
206 |
System.out.println("------------------"); |
207 |
assertEquals(localizedMessage, validationText); |
208 |
return;
|
209 |
} catch (Exception e) { |
210 |
e.printStackTrace(); |
211 |
System.out.println("------------------"); |
212 |
fail(); |
213 |
return;
|
214 |
} |
215 |
|
216 |
System.out.println("------------------"); |
217 |
fail(); |
218 |
} |
219 |
|
220 |
/**
|
221 |
* <p>Test the 'PanelGroup' exceptions </p>
|
222 |
*/
|
223 |
public void test6() { |
224 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_extension_point_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"); |
225 |
|
226 |
try {
|
227 |
System.out.println("----- Test 6 -----"); |
228 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT9_NAME);
|
229 |
|
230 |
// Begin: Test the normal load
|
231 |
panelGroup.loadPanels(loader); |
232 |
// End: Test the normal load
|
233 |
} catch (BaseException bE) {
|
234 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
235 |
System.out.println(localizedMessage);
|
236 |
System.out.println("------------------"); |
237 |
assertEquals(localizedMessage, validationText); |
238 |
return;
|
239 |
} catch (Exception e) { |
240 |
e.printStackTrace(); |
241 |
System.out.println("------------------"); |
242 |
fail(); |
243 |
return;
|
244 |
} |
245 |
|
246 |
System.out.println("------------------"); |
247 |
fail(); |
248 |
} |
249 |
|
250 |
/**
|
251 |
* <p>Test the 'PanelGroup' exceptions </p>
|
252 |
*/
|
253 |
public void test7() { |
254 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n Error cargando un panel: / by zero.\n Panel de etiqueta Information_LABEL sin tama?o inicial definido."; |
255 |
|
256 |
try {
|
257 |
System.out.println("----- Test 7 -----"); |
258 |
loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT10_NAME);
|
259 |
|
260 |
// Begin: Test the normal load
|
261 |
panelGroup.loadPanels(loader); |
262 |
// End: Test the normal load
|
263 |
} catch (BaseException bE) {
|
264 |
localizedMessage = bE.getLocalizedMessageStack().trim(); |
265 |
System.out.println(localizedMessage);
|
266 |
System.out.println("------------------"); |
267 |
assertEquals(localizedMessage, validationText); |
268 |
return;
|
269 |
} catch (Exception e) { |
270 |
e.printStackTrace(); |
271 |
System.out.println("------------------"); |
272 |
fail(); |
273 |
return;
|
274 |
} |
275 |
|
276 |
System.out.println("------------------"); |
277 |
fail(); |
278 |
} |
279 |
} |