svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / panelGroup / Test1ExceptionsUsingTreePanel.java @ 40561
History | View | Annotate | Download (8.6 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.gui.beans.panelGroup; |
25 |
|
26 |
import junit.framework.TestCase; |
27 |
|
28 |
import org.gvsig.tools.exception.BaseException; |
29 |
import org.gvsig.gui.beans.Messages; |
30 |
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList; |
31 |
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data; |
32 |
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel; |
33 |
|
34 |
/**
|
35 |
* <p>Tests the loading of layers using a {@link TreePanel TreePanel} object and a {@link PanelGroupLoaderFromList PanelGroupLoaderFromList} loader
|
36 |
* Tests also the managing of the different kind of exceptions which could be launched during this process.</p>
|
37 |
*
|
38 |
* @version 29/11/2007
|
39 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
40 |
*/
|
41 |
public class Test1ExceptionsUsingTreePanel extends TestCase { |
42 |
private TreePanel panelGroup;
|
43 |
private PanelGroupManager manager;
|
44 |
private PanelGroupLoaderFromList loader;
|
45 |
private String validationText; |
46 |
private String localizedMessage; |
47 |
|
48 |
/*
|
49 |
* (non-Javadoc)
|
50 |
* @see junit.framework.TestCase#setUp()
|
51 |
*/
|
52 |
protected void setUp() throws Exception { |
53 |
super.setUp();
|
54 |
|
55 |
manager = PanelGroupManager.getManager(); |
56 |
manager.registerPanelGroup(TreePanel.class); |
57 |
manager.setDefaultType(TreePanel.class); |
58 |
panelGroup = (TreePanel) manager.getPanelGroup(Samples_Data.REFERENCE3); |
59 |
} |
60 |
|
61 |
/*
|
62 |
* (non-Javadoc)
|
63 |
* @see junit.framework.TestCase#tearDown()
|
64 |
*/
|
65 |
protected void tearDown() throws Exception { |
66 |
super.tearDown();
|
67 |
manager.deregisterPanelGroup(TreePanel.class); |
68 |
} |
69 |
|
70 |
/**
|
71 |
* <p>Test the 'PanelGroup' exceptions </p>
|
72 |
*/
|
73 |
public void test1() { |
74 |
validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n Error cargando un panel: / by zero."; |
75 |
|
76 |
try {
|
77 |
System.out.println("----- Test 1 -----"); |
78 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST4_CLASSES);
|
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 PanelGroupLoaderFromList(Samples_Data.TEST5_CLASSES);
|
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(); |
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 PanelGroupLoaderFromList(Samples_Data.TEST6_CLASSES);
|
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(); |
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 PanelGroupLoaderFromList(Samples_Data.TEST7_CLASSES);
|
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(); |
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_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"); |
195 |
|
196 |
try {
|
197 |
System.out.println("----- Test 5 -----"); |
198 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST8_CLASSES);
|
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(); |
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_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"); |
225 |
|
226 |
try {
|
227 |
System.out.println("----- Test 6 -----"); |
228 |
loader = new PanelGroupLoaderFromList(Samples_Data.TEST9_CLASSES);
|
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(); |
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_list_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 PanelGroupLoaderFromList(Samples_Data.TEST10_CLASSES);
|
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(); |
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 |
} |