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