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 | 47092 | jjdelcerro | package org.gvsig.xml2db.lib.impl; |
---|---|---|---|
2 | |||
3 | import java.io.File; |
||
4 | import java.io.InputStream; |
||
5 | 47223 | jjdelcerro | import org.apache.commons.io.FilenameUtils; |
6 | 47092 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
7 | import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
||
8 | import org.gvsig.xml2db.lib.api.Xml2dbManager; |
||
9 | 47263 | jjdelcerro | import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
10 | 47092 | jjdelcerro | 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 | 47283 | jjdelcerro | XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
42 | 47092 | jjdelcerro | |
43 | File dbfile = utils().getFile(new File("databases/declaracion4")); |
||
44 | 47283 | jjdelcerro | JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
45 | 47092 | jjdelcerro | |
46 | xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
||
47 | 47283 | jjdelcerro | manager.copyXml2Db(xml, null, dbparams, null); |
48 | 47092 | jjdelcerro | } |
49 | |||
50 | public void testCopyR10graf() throws Exception { |
||
51 | 47223 | jjdelcerro | // String xmlfname = "BDA_R10_graf18_1728062018_004.xml";
|
52 | // String xmlfname = "BDA_R10_graf18_1728062018_002.xml";
|
||
53 | String xmlfname = "r10graf.xml"; |
||
54 | 47092 | jjdelcerro | try {
|
55 | Xml2dbManager manager = new DefaultXml2dbManager();
|
||
56 | 47223 | jjdelcerro | InputStream xml = this.getClass().getResourceAsStream(xmlfname); |
57 | 47283 | jjdelcerro | XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
58 | 47092 | jjdelcerro | |
59 | 47223 | jjdelcerro | File dbfile = utils().getFile(new File("databases/"+FilenameUtils.removeExtension(xmlfname))); |
60 | 47283 | jjdelcerro | JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
61 | 47092 | jjdelcerro | |
62 | 47223 | jjdelcerro | xml = this.getClass().getResourceAsStream(xmlfname);
|
63 | 47283 | jjdelcerro | manager.copyXml2Db(xml, null, dbparams, null); |
64 | 47092 | jjdelcerro | } catch(Throwable t) { |
65 | LOGGER.warn("Test testCopyR10graf failed",t);
|
||
66 | throw t;
|
||
67 | } |
||
68 | } |
||
69 | |||
70 | 47223 | jjdelcerro | 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 | 47093 | jjdelcerro | |
77 | 47223 | jjdelcerro | InputStream xml = this.getClass().getResourceAsStream("victimas.xml"); |
78 | 47283 | jjdelcerro | XMLInfo xmlinfo = manager.extractStructure(xml, null, null, null); |
79 | 47223 | jjdelcerro | |
80 | File dbfile = utils().getFile(new File("databases/victimas")); |
||
81 | 47283 | jjdelcerro | JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo, null);
|
82 | 47223 | jjdelcerro | |
83 | xml = this.getClass().getResourceAsStream("victimas.xml"); |
||
84 | 47234 | jjdelcerro | // manager.copyXml2Db(xml, null, dbparams);
|
85 | 47223 | jjdelcerro | } catch(Throwable t) { |
86 | LOGGER.warn("Test testCopyArena2 failed",t);
|
||
87 | throw t;
|
||
88 | } |
||
89 | } |
||
90 | |||
91 | 47092 | jjdelcerro | } |