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