Revision 22967
branches/v2_0_0_prep/libraries/libFMap_dataFile/src-test/org/gvsig/fmap/data/feature/file/ResourceManagerTest.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.data.feature.file; |
29 | 29 |
|
30 |
import java.security.KeyException; |
|
30 | 31 |
import java.util.Comparator; |
31 | 32 |
import java.util.Iterator; |
32 | 33 |
import java.util.SortedSet; |
... | ... | |
37 | 38 |
import org.gvsig.exceptions.BaseException; |
38 | 39 |
import org.gvsig.fmap.data.CloseException; |
39 | 40 |
import org.gvsig.fmap.data.DataCollection; |
41 |
import org.gvsig.fmap.data.DataException; |
|
40 | 42 |
import org.gvsig.fmap.data.DataManager; |
41 | 43 |
import org.gvsig.fmap.data.DataStore; |
42 | 44 |
import org.gvsig.fmap.data.Resource; |
... | ... | |
71 | 73 |
|
72 | 74 |
} |
73 | 75 |
|
74 |
public void closeAll() throws CloseException {
|
|
76 |
public void closeAndDisposeAll() throws KeyException, DataException {
|
|
75 | 77 |
ResourceManager rManager = ResourceManager.getResourceManager(); |
76 | 78 |
|
77 | 79 |
Iterator iter = rManager.iterator(); |
80 |
String name, key; |
|
78 | 81 |
while (iter.hasNext()) { |
79 | 82 |
Resource res = (Resource) iter.next(); |
83 |
name = res.getName(); |
|
84 |
key = res.getKey(); |
|
80 | 85 |
if (res.isOpen()) { |
81 | 86 |
res.close(); |
82 |
System.out.println("** closed: " + res.getName() + "(" |
|
83 |
+ res.getKey() + ")"); |
|
87 |
System.out.println("** closed: " + name + "(" + key + ")"); |
|
84 | 88 |
} |
85 | 89 |
|
90 |
rManager.remove(res); |
|
91 |
System.out.println("** removed: " + name + "(" + key + ")"); |
|
92 |
|
|
93 |
iter = rManager.iterator(); |
|
86 | 94 |
} |
87 | 95 |
|
88 |
System.out.println("** Closed all resources"); |
|
96 |
System.out.println("** Closed and Disposed all resources");
|
|
89 | 97 |
} |
90 | 98 |
|
91 | 99 |
|
... | ... | |
176 | 184 |
public void sys_out_resources() { |
177 | 185 |
ResourceManager resManager = ResourceManager.getResourceManager(); |
178 | 186 |
Iterator iter = resManager.iterator(); |
179 |
int opened = 0; |
|
180 |
|
|
181 | 187 |
while (iter.hasNext()) { |
182 | 188 |
Resource res = (Resource) iter.next(); |
183 | 189 |
System.out.print("- Resource: " + res.getName() + "(" |
... | ... | |
200 | 206 |
|
201 | 207 |
//Nos aseguramos que no hay recursos abiertos |
202 | 208 |
try { |
203 |
closer.closeAll(); |
|
204 |
} catch (CloseException e1) {
|
|
209 |
closer.closeAndDisposeAll();
|
|
210 |
} catch (Exception e1) { |
|
205 | 211 |
e1.printStackTrace(); |
206 | 212 |
fail(); |
207 | 213 |
} |
... | ... | |
214 | 220 |
DataStore shp = null; |
215 | 221 |
DataStore shp_bis = null; |
216 | 222 |
DataStore shpNull = null; |
217 |
DataStore dbf = null; |
|
223 |
// DataStore dbf = null;
|
|
218 | 224 |
|
219 | 225 |
|
220 | 226 |
// Abrimos y cerrarmos uno (ojo los shp son dos recursos el dbf y el shp) |
... | ... | |
338 | 344 |
|
339 | 345 |
//Nos aseguramos que no hay recursos abiertos |
340 | 346 |
try { |
341 |
closer.closeAll(); |
|
342 |
} catch (CloseException e1) {
|
|
347 |
closer.closeAndDisposeAll();
|
|
348 |
} catch (Exception e1) { |
|
343 | 349 |
e1.printStackTrace(); |
344 | 350 |
fail(); |
345 | 351 |
} |
... | ... | |
351 | 357 |
DataStore shp = null; |
352 | 358 |
DataStore shp_bis = null; |
353 | 359 |
DataStore shpNull = null; |
354 |
DataStore dbf = null; |
|
360 |
//DataStore dbf = null;
|
|
355 | 361 |
|
356 | 362 |
// A?adimos el 'closer' como observador para que no deje abierta |
357 | 363 |
// nunca mas de 2 fuentes |
Also available in: Unified diff