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