root / branches / v2_0_0_prep / libraries / libFMap_daldb / src-test / org / gvsig / fmap / data / feature / db / jdbc / h2 / H2Test.java @ 24491
History | View | Annotate | Download (30.1 KB)
1 |
package org.gvsig.fmap.data.feature.db.jdbc.h2; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.sql.Connection; |
5 |
import java.sql.DriverManager; |
6 |
import java.sql.SQLException; |
7 |
import java.sql.Statement; |
8 |
import java.util.Iterator; |
9 |
|
10 |
import org.gvsig.fmap.dal.DataManager; |
11 |
import org.gvsig.fmap.dal.DataStoreParameters; |
12 |
import org.gvsig.fmap.dal.exceptions.CloseException; |
13 |
import org.gvsig.fmap.dal.exceptions.DataException; |
14 |
import org.gvsig.fmap.dal.exceptions.InitializeException; |
15 |
import org.gvsig.fmap.dal.exceptions.ReadException; |
16 |
import org.gvsig.fmap.dal.exceptions.WriteException; |
17 |
import org.gvsig.fmap.dal.feature.AbstractFeature; |
18 |
import org.gvsig.fmap.dal.feature.Feature; |
19 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
20 |
import org.gvsig.fmap.dal.feature.FeatureExplorer; |
21 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
22 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
23 |
import org.gvsig.fmap.dal.feature.FeatureType; |
24 |
import org.gvsig.fmap.dal.feature.file.shp.SHPStore; |
25 |
import org.gvsig.fmap.dal.feature.file.shp.SHPStoreParameters; |
26 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
27 |
import org.gvsig.fmap.data.feature.db.DBAttributeDescriptor; |
28 |
import org.gvsig.fmap.data.feature.db.DBFeatureType; |
29 |
import org.gvsig.fmap.data.feature.db.jdbc.JDBCTest; |
30 |
import org.gvsig.tools.exception.BaseException; |
31 |
import org.h2.tools.Server; |
32 |
|
33 |
|
34 |
public class H2Test extends JDBCTest { |
35 |
|
36 |
private Server h2Server = null; |
37 |
private Server h2WebServer = null; |
38 |
private String h2Server_argsTCP[]= {"-baseDir", "."}; |
39 |
private String h2Server_argsWeb[]= {"-webport", "8089"}; |
40 |
// private boolean runH2WebServer = false;
|
41 |
private boolean runH2WebServer = false; |
42 |
private boolean startsH2Server=true; |
43 |
|
44 |
|
45 |
private File shpfile = new File(H2Test.class.getResource("data/prueba.shp").getFile()); |
46 |
|
47 |
public static void main(String[] args) { |
48 |
H2Test test=new H2Test();
|
49 |
test.runH2WebServer=true;
|
50 |
test.startH2Server(); |
51 |
test.cretateTablePrueba(); |
52 |
test.testH2_explorer_list(); |
53 |
// junit.textui.TestRunner.run(H2Test.class);
|
54 |
} |
55 |
|
56 |
protected void setUp() throws Exception { |
57 |
super.setUp();
|
58 |
if (startsH2Server) {
|
59 |
this.startH2Server();
|
60 |
} |
61 |
} |
62 |
|
63 |
public void startH2Server(){ |
64 |
if (h2Server != null) { |
65 |
throw new RuntimeException("H2 server ya arrancado"); |
66 |
} |
67 |
Server myh2Server = null;
|
68 |
Server myh2WebServer = null;
|
69 |
try{
|
70 |
myh2Server = Server.createTcpServer(h2Server_argsTCP); |
71 |
myh2Server.start(); |
72 |
if (runH2WebServer){
|
73 |
myh2WebServer = Server.createWebServer(h2Server_argsWeb); |
74 |
myh2WebServer.start(); |
75 |
h2WebServer = myh2WebServer; |
76 |
} |
77 |
|
78 |
} catch (Exception e){ |
79 |
throw new RuntimeException(e); |
80 |
} |
81 |
h2Server = myh2Server; |
82 |
System.out.println("\n************************"); |
83 |
if (runH2WebServer){
|
84 |
System.out.println("* H2 SERVER STARTED web: "+ h2Server_argsWeb[1] + "!!!! *"); |
85 |
}else{
|
86 |
System.out.println("* H2 SERVER STARTED!!!! *"); |
87 |
} |
88 |
System.out.println("************************\n"); |
89 |
|
90 |
} |
91 |
|
92 |
|
93 |
public void stopH2Server(){ |
94 |
if (h2Server == null) { |
95 |
return;
|
96 |
} |
97 |
h2Server.stop(); |
98 |
h2Server.shutdown(); |
99 |
h2Server = null;
|
100 |
if (h2WebServer != null){ |
101 |
h2WebServer.stop(); |
102 |
h2WebServer.shutdown(); |
103 |
h2WebServer = null;
|
104 |
} |
105 |
System.out.println("\n************************"); |
106 |
System.out.println("* H2 SERVER STOPED!!!! *"); |
107 |
System.out.println("************************\n"); |
108 |
} |
109 |
|
110 |
|
111 |
private void deleteTable(H2StoreParameters h2Params) { |
112 |
try {
|
113 |
Class.forName("org.h2.Driver"); |
114 |
Connection con = DriverManager.getConnection(h2Params.getUrl(), |
115 |
h2Params.getUser(), h2Params.getPassw()); |
116 |
Statement st = con.createStatement();
|
117 |
st.execute("Delete " + h2Params.tableID());
|
118 |
st.close(); |
119 |
con.close(); |
120 |
System.out.println("* Table " + h2Params.tableID() + " DELETED!!"); |
121 |
} catch (ClassNotFoundException e) { |
122 |
// TODO Auto-generated catch block
|
123 |
e.printStackTrace(); |
124 |
} catch (SQLException e) { |
125 |
// TODO Auto-generated catch block
|
126 |
e.printStackTrace(); |
127 |
} |
128 |
|
129 |
|
130 |
} |
131 |
|
132 |
public void shp2H2(File shpfile,H2StoreParameters h2Param) { |
133 |
System.out.println("======= SHP2H2 =============="); |
134 |
org.gvsig.fmap.dal.shp.Register.selfRegister(); |
135 |
org.gvsig.fmap.dal.dbf.Register.selfRegister(); |
136 |
|
137 |
DataManager dsm=DefaultDataManager.getManager(); |
138 |
// File shpfile= new File(DataStoreTest.class.getResource("data/prueba.dbf").getFile());
|
139 |
|
140 |
// IDriverParameters dp=dsm.createDriverParameters("shp");
|
141 |
|
142 |
|
143 |
DataStoreParameters dsp=null;
|
144 |
try {
|
145 |
dsp = dsm.createStoreParameters(SHPStore.DATASTORE_NAME); |
146 |
} catch (InitializeException e3) {
|
147 |
e3.printStackTrace(); |
148 |
fail("Exception:" + e3);
|
149 |
} |
150 |
((SHPStoreParameters)dsp).setFile(shpfile); |
151 |
// ((SHPStoreParameters)dsp).setSHXFile(SHP.getShxFile(shpfile));
|
152 |
// ((SHPStoreParameters)dsp).setDBFFile(SHP.getDbfFile(shpfile));
|
153 |
FeatureStore fs=null;
|
154 |
try {
|
155 |
fs = (FeatureStore)dsm.createStore(dsp); |
156 |
} catch (InitializeException e) {
|
157 |
e.printStackTrace(); |
158 |
fail("Exception:" + e);
|
159 |
} |
160 |
|
161 |
// try {
|
162 |
// fs.open();
|
163 |
// } catch (OpenException e2) {
|
164 |
// e2.printStackTrace();
|
165 |
// fail();
|
166 |
// }
|
167 |
|
168 |
FeatureType ft= fs.getDefaultFeatureType(); |
169 |
FeatureSet featureCollection=null;
|
170 |
try {
|
171 |
featureCollection = (FeatureSet)fs.getDataSet(); |
172 |
} catch (ReadException e2) {
|
173 |
// TODO Auto-generated catch block
|
174 |
e2.printStackTrace(); |
175 |
} |
176 |
|
177 |
SHP2H2FeaturesVisitor visitor=new SHP2H2FeaturesVisitor(ft,h2Param);
|
178 |
visitor.createStructure(); |
179 |
|
180 |
try {
|
181 |
featureCollection.accept(visitor); |
182 |
} catch (BaseException e1) {
|
183 |
e1.printStackTrace(); |
184 |
System.out.println(e1.getMessageStack());
|
185 |
fail(); |
186 |
} |
187 |
|
188 |
// try {
|
189 |
// visitor.close();
|
190 |
// fs.close();
|
191 |
// } catch (CloseException e) {
|
192 |
// e.printStackTrace();
|
193 |
// fail("Exception: "+e);
|
194 |
// }
|
195 |
try {
|
196 |
fs.dispose(); |
197 |
} catch (CloseException e) {
|
198 |
// TODO Auto-generated catch block
|
199 |
e.printStackTrace(); |
200 |
} |
201 |
|
202 |
} |
203 |
|
204 |
|
205 |
public void testH2_sqlMode() { |
206 |
System.out.println("======= H2 (sql Mode)=============="); |
207 |
Register.selfRegister(); |
208 |
|
209 |
DataManager dsm=DefaultDataManager.getManager(); |
210 |
|
211 |
|
212 |
H2StoreParameters dp=this.cretateTablePrueba();
|
213 |
|
214 |
H2StoreParameters dp2= null;
|
215 |
try {
|
216 |
dp2 = (H2StoreParameters)dsm.createStoreParameters(H2Store.DATASTORE_NAME); |
217 |
} catch (InitializeException e2) {
|
218 |
e2.printStackTrace(); |
219 |
fail("Exception:" + e2);
|
220 |
} |
221 |
|
222 |
dp2.setHost("localhost");
|
223 |
dp2.setUser("SA");
|
224 |
dp2.setPassw("");
|
225 |
dp2.setDefaultGeometryField("GEOMETRY");
|
226 |
dp2.setFieldsId(new String[] {"ID"}); |
227 |
dp2.setSqlSoure("Select * from " + dp.tableID() );
|
228 |
|
229 |
storeTest(dp,null,null,false); |
230 |
|
231 |
Exception exc = null; |
232 |
|
233 |
FeatureStore fs=null;
|
234 |
try {
|
235 |
fs = (FeatureStore)dsm.createStore(dp2); |
236 |
} catch (InitializeException e) {
|
237 |
e.printStackTrace(); |
238 |
fail("Exception:" + e);
|
239 |
} |
240 |
assertNotNull("Can't create Feature Store", fs);
|
241 |
|
242 |
// try {
|
243 |
// fs.open();
|
244 |
// } catch (OpenException e2) {
|
245 |
// e2.printStackTrace();
|
246 |
// fail();
|
247 |
// }
|
248 |
|
249 |
|
250 |
FeatureSet fc =null;
|
251 |
|
252 |
try {
|
253 |
fc = (FeatureSet)fs.getDataSet(); |
254 |
} catch (ReadException e1) {
|
255 |
e1.printStackTrace(); |
256 |
fail(); |
257 |
} |
258 |
|
259 |
assertEquals(9, fc.size());
|
260 |
|
261 |
fc.dispose(); |
262 |
|
263 |
assertFalse("Edition allowed in sqlSource mode", fs.allowWrite());
|
264 |
|
265 |
try {
|
266 |
fs.edit(); |
267 |
} catch (ReadException e1) {
|
268 |
exc=e1; |
269 |
} |
270 |
assertNotNull("Edition allowed in sqlSource mode",exc);
|
271 |
|
272 |
exc=null;
|
273 |
try {
|
274 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"NOMBRE like 'B%'",null); |
275 |
} catch (ReadException e1) {
|
276 |
exc=e1; |
277 |
} |
278 |
assertNotNull("Filter allowed in sqlSource mode",exc);
|
279 |
|
280 |
exc=null;
|
281 |
try {
|
282 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE"); |
283 |
} catch (ReadException e1) {
|
284 |
exc=e1; |
285 |
} |
286 |
assertNotNull("Order allowed in sqlSource mode",exc);
|
287 |
|
288 |
|
289 |
// try {
|
290 |
// fs.close();
|
291 |
// } catch (CloseException e) {
|
292 |
// e.printStackTrace();
|
293 |
// fail("Exception:" + e);
|
294 |
// }
|
295 |
|
296 |
try {
|
297 |
fs.dispose(); |
298 |
} catch (CloseException e) {
|
299 |
e.printStackTrace();fail(); |
300 |
} |
301 |
|
302 |
|
303 |
deleteTable(dp); |
304 |
|
305 |
System.out.println("======= /H2 (sql Mode) =============="); |
306 |
} |
307 |
|
308 |
private String nuevoNombreDeTabla(String prefijo){ |
309 |
String s=String.valueOf(System.currentTimeMillis()); |
310 |
return prefijo+s.substring(s.length()-8); |
311 |
} |
312 |
|
313 |
private H2StoreParameters cretateTablePrueba(){
|
314 |
Register.selfRegister(); |
315 |
DataManager dsm=DefaultDataManager.getManager(); |
316 |
|
317 |
|
318 |
H2StoreParameters dp=null;
|
319 |
try {
|
320 |
dp = (H2StoreParameters)dsm.createStoreParameters(H2Store.DATASTORE_NAME); |
321 |
} catch (InitializeException e1) {
|
322 |
e1.printStackTrace(); |
323 |
fail(); |
324 |
} |
325 |
|
326 |
|
327 |
dp.setHost("localhost");
|
328 |
dp.setUser("SA");
|
329 |
dp.setPassw("");
|
330 |
dp.setFields(new String[] {"*"}); |
331 |
dp.setDefaultGeometryField("GEOMETRY");
|
332 |
dp.setTableName(nuevoNombreDeTabla("testh2").toUpperCase());
|
333 |
dp.setFieldsId(new String[] {"ID"}); |
334 |
|
335 |
try{
|
336 |
this.shp2H2(shpfile, dp);
|
337 |
} catch (Exception e) { |
338 |
if (e.getCause() instanceof BaseException){ |
339 |
System.out.println(((BaseException)e).getLocalizedMessageStack());
|
340 |
} else{
|
341 |
e.printStackTrace(); |
342 |
} |
343 |
fail(); |
344 |
} |
345 |
|
346 |
return dp;
|
347 |
|
348 |
} |
349 |
|
350 |
public void testH2() { |
351 |
System.out.println("======= H2 =============="); |
352 |
Register.selfRegister(); |
353 |
|
354 |
DataManager dsm=DefaultDataManager.getManager(); |
355 |
|
356 |
|
357 |
H2StoreParameters dp=cretateTablePrueba(); |
358 |
|
359 |
storeTest(dp, null, null, true); |
360 |
|
361 |
storeTest(dp, null, null, false); |
362 |
FeatureStore fs=null;
|
363 |
try {
|
364 |
fs = (FeatureStore)dsm.createStore(dp); |
365 |
} catch (InitializeException e) {
|
366 |
e.printStackTrace(); |
367 |
fail("Exception:" + e);
|
368 |
} |
369 |
assertNotNull("Can't create Feature Store", fs);
|
370 |
|
371 |
// try {
|
372 |
// fs.open();
|
373 |
// } catch (OpenException e2) {
|
374 |
// e2.printStackTrace();
|
375 |
// fail();
|
376 |
// }
|
377 |
|
378 |
Iterator it;
|
379 |
FeatureSet fc =null;
|
380 |
Comparable v1,v2;
|
381 |
Feature feature=null,pfeature=null; |
382 |
long count;
|
383 |
|
384 |
|
385 |
try {
|
386 |
fc = (FeatureSet)fs.getDataSet(); |
387 |
} catch (ReadException e1) {
|
388 |
e1.printStackTrace(); |
389 |
fail(); |
390 |
} |
391 |
|
392 |
assertEquals(9, fc.size());
|
393 |
|
394 |
it = fc.iterator(); |
395 |
count = 0;
|
396 |
while (it.hasNext()) {
|
397 |
feature = (Feature) it.next(); |
398 |
count++; |
399 |
} |
400 |
assertEquals("Iteration error", 9, count); |
401 |
|
402 |
fc.dispose(); |
403 |
|
404 |
try {
|
405 |
fc = (FeatureSet) fs.getDataCollection( |
406 |
new String[] { "NOMBRE" }, "lower(NOMBRE) like 'b%'", null); |
407 |
} catch (ReadException e1) {
|
408 |
e1.printStackTrace(); |
409 |
fail(); |
410 |
} |
411 |
|
412 |
assertEquals(2, fc.size());
|
413 |
|
414 |
|
415 |
it = fc.iterator(); |
416 |
count=0;
|
417 |
while (it.hasNext()){
|
418 |
feature = (Feature)it.next(); |
419 |
assertEquals(feature.getType().size(), 1);
|
420 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
421 |
count++; |
422 |
} |
423 |
assertEquals("Iteration error",2,count); |
424 |
|
425 |
fc.dispose(); |
426 |
|
427 |
|
428 |
try {
|
429 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE ASC"); |
430 |
} catch (ReadException e1) {
|
431 |
e1.printStackTrace(); |
432 |
fail(); |
433 |
} |
434 |
assertEquals(9, fc.size());
|
435 |
it = fc.iterator(); |
436 |
count=0;
|
437 |
pfeature = (Feature)it.next(); |
438 |
count++; |
439 |
while (it.hasNext()){
|
440 |
feature = (Feature)it.next(); |
441 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
442 |
v2 = (Comparable)feature.get("NOMBRE"); |
443 |
pfeature=feature; |
444 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
445 |
count++; |
446 |
} |
447 |
assertEquals("Iteration error",9,count); |
448 |
|
449 |
fc.dispose(); |
450 |
|
451 |
|
452 |
try {
|
453 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC"); |
454 |
} catch (ReadException e1) {
|
455 |
e1.printStackTrace(); |
456 |
fail(); |
457 |
} |
458 |
assertEquals(9, fc.size());
|
459 |
it = fc.iterator(); |
460 |
|
461 |
count=0;
|
462 |
pfeature = (Feature)it.next(); |
463 |
count++; |
464 |
while (it.hasNext()){
|
465 |
feature = (Feature)it.next(); |
466 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
467 |
v2 = (Comparable)feature.get("NOMBRE"); |
468 |
pfeature=feature; |
469 |
assertTrue("Short error", (v1.compareTo(v1) >= 0)); |
470 |
count++; |
471 |
} |
472 |
assertEquals("Iteration error",9,count); |
473 |
|
474 |
fc.dispose(); |
475 |
|
476 |
|
477 |
|
478 |
try {
|
479 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'","NOMBRE"); |
480 |
} catch (ReadException e1) {
|
481 |
e1.printStackTrace(); |
482 |
fail(); |
483 |
} |
484 |
|
485 |
assertEquals(2, fc.size());
|
486 |
|
487 |
it = fc.iterator(); |
488 |
|
489 |
count=0;
|
490 |
pfeature = (Feature)it.next(); |
491 |
assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b")); |
492 |
count++; |
493 |
while (it.hasNext()){
|
494 |
feature = (Feature)it.next(); |
495 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
496 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
497 |
v2 = (Comparable)feature.get("NOMBRE"); |
498 |
pfeature=feature; |
499 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
500 |
count++; |
501 |
} |
502 |
assertEquals("Iteration error",2,count); |
503 |
fc.dispose(); |
504 |
|
505 |
|
506 |
|
507 |
try {
|
508 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc"); |
509 |
} catch (ReadException e1) {
|
510 |
e1.printStackTrace(); |
511 |
fail(); |
512 |
} |
513 |
assertEquals(9, fc.size());
|
514 |
it = fc.iterator(); |
515 |
count=0;
|
516 |
pfeature = (Feature)it.next(); |
517 |
System.out.println(pfeature.getString("NOMBRE")); |
518 |
count++; |
519 |
while (it.hasNext()){
|
520 |
feature = (Feature)it.next(); |
521 |
v1 = ((String)pfeature.get("NOMBRE")).toLowerCase(); |
522 |
v2 = ((String)feature.get("NOMBRE")).toLowerCase(); |
523 |
pfeature=feature; |
524 |
assertTrue("Short error", (v1.compareTo(v2) >= 0)); |
525 |
System.out.println(pfeature.getString("NOMBRE")); |
526 |
count++; |
527 |
} |
528 |
assertEquals("Iteration error",9,count); |
529 |
fc.dispose(); |
530 |
|
531 |
|
532 |
|
533 |
/// CON EDICION
|
534 |
try {
|
535 |
fs.edit(); |
536 |
} catch (ReadException e1) {
|
537 |
e1.printStackTrace(); |
538 |
fail(); |
539 |
} |
540 |
|
541 |
try{
|
542 |
Feature newFeature = fs.createNewFeature(true);
|
543 |
newFeature.editing(); |
544 |
newFeature.setAttribute("NOMBRE","BuRjaSOT"); |
545 |
newFeature.setAttribute("TIPO","MUNICIPIO"); |
546 |
fs.insert(newFeature); |
547 |
} catch (DataException e2) {
|
548 |
// TODO Auto-generated catch block
|
549 |
e2.printStackTrace(); |
550 |
} |
551 |
|
552 |
try {
|
553 |
fc = (FeatureSet)fs.getDataSet(); |
554 |
} catch (ReadException e1) {
|
555 |
e1.printStackTrace(); |
556 |
fail(); |
557 |
} |
558 |
|
559 |
assertEquals(10, fc.size());
|
560 |
fc.dispose(); |
561 |
|
562 |
try {
|
563 |
fc = (FeatureSet)fs.getDataCollection(new String[] {"NOMBRE"},"lower(NOMBRE) like 'b%'",null); |
564 |
} catch (ReadException e1) {
|
565 |
e1.printStackTrace(); |
566 |
fail(); |
567 |
} |
568 |
|
569 |
assertEquals(3, fc.size());
|
570 |
|
571 |
it = fc.iterator(); |
572 |
count=0;
|
573 |
while (it.hasNext()){
|
574 |
feature = (Feature)it.next(); |
575 |
// assertEquals(1, feature.getType().size());
|
576 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
577 |
count++; |
578 |
} |
579 |
assertEquals("Iteration error",3,count); |
580 |
fc.dispose(); |
581 |
|
582 |
|
583 |
try {
|
584 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE ASC"); |
585 |
} catch (ReadException e1) {
|
586 |
e1.printStackTrace(); |
587 |
fail(); |
588 |
} |
589 |
assertEquals(10, fc.size());
|
590 |
it = fc.iterator(); |
591 |
count=0;
|
592 |
pfeature = (Feature)it.next(); |
593 |
count++; |
594 |
while (it.hasNext()){
|
595 |
feature = (Feature)it.next(); |
596 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
597 |
v2 = (Comparable)feature.get("NOMBRE"); |
598 |
pfeature=feature; |
599 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
600 |
count++; |
601 |
} |
602 |
assertEquals("Iteration error",10,count); |
603 |
fc.dispose(); |
604 |
|
605 |
|
606 |
try {
|
607 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC"); |
608 |
} catch (ReadException e1) {
|
609 |
e1.printStackTrace(); |
610 |
fail(); |
611 |
} |
612 |
assertEquals(10, fc.size());
|
613 |
it = fc.iterator(); |
614 |
|
615 |
count=0;
|
616 |
pfeature = (Feature)it.next(); |
617 |
count++; |
618 |
while (it.hasNext()){
|
619 |
feature = (Feature)it.next(); |
620 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
621 |
v2 = (Comparable)feature.get("NOMBRE"); |
622 |
pfeature=feature; |
623 |
assertTrue("Short error", (v1.compareTo(v1) >= 0)); |
624 |
count++; |
625 |
} |
626 |
assertEquals("Iteration error",10,count); |
627 |
fc.dispose(); |
628 |
|
629 |
|
630 |
try {
|
631 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'","NOMBRE"); |
632 |
} catch (ReadException e1) {
|
633 |
e1.printStackTrace(); |
634 |
fail(); |
635 |
} |
636 |
|
637 |
assertEquals(3, fc.size());
|
638 |
|
639 |
it = fc.iterator(); |
640 |
|
641 |
count=0;
|
642 |
pfeature = (Feature)it.next(); |
643 |
assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b")); |
644 |
count++; |
645 |
while (it.hasNext()){
|
646 |
feature = (Feature)it.next(); |
647 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
648 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
649 |
v2 = (Comparable)feature.get("NOMBRE"); |
650 |
pfeature=feature; |
651 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
652 |
count++; |
653 |
} |
654 |
assertEquals("Iteration error",3,count); |
655 |
fc.dispose(); |
656 |
|
657 |
|
658 |
|
659 |
try {
|
660 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc"); |
661 |
} catch (ReadException e1) {
|
662 |
e1.printStackTrace(); |
663 |
fail(); |
664 |
} |
665 |
assertEquals(10, fc.size());
|
666 |
it = fc.iterator(); |
667 |
count=0;
|
668 |
pfeature = (Feature)it.next(); |
669 |
System.out.println(pfeature.getString("NOMBRE")); |
670 |
count++; |
671 |
while (it.hasNext()){
|
672 |
feature = (Feature)it.next(); |
673 |
v1 = ((String)pfeature.get("NOMBRE")).toLowerCase(); |
674 |
v2 = ((String)feature.get("NOMBRE")).toLowerCase(); |
675 |
pfeature=feature; |
676 |
assertTrue("Short error", (v1.compareTo(v2) >= 0)); |
677 |
System.out.println(pfeature.getString("NOMBRE")); |
678 |
count++; |
679 |
} |
680 |
assertEquals("Iteration error",10,count); |
681 |
fc.dispose(); |
682 |
|
683 |
|
684 |
fs.cancelEditing(); |
685 |
|
686 |
|
687 |
//Insertar un elemento
|
688 |
try{
|
689 |
fs.edit(); |
690 |
} catch (ReadException e1) {
|
691 |
e1.printStackTrace(); |
692 |
fail(); |
693 |
} |
694 |
|
695 |
try{
|
696 |
feature = fs.createNewFeature(true);
|
697 |
feature.editing(); |
698 |
feature.setAttribute("ID", 90000); |
699 |
feature.setAttribute("NOMBRE","BurJASOT"); |
700 |
feature.setAttribute("TIPO", "OTRO"); |
701 |
fs.insert(feature); |
702 |
fs.finishEditing(); |
703 |
} catch (DataException e) {
|
704 |
e.printStackTrace(); |
705 |
fail("Exception: "+e);
|
706 |
} |
707 |
|
708 |
|
709 |
try {
|
710 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),null,"lower(NOMBRE) Desc"); |
711 |
} catch (ReadException e1) {
|
712 |
e1.printStackTrace(); |
713 |
fail(); |
714 |
} |
715 |
assertEquals(10, fc.size());
|
716 |
it = fc.iterator(); |
717 |
count=0;
|
718 |
pfeature = (Feature)it.next(); |
719 |
System.out.println(pfeature.getString("NOMBRE")); |
720 |
count++; |
721 |
while (it.hasNext()){
|
722 |
feature = (Feature)it.next(); |
723 |
v1 = ((String)pfeature.get("NOMBRE")).toLowerCase(); |
724 |
v2 = ((String)feature.get("NOMBRE")).toLowerCase(); |
725 |
pfeature=feature; |
726 |
assertTrue("Short error: "+ v1.toString() + " >= " +v2.toString(), (v1.compareTo(v2) >= 0)); |
727 |
System.out.println(pfeature.getString("NOMBRE")); |
728 |
count++; |
729 |
} |
730 |
assertEquals("Iteration error",10,count); |
731 |
fc.dispose(); |
732 |
|
733 |
//Actualizacion
|
734 |
try{
|
735 |
fs.edit(); |
736 |
} catch (ReadException e1) {
|
737 |
e1.printStackTrace(); |
738 |
fail(); |
739 |
} |
740 |
|
741 |
try {
|
742 |
fc = (FeatureSet) fs.getDataCollection(fs |
743 |
.getDefaultFeatureType(), "NOMBRE like '%__KK__'", null); |
744 |
} catch (ReadException e1) {
|
745 |
e1.printStackTrace(); |
746 |
fail(); |
747 |
} |
748 |
assertEquals(0, fc.size());
|
749 |
|
750 |
count = 0;
|
751 |
it = fc.iterator(); |
752 |
while (it.hasNext()) {
|
753 |
it.next(); |
754 |
count++; |
755 |
} |
756 |
assertEquals(0, count);
|
757 |
fc.dispose(); |
758 |
|
759 |
try {
|
760 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) = 'burjasot'",null); |
761 |
} catch (ReadException e1) {
|
762 |
e1.printStackTrace(); |
763 |
fail(); |
764 |
} |
765 |
assertEquals(1, fc.size());
|
766 |
count = 0;
|
767 |
it = fc.iterator(); |
768 |
while (it.hasNext()) {
|
769 |
it.next(); |
770 |
count++; |
771 |
} |
772 |
assertEquals(1, count);
|
773 |
|
774 |
feature =(AbstractFeature)fc.iterator().next(); |
775 |
boolean isOk=false; |
776 |
try {
|
777 |
// feature.editing();
|
778 |
feature.setAttribute("NOMBRE", feature.getString("NOMBRE")+"__KK__"); |
779 |
} catch (DataException e2) {
|
780 |
isOk=true;
|
781 |
} |
782 |
assertTrue("editing feature control", isOk);
|
783 |
|
784 |
try {
|
785 |
feature.editing(); |
786 |
feature.setAttribute("NOMBRE", feature.getString("NOMBRE")+"__KK__"); |
787 |
} catch (DataException e2) {
|
788 |
isOk=true;
|
789 |
e2.printStackTrace(); |
790 |
fail("Exception: "+e2);
|
791 |
} |
792 |
|
793 |
try {
|
794 |
fs.update(feature); |
795 |
} catch (DataException e2) {
|
796 |
e2.printStackTrace();fail(); |
797 |
} |
798 |
|
799 |
// try {
|
800 |
// fc = (FeatureCollection) fs.getDataCollection(fs
|
801 |
// .getDefaultFeatureType(), "NOMBRE like '%__KK__'", null);
|
802 |
// } catch (ReadException e1) {
|
803 |
// e1.printStackTrace();
|
804 |
// fail();
|
805 |
// }
|
806 |
// assertEquals(1, fc.size());
|
807 |
// count = 0;
|
808 |
// it = fc.iterator();
|
809 |
// while (it.hasNext()) {
|
810 |
// it.next();
|
811 |
// count++;
|
812 |
// }
|
813 |
// assertEquals(1, count);
|
814 |
fc.dispose(); |
815 |
|
816 |
|
817 |
try {
|
818 |
fs.finishEditing(); |
819 |
} catch (WriteException e) {
|
820 |
e.printStackTrace(); |
821 |
fail("Exception: "+e);
|
822 |
} catch (ReadException e) {
|
823 |
e.printStackTrace(); |
824 |
fail("Exception: "+e);
|
825 |
} |
826 |
|
827 |
try {
|
828 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"NOMBRE like '%__KK__'",null); |
829 |
} catch (ReadException e1) {
|
830 |
e1.printStackTrace(); |
831 |
fail(); |
832 |
} |
833 |
assertEquals(1, fc.size());
|
834 |
count = 0;
|
835 |
it = fc.iterator(); |
836 |
while (it.hasNext()) {
|
837 |
it.next(); |
838 |
count++; |
839 |
} |
840 |
assertEquals(1, count);
|
841 |
fc.dispose(); |
842 |
|
843 |
|
844 |
//Eliminacion
|
845 |
try{
|
846 |
fs.edit(); |
847 |
} catch (ReadException e1) {
|
848 |
e1.printStackTrace(); |
849 |
fail(); |
850 |
} |
851 |
|
852 |
|
853 |
try {
|
854 |
fc = (FeatureSet)fs.getDataCollection(fs.getDefaultFeatureType(),"NOMBRE like '%__KK__'",null); |
855 |
} catch (ReadException e1) {
|
856 |
e1.printStackTrace(); |
857 |
fail(); |
858 |
} |
859 |
assertEquals(1, fc.size());
|
860 |
|
861 |
count = 0;
|
862 |
it = fc.iterator(); |
863 |
while (it.hasNext()) {
|
864 |
it.next(); |
865 |
count++; |
866 |
} |
867 |
assertEquals(1, count);
|
868 |
|
869 |
try {
|
870 |
fs.delete((Feature)fc.iterator().next()); |
871 |
} catch (DataException e2) {
|
872 |
e2.printStackTrace();fail(); |
873 |
} |
874 |
fc.dispose(); |
875 |
|
876 |
try {
|
877 |
fc = (FeatureSet) fs.getDataCollection(fs |
878 |
.getDefaultFeatureType(), "NOMBRE like '%__KK__'", null); |
879 |
} catch (ReadException e1) {
|
880 |
e1.printStackTrace(); |
881 |
fail(); |
882 |
} |
883 |
assertEquals(0, fc.size());
|
884 |
|
885 |
count = 0;
|
886 |
it = fc.iterator(); |
887 |
while (it.hasNext()) {
|
888 |
it.next(); |
889 |
count++; |
890 |
} |
891 |
assertEquals(0, count);
|
892 |
fc.dispose(); |
893 |
|
894 |
try {
|
895 |
fs.finishEditing(); |
896 |
} catch (WriteException e) {
|
897 |
e.printStackTrace(); |
898 |
fail("Exception: "+e);
|
899 |
} catch (ReadException e) {
|
900 |
e.printStackTrace(); |
901 |
fail("Exception: "+e);
|
902 |
} |
903 |
|
904 |
try {
|
905 |
fc = (FeatureSet)fs.getDataSet(); |
906 |
} catch (ReadException e1) {
|
907 |
e1.printStackTrace(); |
908 |
fail(); |
909 |
} |
910 |
assertEquals(9, fc.size());
|
911 |
fc.dispose(); |
912 |
|
913 |
|
914 |
|
915 |
// try {
|
916 |
// fs.close();
|
917 |
// } catch (CloseException e) {
|
918 |
// e.printStackTrace();
|
919 |
// fail("Exception:" + e);
|
920 |
// }
|
921 |
|
922 |
try {
|
923 |
fc = (FeatureSet) fs.getDataCollection(fs |
924 |
.getDefaultFeatureType(), "NOMBRE = 'NOEXISTE'", null); |
925 |
} catch (ReadException e1) {
|
926 |
e1.printStackTrace(); |
927 |
fail(); |
928 |
} |
929 |
|
930 |
count = 0;
|
931 |
it = fc.iterator(); |
932 |
while (it.hasNext()) {
|
933 |
it.next(); |
934 |
count++; |
935 |
} |
936 |
assertEquals(0, count);
|
937 |
|
938 |
|
939 |
|
940 |
try {
|
941 |
fs.dispose(); |
942 |
} catch (CloseException e) {
|
943 |
e.printStackTrace();fail(); |
944 |
} |
945 |
|
946 |
// TODO FALTA Notificaci?n de edici?n
|
947 |
doFileResourceTest(dp); |
948 |
// JDBCTest.doFileResourceTest(dp,false);
|
949 |
|
950 |
deleteTable(dp); |
951 |
|
952 |
System.out.println("======= /H2 =============="); |
953 |
|
954 |
} |
955 |
|
956 |
public void testH2_explorer_list(){ |
957 |
System.out.println("======= H2 explorer list =============="); |
958 |
Register.selfRegister(); |
959 |
|
960 |
DataManager dm=DefaultDataManager.getManager(); |
961 |
|
962 |
|
963 |
H2ExplorerParameters dp=null;
|
964 |
try {
|
965 |
dp = (H2ExplorerParameters)dm.createExplorerParameters(H2Explorer.DATAEXPLORER_NAME); |
966 |
} catch (InitializeException e2) {
|
967 |
e2.printStackTrace(); |
968 |
fail(); |
969 |
} |
970 |
|
971 |
dp.setHost("localhost");
|
972 |
dp.setUser("SA");
|
973 |
dp.setPassw("");
|
974 |
dp.setShowInformationDBTables(true);
|
975 |
|
976 |
FeatureExplorer explorer=null;
|
977 |
try {
|
978 |
explorer = (FeatureExplorer)dm.createExplorer(dp); |
979 |
} catch (InitializeException e1) {
|
980 |
e1.printStackTrace(); |
981 |
fail(); return;
|
982 |
} |
983 |
|
984 |
DataStoreParameters[] list= null; |
985 |
|
986 |
try {
|
987 |
list = explorer.list(); |
988 |
} catch (ReadException e) {
|
989 |
e.printStackTrace(); |
990 |
fail();return;
|
991 |
} |
992 |
|
993 |
H2StoreParameters h2param= null;
|
994 |
DBFeatureType ftype=null;
|
995 |
Iterator iter = null; |
996 |
DBAttributeDescriptor attr= null;
|
997 |
|
998 |
int i;
|
999 |
for (i=0;i<list.length;i++){ |
1000 |
h2param = (H2StoreParameters)list[i]; |
1001 |
System.out.println("Table: "+h2param.tableID()); |
1002 |
try {
|
1003 |
ftype =(DBFeatureType)(explorer.getFeatureTypes(h2param)[0]);
|
1004 |
} catch (ReadException e) {
|
1005 |
e.printStackTrace(); |
1006 |
fail(); return;
|
1007 |
} |
1008 |
System.out.println("\tNum fields: "+ftype.size()); |
1009 |
System.out.println("\tPk field: "+ftype.getFieldsId()[0]); |
1010 |
System.out.println("\tFields: "); |
1011 |
|
1012 |
|
1013 |
iter = ftype.iterator(); |
1014 |
while(iter.hasNext()){
|
1015 |
attr = (DBAttributeDescriptor) iter.next(); |
1016 |
System.out.println("\t\t "+attr.getName()+" "+attr.getDataType()); |
1017 |
} |
1018 |
|
1019 |
} |
1020 |
|
1021 |
try {
|
1022 |
explorer.dispose(); |
1023 |
} catch (DataException e) {
|
1024 |
e.printStackTrace(); |
1025 |
} |
1026 |
|
1027 |
this.persistenceTest(dp);
|
1028 |
|
1029 |
System.out.println("======= H2 explorer list=============="); |
1030 |
} |
1031 |
|
1032 |
public void testH2_explorer_remove(){ |
1033 |
System.out.println("======= H2 explorer delete=============="); |
1034 |
Register.selfRegister(); |
1035 |
|
1036 |
DataManager dm=DefaultDataManager.getManager(); |
1037 |
|
1038 |
H2StoreParameters ds=cretateTablePrueba(); |
1039 |
|
1040 |
H2ExplorerParameters dex=null;
|
1041 |
try {
|
1042 |
dex = (H2ExplorerParameters)dm.createExplorerParameters(H2Explorer.DATAEXPLORER_NAME); |
1043 |
} catch (InitializeException e2) {
|
1044 |
e2.printStackTrace(); |
1045 |
fail(); |
1046 |
} |
1047 |
|
1048 |
dex.putAllDefaultValues(ds); |
1049 |
dex.setShowInformationDBTables(false);
|
1050 |
|
1051 |
FeatureExplorer explorer=null;
|
1052 |
try {
|
1053 |
explorer = (FeatureExplorer)dm.createExplorer(dex); |
1054 |
} catch (InitializeException e1) {
|
1055 |
e1.printStackTrace(); |
1056 |
fail(); return;
|
1057 |
} |
1058 |
|
1059 |
DataStoreParameters[] list= null; |
1060 |
|
1061 |
try {
|
1062 |
list = explorer.list(); |
1063 |
} catch (ReadException e) {
|
1064 |
e.printStackTrace(); |
1065 |
fail();return;
|
1066 |
} |
1067 |
|
1068 |
if (list.length < 1){ |
1069 |
fail(); return;
|
1070 |
} |
1071 |
int i;
|
1072 |
boolean found=false; |
1073 |
H2StoreParameters dsaux=null;
|
1074 |
for(i=0;i<list.length;i++){ |
1075 |
dsaux = (H2StoreParameters)list[i]; |
1076 |
if (dsaux.getTableName().equals(ds.getTableName())){
|
1077 |
found=true;
|
1078 |
break;
|
1079 |
} |
1080 |
} |
1081 |
if (!found){
|
1082 |
fail(); |
1083 |
} |
1084 |
|
1085 |
try {
|
1086 |
explorer.remove(dsaux); |
1087 |
} catch (ReadException e) {
|
1088 |
e.printStackTrace(); |
1089 |
fail();return;
|
1090 |
} |
1091 |
|
1092 |
try {
|
1093 |
list = explorer.list(); |
1094 |
} catch (ReadException e) {
|
1095 |
e.printStackTrace(); |
1096 |
fail();return;
|
1097 |
} |
1098 |
|
1099 |
found = false;
|
1100 |
for(i=0;i<list.length;i++){ |
1101 |
dsaux = (H2StoreParameters)list[i]; |
1102 |
if (dsaux.getTableName().equals(ds.getTableName())){
|
1103 |
found=true;
|
1104 |
break;
|
1105 |
} |
1106 |
} |
1107 |
if (found){
|
1108 |
fail(); |
1109 |
} |
1110 |
|
1111 |
try {
|
1112 |
explorer.dispose(); |
1113 |
} catch (DataException e) {
|
1114 |
e.printStackTrace();fail(); |
1115 |
} |
1116 |
|
1117 |
System.out.println("======= /H2 explorer remove=============="); |
1118 |
} |
1119 |
|
1120 |
public void testH2_explorer_add_remove(){ |
1121 |
System.out.println("======= H2 explorer add/remove=============="); |
1122 |
Register.selfRegister(); |
1123 |
|
1124 |
DataManager dm=DefaultDataManager.getManager(); |
1125 |
|
1126 |
|
1127 |
H2ExplorerParameters dex=null;
|
1128 |
try {
|
1129 |
dex = (H2ExplorerParameters)dm.createExplorerParameters(H2Explorer.DATAEXPLORER_NAME); |
1130 |
} catch (InitializeException e3) {
|
1131 |
e3.printStackTrace(); |
1132 |
fail(); |
1133 |
} |
1134 |
|
1135 |
|
1136 |
dex.setHost("localhost");
|
1137 |
dex.setUser("SA");
|
1138 |
dex.setPassw("");
|
1139 |
|
1140 |
FeatureExplorer explorer=null;
|
1141 |
try {
|
1142 |
explorer = (FeatureExplorer)dm.createExplorer(dex); |
1143 |
} catch (InitializeException e1) {
|
1144 |
e1.printStackTrace(); |
1145 |
fail(); return;
|
1146 |
} |
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
H2NewStoreParameter newdp; |
1152 |
try {
|
1153 |
newdp = (H2NewStoreParameter) explorer |
1154 |
.createNewDataStoreParameter(); |
1155 |
} catch (InitializeException e3) {
|
1156 |
e3.printStackTrace(); |
1157 |
fail(); |
1158 |
return;
|
1159 |
} |
1160 |
|
1161 |
newdp.getH2Parameters().setTableName(nuevoNombreDeTabla("th2_create").toUpperCase());
|
1162 |
newdp.getH2Parameters().setFieldsId(new String[] {"ID"}); |
1163 |
|
1164 |
|
1165 |
DBFeatureType ftype = new DBFeatureType();
|
1166 |
|
1167 |
newdp.setFeatureType(ftype); |
1168 |
DBAttributeDescriptor attr; |
1169 |
|
1170 |
attr = (DBAttributeDescriptor) ftype.createAttributeDescriptor(); |
1171 |
try {
|
1172 |
attr.loading(); |
1173 |
attr.setName("ID");
|
1174 |
attr.setAutoIncrement(true);
|
1175 |
attr.setType(FeatureAttributeDescriptor.INT); |
1176 |
attr.setPrimaryKey(true);
|
1177 |
attr.stopLoading(); |
1178 |
ftype.add(attr); |
1179 |
|
1180 |
attr = (DBAttributeDescriptor) ftype.createAttributeDescriptor(); |
1181 |
attr.loading(); |
1182 |
attr.setName("MYGEOMETRY");
|
1183 |
attr.setType(FeatureAttributeDescriptor.GEOMETRY); |
1184 |
attr.stopLoading(); |
1185 |
ftype.add(attr); |
1186 |
ftype.setDefaultGeometry(attr.getName()); |
1187 |
|
1188 |
attr = (DBAttributeDescriptor) ftype.createAttributeDescriptor(); |
1189 |
attr.loading(); |
1190 |
attr.setName("MYSTRING");
|
1191 |
attr.setSize(50);
|
1192 |
attr.setDefaultValue("def");
|
1193 |
attr.setType(FeatureAttributeDescriptor.STRING); |
1194 |
attr.stopLoading(); |
1195 |
ftype.add(attr); |
1196 |
|
1197 |
|
1198 |
attr = (DBAttributeDescriptor) ftype.createAttributeDescriptor(); |
1199 |
attr.loading(); |
1200 |
attr.setName("MYDOUBLE");
|
1201 |
|
1202 |
attr.setType(FeatureAttributeDescriptor.DOUBLE); |
1203 |
|
1204 |
attr.stopLoading(); |
1205 |
|
1206 |
ftype.add(attr); |
1207 |
|
1208 |
ftype.setFieldsId(newdp.getH2Parameters().getFieldsId()); |
1209 |
} catch (DataException e2) {
|
1210 |
e2.printStackTrace(); |
1211 |
fail();return;
|
1212 |
} |
1213 |
|
1214 |
try {
|
1215 |
explorer.add(newdp); |
1216 |
} catch (InitializeException e1) {
|
1217 |
e1.printStackTrace(); |
1218 |
fail();return;
|
1219 |
} catch (WriteException e1) {
|
1220 |
e1.printStackTrace(); |
1221 |
fail();return;
|
1222 |
} |
1223 |
|
1224 |
|
1225 |
DataStoreParameters[] list= null; |
1226 |
|
1227 |
try {
|
1228 |
list = explorer.list(); |
1229 |
} catch (ReadException e) {
|
1230 |
e.printStackTrace(); |
1231 |
fail();return;
|
1232 |
} |
1233 |
|
1234 |
if (list.length < 1){ |
1235 |
fail(); return;
|
1236 |
} |
1237 |
int i;
|
1238 |
boolean found=false; |
1239 |
H2StoreParameters dsaux=null;
|
1240 |
for(i=0;i<list.length;i++){ |
1241 |
dsaux = (H2StoreParameters)list[i]; |
1242 |
if (dsaux.getTableName().equalsIgnoreCase(newdp.getH2Parameters().getTableName())){
|
1243 |
found=true;
|
1244 |
break;
|
1245 |
} |
1246 |
} |
1247 |
if (!found){
|
1248 |
fail(); |
1249 |
} |
1250 |
|
1251 |
try {
|
1252 |
explorer.remove(dsaux); |
1253 |
} catch (ReadException e) {
|
1254 |
e.printStackTrace(); |
1255 |
fail();return;
|
1256 |
} |
1257 |
|
1258 |
try {
|
1259 |
list = explorer.list(); |
1260 |
} catch (ReadException e) {
|
1261 |
e.printStackTrace(); |
1262 |
fail();return;
|
1263 |
} |
1264 |
|
1265 |
found = false;
|
1266 |
for(i=0;i<list.length;i++){ |
1267 |
dsaux = (H2StoreParameters)list[i]; |
1268 |
if (dsaux.getTableName().equals(newdp.getH2Parameters().getTableName())){
|
1269 |
found=true;
|
1270 |
break;
|
1271 |
} |
1272 |
} |
1273 |
if (found){
|
1274 |
fail(); |
1275 |
} |
1276 |
|
1277 |
try {
|
1278 |
explorer.dispose(); |
1279 |
} catch (DataException e) {
|
1280 |
e.printStackTrace();fail(); |
1281 |
} |
1282 |
|
1283 |
System.out.println("======= /H2 explorer add/remove=============="); |
1284 |
} |
1285 |
|
1286 |
|
1287 |
protected void tearDown() throws Exception { |
1288 |
// TODO Auto-generated method stub
|
1289 |
super.tearDown();
|
1290 |
if (startsH2Server) {
|
1291 |
this.stopH2Server();
|
1292 |
} |
1293 |
|
1294 |
|
1295 |
} |
1296 |
} |