svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.xml2db / org.gvsig.xml2db.lib / org.gvsig.xml2db.lib.impl / src / test / java / org / gvsig / xml2db / lib / impl / TestCopyXml2db.java @ 47283
History | View | Annotate | Download (3.36 KB)
1 |
package org.gvsig.xml2db.lib.impl; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.InputStream; |
5 |
import org.apache.commons.io.FilenameUtils; |
6 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
7 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
8 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
9 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
10 |
import org.slf4j.Logger; |
11 |
import org.slf4j.LoggerFactory; |
12 |
|
13 |
|
14 |
@SuppressWarnings("UseSpecificCatch") |
15 |
public class TestCopyXml2db extends AbstractLibraryAutoInitTestCase { |
16 |
|
17 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCopyXml2db.class); |
18 |
|
19 |
private TestUtilsXml2db utils;
|
20 |
|
21 |
public TestCopyXml2db(String testName) { |
22 |
super(testName);
|
23 |
} |
24 |
|
25 |
@Override
|
26 |
protected void doSetUp() throws Exception { |
27 |
|
28 |
} |
29 |
|
30 |
public TestUtilsXml2db utils() {
|
31 |
if( this.utils == null ) { |
32 |
this.utils = new TestUtilsXml2db(); |
33 |
} |
34 |
return this.utils; |
35 |
} |
36 |
|
37 |
public void testCopyDeclaracion() throws Exception { |
38 |
Xml2dbManager manager = new DefaultXml2dbManager();
|
39 |
|
40 |
InputStream xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
41 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
42 |
|
43 |
File dbfile = utils().getFile(new File("databases/declaracion4")); |
44 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
45 |
|
46 |
xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
47 |
manager.copyXml2Db(xml, null, dbparams, null); |
48 |
} |
49 |
|
50 |
public void testCopyR10graf() throws Exception { |
51 |
// String xmlfname = "BDA_R10_graf18_1728062018_004.xml";
|
52 |
// String xmlfname = "BDA_R10_graf18_1728062018_002.xml";
|
53 |
String xmlfname = "r10graf.xml"; |
54 |
try {
|
55 |
Xml2dbManager manager = new DefaultXml2dbManager();
|
56 |
InputStream xml = this.getClass().getResourceAsStream(xmlfname); |
57 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
58 |
|
59 |
File dbfile = utils().getFile(new File("databases/"+FilenameUtils.removeExtension(xmlfname))); |
60 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
61 |
|
62 |
xml = this.getClass().getResourceAsStream(xmlfname);
|
63 |
manager.copyXml2Db(xml, null, dbparams, null); |
64 |
} catch(Throwable t) { |
65 |
LOGGER.warn("Test testCopyR10graf failed",t);
|
66 |
throw t;
|
67 |
} |
68 |
} |
69 |
|
70 |
public void testCopyArena2() throws Exception { |
71 |
// Fallan cosas del estilo de la linea 281 o 282, parece que no reconoce el
|
72 |
// StructureStractor a PRES_INFRAC_VEL_COND como una tabla.
|
73 |
// Hay que repasar tambien que pasa con cosas como la linea 497.
|
74 |
try {
|
75 |
Xml2dbManager manager = new DefaultXml2dbManager();
|
76 |
|
77 |
InputStream xml = this.getClass().getResourceAsStream("victimas.xml"); |
78 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
79 |
|
80 |
File dbfile = utils().getFile(new File("databases/victimas")); |
81 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
82 |
|
83 |
xml = this.getClass().getResourceAsStream("victimas.xml"); |
84 |
// manager.copyXml2Db(xml, null, dbparams);
|
85 |
} catch(Throwable t) { |
86 |
LOGGER.warn("Test testCopyArena2 failed",t);
|
87 |
throw t;
|
88 |
} |
89 |
} |
90 |
|
91 |
} |