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