Revision 34509
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/schemas/PatternNorm.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by vic (vic) --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <!--<xsd:schema targetNamespace="http://www.w3schools.com" + xmlns="http://www.w3schools.com" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified"> --> + <xsd:element name="patternnormalization"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="patternname"/> + <xsd:element ref="patternurl"/> + <xsd:element ref="normalizationfirstrow"/> + <xsd:element ref="addresselements"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="patternname" type="xsd:string"/> + <xsd:element name="normalizationfirstrow" type="xsd:boolean" default="true"/> + <xsd:element name="patternurl" type="xsd:string"/> + <xsd:element name="addresselements"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="addresselement" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="addresselement"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="newfieldname"/> + <xsd:element ref="newfieldtype"/> + <xsd:element ref="fieldwidth"/> + <xsd:element ref="fieldseparator" minOccurs="0"/> + <xsd:element ref="infieldseparators"/> + <xsd:element ref="importfield"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="newfieldname" type="xsd:string"/> + <xsd:element name="newfieldtype"> + <xsd:complexType> + <xsd:choice> + <xsd:element ref="stringvalue"/> + <xsd:element ref="datevalue"/> + <xsd:element ref="decimalvalue"/> + <xsd:element ref="integervalue"/> + </xsd:choice> + </xsd:complexType> + </xsd:element> + <xsd:element name="stringvalue"> + <xsd:complexType> + <xsd:attribute name="width" type="xsd:int"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="datevalue"> + <xsd:complexType> + <xsd:attribute name="format" type="xsd:string" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="decimalvalue"> + <xsd:complexType> + <xsd:attribute name="integers" type="xsd:int" use="required"/> + <xsd:attribute name="decimals" type="xsd:int" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="integervalue"> + <xsd:complexType> + <xsd:attribute name="width" type="xsd:int" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="fieldwidth" type="xsd:int"/> + <xsd:element name="fieldseparator"> + <xsd:complexType> + <xsd:attribute name="tabsep" type="xsd:boolean" use="optional" default="false"/> + <xsd:attribute name="spacesep" type="xsd:boolean" use="optional" default="false"/> + <xsd:attribute name="colonsep" type="xsd:boolean" use="optional" default="false"/> + <xsd:attribute name="semicolonsep" type="xsd:boolean" use="optional" default="false"/> + <xsd:attribute name="othersep" type="xsd:string" use="optional"/> + <xsd:attribute name="joinsep" type="xsd:boolean" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="importfield" type="xsd:boolean" default="true"/> + <xsd:element name="infieldseparators"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="thousandseparator"/> + <xsd:element ref="decimalseparator"/> + <xsd:element ref="textseparator"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="integers" type="xsd:int"/> + <xsd:element name="textseparator"> + <xsd:complexType> + <xsd:attribute name="value" type="xsd:string" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="thousandseparator"> + <xsd:complexType> + <xsd:attribute name="value" type="xsd:string" use="required"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="decimalseparator"> + <xsd:complexType> + <xsd:attribute name="value" type="xsd:string" use="required"/> + </xsd:complexType> + </xsd:element> +</xsd:schema> Index: tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/schemas/PatternGeoco.xsd |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/schemas/PatternGeoco.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by vic (vic) --> |
|
3 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
4 |
<!--<xsd:schema targetNamespace="http://www.w3schools.com" |
|
5 |
xmlns="http://www.w3schools.com" |
|
6 |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
|
7 |
elementFormDefault="qualified"> --> |
|
8 |
<xsd:element name="patterngeocoding"> |
|
9 |
<xsd:complexType> |
|
10 |
<xsd:sequence> |
|
11 |
<xsd:element ref="patternname"/> |
|
12 |
<xsd:element ref="patternurl"/> |
|
13 |
<xsd:element ref="source"/> |
|
14 |
<xsd:element ref="settings"/> |
|
15 |
</xsd:sequence> |
|
16 |
</xsd:complexType> |
|
17 |
</xsd:element> |
|
18 |
<xsd:element name="patternname" type="xsd:string"/> |
|
19 |
<xsd:element name="patternurl" type="xsd:string"/> |
|
20 |
<xsd:element name="source"> |
|
21 |
<xsd:complexType> |
|
22 |
<xsd:sequence> |
|
23 |
<xsd:element ref="addressstyle"/> |
|
24 |
<xsd:element ref="layersource"/> |
|
25 |
</xsd:sequence> |
|
26 |
</xsd:complexType> |
|
27 |
</xsd:element> |
|
28 |
<xsd:element name="layersource"> |
|
29 |
<xsd:complexType> |
|
30 |
<xsd:choice> |
|
31 |
<xsd:element ref="shpfile"/> |
|
32 |
<xsd:element ref="jdbc"/> |
|
33 |
</xsd:choice> |
|
34 |
<xsd:attribute name="id" type="xsd:string" use="required"/> |
|
35 |
</xsd:complexType> |
|
36 |
</xsd:element> |
|
37 |
<xsd:element name="property"> |
|
38 |
<xsd:complexType> |
|
39 |
<xsd:attribute name="key" type="xsd:string" use="required"/> |
|
40 |
<xsd:attribute name="value" type="xsd:string" use="optional"/> |
|
41 |
</xsd:complexType> |
|
42 |
</xsd:element> |
|
43 |
<xsd:element name="addressstyle"> |
|
44 |
<xsd:complexType> |
|
45 |
<xsd:sequence> |
|
46 |
<xsd:element ref="field" maxOccurs="unbounded"/> |
|
47 |
</xsd:sequence> |
|
48 |
</xsd:complexType> |
|
49 |
</xsd:element> |
|
50 |
<xsd:element name="field"> |
|
51 |
<xsd:complexType> |
|
52 |
<xsd:attribute name="name" type="xsd:string" use="required"/> |
|
53 |
<xsd:attribute name="addresselement" type="xsd:string" use="required"/> |
|
54 |
</xsd:complexType> |
|
55 |
</xsd:element> |
|
56 |
<xsd:element name="settings"> |
|
57 |
<xsd:complexType> |
|
58 |
<xsd:attribute name="maxresults" type="xsd:integer" default="10"/> |
|
59 |
<xsd:attribute name="accuracy" type="xsd:integer" default="80"/> |
|
60 |
<xsd:attribute name="quality" type="xsd:integer" default="80"/> |
|
61 |
</xsd:complexType> |
|
62 |
</xsd:element> |
|
63 |
<xsd:element name="shpfile"> |
|
64 |
<xsd:complexType> |
|
65 |
<xsd:attribute name="file" type="xsd:string" use="required"/> |
|
66 |
</xsd:complexType> |
|
67 |
</xsd:element> |
|
68 |
<xsd:element name="jdbc"> |
|
69 |
<xsd:complexType> |
|
70 |
<xsd:attribute name="server" type="xsd:string" use="required"/> |
|
71 |
<xsd:attribute name="database" type="xsd:string" use="required"/> |
|
72 |
<xsd:attribute name="table" type="xsd:string" use="required"/> |
|
73 |
<xsd:attribute name="user" type="xsd:string" use="required"/> |
|
74 |
</xsd:complexType> |
|
75 |
</xsd:element> |
|
76 |
</xsd:schema> |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libGeocoding</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/patterns/AllTests.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.patterns; |
|
29 |
|
|
30 |
import junit.framework.Test; |
|
31 |
import junit.framework.TestSuite; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
36 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
37 |
* |
|
38 |
*/ |
|
39 |
|
|
40 |
public class AllTests { |
|
41 |
|
|
42 |
public static Test suite() { |
|
43 |
TestSuite suite = new TestSuite( |
|
44 |
"Test for org.gvsig.normalization.patterns"); |
|
45 |
// $JUnit-BEGIN$ |
|
46 |
suite.addTestSuite(TestPersistence.class); |
|
47 |
|
|
48 |
// $JUnit-END$ |
|
49 |
return suite; |
|
50 |
} |
|
51 |
|
|
52 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/patterns/TestPersistence.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.patterns; |
|
29 |
|
|
30 |
import java.io.IOException; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import junit.framework.TestCase; |
|
35 |
|
|
36 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
37 |
import com.iver.utiles.XMLEntity; |
|
38 |
|
|
39 |
/** |
|
40 |
* |
|
41 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
42 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicent Sanjaime Calvet</a> |
|
43 |
* |
|
44 |
*/ |
|
45 |
public class TestPersistence extends TestCase { |
|
46 |
|
|
47 |
/** |
|
48 |
* test |
|
49 |
* |
|
50 |
* @throws XMLException |
|
51 |
*/ |
|
52 |
public void testParseLoadXML() throws IOException, XMLException { |
|
53 |
|
|
54 |
NormalizationPattern pat = new NormalizationPattern(); |
|
55 |
pat.setPatternname("pruebaParseXML.xml"); |
|
56 |
pat.setNofirstrows(0); |
|
57 |
|
|
58 |
List<Element> elems = new ArrayList<Element>(); |
|
59 |
|
|
60 |
Element elem1 = new Element(); |
|
61 |
elem1.setFieldname("campo1"); |
|
62 |
|
|
63 |
Fieldtype tipo = new Fieldtype(); |
|
64 |
Stringvalue strval = new Stringvalue(); |
|
65 |
strval.setStringvaluewidth(50); |
|
66 |
tipo.setStringvalue(strval); |
|
67 |
elem1.setFieldtype(tipo); |
|
68 |
|
|
69 |
elem1.setFieldwidth(30); |
|
70 |
|
|
71 |
Fieldseparator fsep = new Fieldseparator(); |
|
72 |
fsep.setSemicolonsep(true); |
|
73 |
fsep.setJoinsep(false); |
|
74 |
elem1.setFieldseparator(fsep); |
|
75 |
|
|
76 |
Infieldseparators infsep = new Infieldseparators(); |
|
77 |
infsep.setThousandseparator(","); |
|
78 |
infsep.setDecimalseparator("."); |
|
79 |
infsep.setTextseparator("\""); |
|
80 |
elem1.setInfieldseparators(infsep); |
|
81 |
|
|
82 |
elem1.setImportfield(true); |
|
83 |
|
|
84 |
elems.add(elem1); |
|
85 |
|
|
86 |
Element elem2 = new Element(); |
|
87 |
elem2.setFieldname("campo2"); |
|
88 |
|
|
89 |
Fieldtype tipo2 = new Fieldtype(); |
|
90 |
Stringvalue strval2 = new Stringvalue(); |
|
91 |
strval2.setStringvaluewidth(50); |
|
92 |
tipo2.setStringvalue(strval2); |
|
93 |
elem2.setFieldtype(tipo2); |
|
94 |
|
|
95 |
elem2.setFieldwidth(30); |
|
96 |
|
|
97 |
Fieldseparator fsep2 = new Fieldseparator(); |
|
98 |
fsep2.setSemicolonsep(true); |
|
99 |
fsep2.setJoinsep(false); |
|
100 |
elem2.setFieldseparator(fsep2); |
|
101 |
|
|
102 |
Infieldseparators infsep2 = new Infieldseparators(); |
|
103 |
infsep2.setThousandseparator(","); |
|
104 |
infsep2.setDecimalseparator("."); |
|
105 |
infsep2.setTextseparator("\""); |
|
106 |
elem2.setInfieldseparators(infsep2); |
|
107 |
|
|
108 |
elem2.setImportfield(true); |
|
109 |
|
|
110 |
elems.add(elem2); |
|
111 |
|
|
112 |
pat.setElements(elems); |
|
113 |
|
|
114 |
XMLEntity xml = pat.getXMLEntity(); |
|
115 |
assertNotNull(xml); |
|
116 |
|
|
117 |
// pat2 |
|
118 |
NormalizationPattern pat2 = new NormalizationPattern(); |
|
119 |
pat2.setXMLEntity(xml); |
|
120 |
|
|
121 |
assertEquals(0, pat2.getNofirstrows()); |
|
122 |
|
|
123 |
assertEquals("pruebaParseXML.xml", pat2.getPatternname()); |
|
124 |
assertEquals(0, pat2.getNofirstrows()); |
|
125 |
|
|
126 |
Element elem0 = ((Element) pat.getElements().get(0)); |
|
127 |
|
|
128 |
assertEquals("campo1", elem0.getFieldname()); |
|
129 |
assertEquals(true, elem0.getImportfield()); |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/AllTests.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import junit.framework.Test; |
|
31 |
import junit.framework.TestSuite; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
36 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class AllTests { |
|
40 |
|
|
41 |
public static Test suite() { |
|
42 |
TestSuite suite = new TestSuite( |
|
43 |
"Test for org.gvsig.normalization.operations"); |
|
44 |
// $JUnit-BEGIN$ |
|
45 |
|
|
46 |
suite.addTestSuite(TestMarshall.class); |
|
47 |
suite.addTestSuite(TestFilterString.class); |
|
48 |
suite.addTestSuite(TestNormAlgorithm.class); |
|
49 |
|
|
50 |
// Norm Strings from file |
|
51 |
suite.addTestSuite(TestCreateNewPattern.class); |
|
52 |
|
|
53 |
|
|
54 |
// Norm Strings from file |
|
55 |
suite.addTestSuite(TestNormalizeStringsFromFile.class); |
|
56 |
suite.addTestSuite(TestAllTypeData.class); |
|
57 |
|
|
58 |
// Norm Strings from table |
|
59 |
suite.addTestSuite(TestNormalizeTableAlterTable.class); |
|
60 |
suite.addTestSuite(TestNormalizeTableJoinTable.class); |
|
61 |
|
|
62 |
// $JUnit-END$ |
|
63 |
return suite; |
|
64 |
} |
|
65 |
|
|
66 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestCreateNewPattern.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.text.DecimalFormatSymbols; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.List; |
|
33 |
import java.util.Locale; |
|
34 |
|
|
35 |
import junit.framework.TestCase; |
|
36 |
|
|
37 |
import org.gvsig.normalization.patterns.Decimalvalue; |
|
38 |
import org.gvsig.normalization.patterns.Element; |
|
39 |
import org.gvsig.normalization.patterns.Fieldseparator; |
|
40 |
import org.gvsig.normalization.patterns.Fieldtype; |
|
41 |
import org.gvsig.normalization.patterns.Infieldseparators; |
|
42 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
43 |
import org.gvsig.normalization.patterns.Stringvalue; |
|
44 |
|
|
45 |
/* |
|
46 |
* This test validates a new pattern generated |
|
47 |
* |
|
48 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
49 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
50 |
*/ |
|
51 |
public class TestCreateNewPattern extends TestCase { |
|
52 |
|
|
53 |
public void getUp() { |
|
54 |
} |
|
55 |
|
|
56 |
public void testCreateNewPattern() { |
|
57 |
// Create object |
|
58 |
NormalizationPattern pat = new NormalizationPattern(); |
|
59 |
|
|
60 |
// Field Separators |
|
61 |
Fieldseparator filsep1 = new Fieldseparator(); |
|
62 |
|
|
63 |
filsep1.setSemicolonsep(true); |
|
64 |
filsep1.setJoinsep(false); |
|
65 |
filsep1.setColonsep(false); |
|
66 |
filsep1.setSpacesep(false); |
|
67 |
filsep1.setTabsep(false); |
|
68 |
|
|
69 |
// Field Separators |
|
70 |
Fieldseparator filsep2 = new Fieldseparator(); |
|
71 |
|
|
72 |
filsep2.setSemicolonsep(true); |
|
73 |
filsep2.setJoinsep(false); |
|
74 |
filsep2.setColonsep(false); |
|
75 |
filsep2.setSpacesep(false); |
|
76 |
filsep2.setTabsep(false); |
|
77 |
|
|
78 |
// In Field Separators |
|
79 |
Locale loc = Locale.getDefault(); |
|
80 |
DecimalFormatSymbols dfs = new DecimalFormatSymbols(loc); |
|
81 |
Infieldseparators infilsep1 = new Infieldseparators(); |
|
82 |
|
|
83 |
infilsep1.setDecimalseparator(Character.toString(dfs |
|
84 |
.getDecimalSeparator())); |
|
85 |
infilsep1.setTextseparator("\""); |
|
86 |
infilsep1.setThousandseparator(Character.toString(dfs |
|
87 |
.getGroupingSeparator())); |
|
88 |
|
|
89 |
// In Field Separators |
|
90 |
|
|
91 |
Infieldseparators infilsep2 = new Infieldseparators(); |
|
92 |
|
|
93 |
infilsep2.setDecimalseparator(Character.toString(dfs |
|
94 |
.getDecimalSeparator())); |
|
95 |
infilsep2.setTextseparator("\""); |
|
96 |
infilsep2.setThousandseparator(Character.toString(dfs |
|
97 |
.getGroupingSeparator())); |
|
98 |
|
|
99 |
// Main attributes |
|
100 |
pat.setPatternname("thePattern"); |
|
101 |
pat.setNofirstrows(0); |
|
102 |
|
|
103 |
// Create the first Address Element //////////////////// |
|
104 |
List<Element> elems = new ArrayList<Element>(); |
|
105 |
Element elem1 = new Element(); |
|
106 |
|
|
107 |
// Field Name |
|
108 |
elem1.setFieldname("StringField"); |
|
109 |
|
|
110 |
elem1.setFieldseparator(filsep1); |
|
111 |
|
|
112 |
elem1.setInfieldseparators(infilsep1); |
|
113 |
|
|
114 |
// Field type |
|
115 |
Fieldtype newtype = new Fieldtype(); |
|
116 |
Stringvalue strval = new Stringvalue(); |
|
117 |
strval.setStringvaluewidth(50); |
|
118 |
newtype.setStringvalue(strval); |
|
119 |
|
|
120 |
elem1.setFieldtype(newtype); |
|
121 |
elem1.setFieldwidth(0); |
|
122 |
elem1.setImportfield(true); |
|
123 |
|
|
124 |
elems.add(elem1); |
|
125 |
|
|
126 |
// Create the second Address Element //////////////////// |
|
127 |
|
|
128 |
Element elem2 = new Element(); |
|
129 |
|
|
130 |
// Field Name |
|
131 |
elem2.setFieldname("DecimalField"); |
|
132 |
|
|
133 |
elem2.setFieldseparator(filsep2); |
|
134 |
|
|
135 |
elem2.setInfieldseparators(infilsep2); |
|
136 |
|
|
137 |
// Field type |
|
138 |
Fieldtype newtype2 = new Fieldtype(); |
|
139 |
Decimalvalue decval = new Decimalvalue(); |
|
140 |
decval.setDecimalvalueint(5); |
|
141 |
decval.setDecimalvaluedec(5); |
|
142 |
newtype2.setDecimalvalue(decval); |
|
143 |
|
|
144 |
elem2.setFieldtype(newtype2); |
|
145 |
elem2.setFieldwidth(0); |
|
146 |
elem2.setImportfield(true); |
|
147 |
|
|
148 |
elems.add(elem2); |
|
149 |
|
|
150 |
pat.setElements(elems); |
|
151 |
System.out.println("load pattern"); |
|
152 |
|
|
153 |
assertNotNull(pat); |
|
154 |
assertNotNull(elem1); |
|
155 |
assertNotNull(elem2); |
|
156 |
assertEquals(((Element) pat.getElements().get(0)).getImportfield(), |
|
157 |
true); |
|
158 |
assertEquals(((Element) pat.getElements().get(0)).getFieldwidth(), 0); |
|
159 |
assertEquals(((Stringvalue) ((Element) pat.getElements().get(0)) |
|
160 |
.getFieldtype().getStringvalue()).getStringvaluewidth(), 50); |
|
161 |
assertEquals(((Element) pat.getElements().get(0)).getFieldseparator() |
|
162 |
.getSemicolonsep(), true); |
|
163 |
assertEquals(((Element) pat.getElements().get(1)).getImportfield(), |
|
164 |
true); |
|
165 |
assertEquals(((Element) pat.getElements().get(1)).getFieldwidth(), 0); |
|
166 |
assertEquals(((Element) pat.getElements().get(1)).getFieldtype() |
|
167 |
.getDecimalvalue().getDecimalvaluedec(), 5); |
|
168 |
assertEquals(((Element) pat.getElements().get(1)).getFieldseparator() |
|
169 |
.getSemicolonsep(), true); |
|
170 |
|
|
171 |
} |
|
172 |
|
|
173 |
public void tearDown() { |
|
174 |
} |
|
175 |
|
|
176 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestFilterString.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L vsanjaime programador |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.FileNotFoundException; |
|
32 |
import java.io.IOException; |
|
33 |
import java.io.UnsupportedEncodingException; |
|
34 |
import java.util.ArrayList; |
|
35 |
|
|
36 |
import junit.framework.TestCase; |
|
37 |
|
|
38 |
import org.apache.log4j.Logger; |
|
39 |
import org.exolab.castor.xml.MarshalException; |
|
40 |
import org.exolab.castor.xml.ValidationException; |
|
41 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
42 |
|
|
43 |
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver; |
|
44 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
45 |
|
|
46 |
/** |
|
47 |
* |
|
48 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
49 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicent Sanjaime Calvet</a> |
|
50 |
* |
|
51 |
*/ |
|
52 |
public class TestFilterString extends TestCase { |
|
53 |
|
|
54 |
private static final Logger log = Logger.getLogger(TestFilterString.class); |
|
55 |
|
|
56 |
public void testFilterString() throws MarshalException, |
|
57 |
FileNotFoundException, UnsupportedEncodingException, |
|
58 |
ValidationException, XMLException { |
|
59 |
|
|
60 |
log.info("TestFilterString: start the test"); |
|
61 |
|
|
62 |
ArrayList<String> chains = new ArrayList<String>(); |
|
63 |
chains.add(",XXX;9393;33.25;337.22;1/1/8"); |
|
64 |
|
|
65 |
File fPat = new File( |
|
66 |
"./src-test/org/gvsig/normalization/testdata/PATNORM_TEST.xml"); |
|
67 |
|
|
68 |
assertNotNull(fPat); |
|
69 |
|
|
70 |
NormalizationPattern pat = parserPat(fPat); |
|
71 |
assertNotNull(pat); |
|
72 |
|
|
73 |
File outputFile = null; |
|
74 |
try { |
|
75 |
outputFile = File.createTempFile("filters", ".dbf"); |
|
76 |
} catch (IOException e1) { |
|
77 |
e1.printStackTrace(); |
|
78 |
} |
|
79 |
|
|
80 |
// Normalization |
|
81 |
StringListNormalization norm = new StringListNormalization(pat, chains, |
|
82 |
outputFile); |
|
83 |
|
|
84 |
norm.preProcess(); |
|
85 |
for (int i = 0; i < chains.size(); i++) { |
|
86 |
try { |
|
87 |
norm.fillRow(i); |
|
88 |
} catch (Exception e) { |
|
89 |
e.printStackTrace(); |
|
90 |
} |
|
91 |
} |
|
92 |
norm.postProcess(); |
|
93 |
|
|
94 |
DBFDriver test = new DBFDriver(); |
|
95 |
int nFields = -1; |
|
96 |
long nRows = -1; |
|
97 |
String val00 = null; |
|
98 |
String val01 = null; |
|
99 |
String val02 = null; |
|
100 |
String val03 = null; |
|
101 |
String val04 = null; |
|
102 |
String val05 = null; |
|
103 |
|
|
104 |
try { |
|
105 |
test.open(outputFile); |
|
106 |
nFields = test.getFieldCount(); |
|
107 |
nRows = test.getRowCount(); |
|
108 |
val00 = test.getFieldValue(0, 0).toString().trim(); |
|
109 |
val01 = test.getFieldValue(0, 1).toString().trim(); |
|
110 |
val02 = test.getFieldValue(0, 2).toString().trim(); |
|
111 |
val03 = test.getFieldValue(0, 3).toString().trim(); |
|
112 |
val04 = test.getFieldValue(0, 4).toString().trim(); |
|
113 |
val05 = test.getFieldValue(0, 5).toString().trim(); |
|
114 |
|
|
115 |
test.close(); |
|
116 |
} catch (Exception e) { |
|
117 |
e.printStackTrace(); |
|
118 |
} |
|
119 |
|
|
120 |
assertEquals(nFields, 6); |
|
121 |
assertEquals(nRows, 1); |
|
122 |
|
|
123 |
assertEquals(val00, ""); |
|
124 |
assertEquals(val01, "XXX"); |
|
125 |
assertEquals(val02, "9393"); |
|
126 |
assertEquals(val03, "0.0"); |
|
127 |
assertEquals(val04, "337.22"); |
|
128 |
assertEquals(val05, "01-ene-0008"); |
|
129 |
|
|
130 |
log.info("TestFilterString: test finished"); |
|
131 |
} |
|
132 |
|
|
133 |
private NormalizationPattern parserPat(File f) throws MarshalException, |
|
134 |
FileNotFoundException, UnsupportedEncodingException, |
|
135 |
ValidationException, XMLException { |
|
136 |
NormalizationPattern pat = new NormalizationPattern(); |
|
137 |
pat.loadFromXML(f); |
|
138 |
return pat; |
|
139 |
} |
|
140 |
|
|
141 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestNormalizeStringsFromFile.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
32 |
import java.util.ArrayList; |
|
33 |
|
|
34 |
import junit.framework.TestCase; |
|
35 |
|
|
36 |
import org.apache.log4j.Logger; |
|
37 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
38 |
|
|
39 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
40 |
import com.iver.andami.PluginServices; |
|
41 |
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
45 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
46 |
*/ |
|
47 |
|
|
48 |
public class TestNormalizeStringsFromFile extends TestCase { |
|
49 |
|
|
50 |
private static final Logger log = PluginServices.getLogger(); |
|
51 |
NormalizationPattern pat = new NormalizationPattern(); |
|
52 |
ArrayList<String> chains = new ArrayList<String>(); |
|
53 |
File file; |
|
54 |
DBFDriver test = null; |
|
55 |
|
|
56 |
public void setUp() { |
|
57 |
|
|
58 |
File f = new File( |
|
59 |
"./src-test/org/gvsig/normalization/operations/testdata/normFile.xml"); |
|
60 |
try { |
|
61 |
pat.loadFromXML(f); |
|
62 |
} catch (Exception e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} |
|
65 |
|
|
66 |
chains.add("TEST1;TEST2;TEST3"); |
|
67 |
chains.add("TEST4;TEST5;TEST6"); |
|
68 |
chains.add("TEST7;TEST8;TEST9"); |
|
69 |
} |
|
70 |
|
|
71 |
public void testNormalizeStringsFromFile() { |
|
72 |
|
|
73 |
try { |
|
74 |
file = File.createTempFile("temp", ".dbf"); |
|
75 |
|
|
76 |
StringListNormalization norm = new StringListNormalization(pat, |
|
77 |
chains, file); |
|
78 |
norm.preProcess(); |
|
79 |
for (int i = 0; i < chains.size(); i++) { |
|
80 |
try { |
|
81 |
norm.fillRow(i); |
|
82 |
} catch (Exception e) { |
|
83 |
e.printStackTrace(); |
|
84 |
} |
|
85 |
} |
|
86 |
norm.postProcess(); |
|
87 |
|
|
88 |
// Asserts |
|
89 |
test = new DBFDriver(); |
|
90 |
int nFields = -1; |
|
91 |
long nRows = -1; |
|
92 |
String val00 = null; |
|
93 |
String val01 = null; |
|
94 |
String val10 = null; |
|
95 |
String val11 = null; |
|
96 |
try { |
|
97 |
test.open(file); |
|
98 |
nFields = test.getFieldCount(); |
|
99 |
nRows = test.getRowCount(); |
|
100 |
val00 = test.getFieldValue(0, 0).toString().trim(); |
|
101 |
val01 = test.getFieldValue(0, 1).toString().trim(); |
|
102 |
val10 = test.getFieldValue(1, 0).toString().trim(); |
|
103 |
val11 = test.getFieldValue(1, 1).toString().trim(); |
|
104 |
test.close(); |
|
105 |
} catch (Exception e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} |
|
108 |
|
|
109 |
assertEquals(nFields, 2); |
|
110 |
assertEquals(nRows, 3); |
|
111 |
|
|
112 |
assertEquals(val00, "TEST1"); |
|
113 |
assertEquals(val10, "TEST4"); |
|
114 |
assertEquals(val01, "TEST2;TEST3"); |
|
115 |
assertEquals(val11, "TEST5;TEST6"); |
|
116 |
|
|
117 |
file.delete(); |
|
118 |
|
|
119 |
} catch (IOException e1) { |
|
120 |
log.error("Creating the temp file", e1); |
|
121 |
} |
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
public void tearDown() { |
|
126 |
try { |
|
127 |
test.close(); |
|
128 |
log.info("TEST FINISHED"); |
|
129 |
} catch (CloseDriverException e) { |
|
130 |
log.error("Clossing the driver"); |
|
131 |
e.printStackTrace(); |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestNormalizeTableJoinTable.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L. main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
32 |
|
|
33 |
import junit.framework.TestCase; |
|
34 |
|
|
35 |
import org.apache.log4j.Logger; |
|
36 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
37 |
|
|
38 |
import com.hardcode.gdbms.driver.exceptions.CloseDriverException; |
|
39 |
import com.hardcode.gdbms.engine.data.file.FileDataSource; |
|
40 |
import com.hardcode.gdbms.engine.data.file.FileDataSourceFactory; |
|
41 |
import com.hardcode.gdbms.engine.data.file.FileSourceInfo; |
|
42 |
import com.iver.andami.PluginServices; |
|
43 |
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver; |
|
44 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
|
45 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
50 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
51 |
* |
|
52 |
*/ |
|
53 |
public class TestNormalizeTableJoinTable extends TestCase { |
|
54 |
|
|
55 |
private static final Logger log = PluginServices.getLogger(); |
|
56 |
NormalizationPattern pat = new NormalizationPattern(); |
|
57 |
File dbfFile = new File( |
|
58 |
"src-test/org/gvsig/normalization/operations/testdata/pro.dbf"); |
|
59 |
File patFile = new File( |
|
60 |
"src-test/org/gvsig/normalization/operations/testdata/normAlterTable.xml"); |
|
61 |
File outputFile; |
|
62 |
EditableAdapter source = new EditableAdapter(); |
|
63 |
String[] joinNames = { "PROVINCIA", "COUNT" }; |
|
64 |
DBFDriver test = null; |
|
65 |
|
|
66 |
public void setUp() { |
|
67 |
|
|
68 |
try { |
|
69 |
pat.loadFromXML(patFile); |
|
70 |
} catch (Exception e) { |
|
71 |
log.error("Error parsing the xml pattern", e); |
|
72 |
} |
|
73 |
|
|
74 |
try { |
|
75 |
test = new DBFDriver(); |
|
76 |
test.open(dbfFile); |
|
77 |
|
|
78 |
FileDataSource fildas = FileDataSourceFactory.newInstance(); |
|
79 |
fildas.setDriver(test); |
|
80 |
String path = dbfFile.getAbsolutePath(); |
|
81 |
String na = dbfFile.getName(); |
|
82 |
FileSourceInfo fsi = new FileSourceInfo(); |
|
83 |
fsi.file = path; |
|
84 |
fsi.name = na; |
|
85 |
fildas.setSourceInfo(fsi); |
|
86 |
|
|
87 |
SelectableDataSource sds = new SelectableDataSource(fildas); |
|
88 |
|
|
89 |
source.setOriginalDataSource(sds); |
|
90 |
|
|
91 |
} catch (Exception e) { |
|
92 |
log.error("Reading the driver", e); |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
public void testNormalizeTableJoinTable() { |
|
98 |
|
|
99 |
try { |
|
100 |
outputFile = File.createTempFile("jointable", ".dbf"); |
|
101 |
|
|
102 |
JoinedTableNormalization norm = new JoinedTableNormalization( |
|
103 |
source, 5, pat, joinNames, outputFile); |
|
104 |
norm.preProcess(); |
|
105 |
try { |
|
106 |
for (int i = 0; i < source.getRowCount(); i++) { |
|
107 |
|
|
108 |
norm.fillRow(i); |
|
109 |
|
|
110 |
} |
|
111 |
} catch (Exception e) { |
|
112 |
log.error("Normalizing", e); |
|
113 |
} |
|
114 |
norm.postProcess(); |
|
115 |
|
|
116 |
// asserts |
|
117 |
|
|
118 |
DBFDriver test = new DBFDriver(); |
|
119 |
int nFields = -1; |
|
120 |
long nRows = -1; |
|
121 |
String val02 = null; |
|
122 |
String val03 = null; |
|
123 |
String val04 = null; |
|
124 |
String val05 = null; |
|
125 |
String val06 = null; |
|
126 |
String val12 = null; |
|
127 |
String val15 = null; |
|
128 |
String val26 = null; |
|
129 |
|
|
130 |
try { |
|
131 |
test.open(outputFile); |
|
132 |
nFields = test.getFieldCount(); |
|
133 |
nRows = test.getRowCount(); |
|
134 |
val02 = test.getFieldValue(0, 2).toString().trim(); |
|
135 |
val03 = test.getFieldValue(0, 3).toString().trim(); |
|
136 |
val04 = test.getFieldValue(0, 4).toString().trim(); |
|
137 |
val05 = test.getFieldValue(0, 5).toString().trim(); |
|
138 |
val06 = test.getFieldValue(0, 6).toString().trim(); |
|
139 |
val12 = test.getFieldValue(1, 2).toString().trim(); |
|
140 |
val15 = test.getFieldValue(1, 5).toString().trim(); |
|
141 |
val26 = test.getFieldValue(2, 6).toString().trim(); |
|
142 |
|
|
143 |
} catch (Exception e) { |
|
144 |
e.printStackTrace(); |
|
145 |
} |
|
146 |
|
|
147 |
assertEquals(nFields, 7); |
|
148 |
assertEquals(nRows, 3); |
|
149 |
|
|
150 |
assertEquals(val02, "23030"); |
|
151 |
assertEquals(val03, "697096"); |
|
152 |
assertEquals(val04, "4364444"); |
|
153 |
assertEquals(val05, "35.5"); |
|
154 |
assertEquals(val06, "01/07/2007"); |
|
155 |
|
|
156 |
assertEquals(val12, "23030"); |
|
157 |
assertEquals(val15, "100.8"); |
|
158 |
|
|
159 |
assertEquals(val26, "12/11/2006"); |
|
160 |
|
|
161 |
outputFile.delete(); |
|
162 |
|
|
163 |
} catch (IOException e1) { |
|
164 |
log.error("Creating the temp file", e1); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
public void tearDown() { |
|
169 |
try { |
|
170 |
test.close(); |
|
171 |
log.info("TEST FINISHED"); |
|
172 |
} catch (CloseDriverException e) { |
|
173 |
log.error("Clossing the driver", e); |
|
174 |
} |
|
175 |
} |
|
176 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestNormAlgorithm.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.FileNotFoundException; |
|
32 |
import java.io.UnsupportedEncodingException; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import junit.framework.TestCase; |
|
36 |
|
|
37 |
import org.apache.log4j.Logger; |
|
38 |
import org.exolab.castor.xml.MarshalException; |
|
39 |
import org.exolab.castor.xml.ValidationException; |
|
40 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
41 |
|
|
42 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
43 |
|
|
44 |
public class TestNormAlgorithm extends TestCase { |
|
45 |
|
|
46 |
private static final Logger log = Logger.getLogger(TestNormAlgorithm.class); |
|
47 |
|
|
48 |
public void setUp() { |
|
49 |
} |
|
50 |
|
|
51 |
public void testSplitChain() throws MarshalException, FileNotFoundException, UnsupportedEncodingException, ValidationException, XMLException { |
|
52 |
|
|
53 |
log.info("TestNormAlgorithm. Test splits strings"); |
|
54 |
|
|
55 |
log.info("SubTest 1"); |
|
56 |
String c1 = ";aaa,,bbb;;;ccc/ddd@eee##;"; |
|
57 |
|
|
58 |
File f1 = new File( |
|
59 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain.xml"); |
|
60 |
assertNotNull(f1); |
|
61 |
|
|
62 |
List<String> r1 = parser(f1, c1); |
|
63 |
assertNotNull(r1); |
|
64 |
|
|
65 |
assertEquals("", (String) r1.get(0)); |
|
66 |
assertEquals("aaa", (String) r1.get(1)); |
|
67 |
assertEquals("", (String) r1.get(2)); |
|
68 |
assertEquals("bbb", (String) r1.get(3)); |
|
69 |
assertEquals("", (String) r1.get(4)); |
|
70 |
assertEquals("", (String) r1.get(5)); |
|
71 |
assertEquals("ccc", (String) r1.get(6)); |
|
72 |
assertEquals("ddd", (String) r1.get(7)); |
|
73 |
assertEquals("eee", (String) r1.get(8)); |
|
74 |
assertEquals("", (String) r1.get(9)); |
|
75 |
assertEquals(";", (String) r1.get(10)); |
|
76 |
|
|
77 |
log.info("SubTest 2."); |
|
78 |
String c2 = "aaa bbb ccc ddd,76 %"; |
|
79 |
|
|
80 |
File f2 = new File( |
|
81 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain2.xml"); |
|
82 |
assertNotNull(f2); |
|
83 |
|
|
84 |
List<String> r2 = parser(f2, c2); |
|
85 |
assertNotNull(r2); |
|
86 |
|
|
87 |
assertEquals("aaa", (String) r2.get(0)); |
|
88 |
assertEquals("bbb", (String) r2.get(1)); |
|
89 |
assertEquals("ccc", (String) r2.get(2)); |
|
90 |
assertEquals("ddd", (String) r2.get(3)); |
|
91 |
assertEquals("76", (String) r2.get(4)); |
|
92 |
assertEquals("%", (String) r2.get(5)); |
|
93 |
|
|
94 |
log.info("SubTest 3."); |
|
95 |
String c3 = "Av;Germanias;25;3;Moncada;Valencia"; |
|
96 |
|
|
97 |
File f3 = new File( |
|
98 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain3.xml"); |
|
99 |
assertNotNull(f3); |
|
100 |
|
|
101 |
List<String> r3 = parser(f3, c3); |
|
102 |
assertNotNull(r3); |
|
103 |
|
|
104 |
assertEquals("Av", (String) r3.get(0)); |
|
105 |
assertEquals("Germanias", (String) r3.get(1)); |
|
106 |
assertEquals(25, Integer.parseInt((String) r3.get(2))); |
|
107 |
assertEquals(3, Integer.parseInt((String) r3.get(3))); |
|
108 |
assertEquals("Moncada", (String) r3.get(4)); |
|
109 |
assertEquals("Valencia", (String) r3.get(5)); |
|
110 |
|
|
111 |
log.info("SubTest 4."); |
|
112 |
String c4 = "Av. Germanias 15 2 Moncada Valencia "; |
|
113 |
|
|
114 |
File f4 = new File( |
|
115 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain4.xml"); |
|
116 |
assertNotNull(f4); |
|
117 |
|
|
118 |
List<String> r4 = parser(f4, c4); |
|
119 |
assertNotNull(r4); |
|
120 |
|
|
121 |
assertEquals("Av.", ((String) r4.get(0)).trim()); |
|
122 |
assertEquals("Germanias", ((String) r4.get(1)).trim()); |
|
123 |
assertEquals(15, Integer.parseInt(((String) r4.get(2)).trim())); |
|
124 |
assertEquals(2, Integer.parseInt(((String) r4.get(3)).trim())); |
|
125 |
assertEquals("Moncada", ((String) r4.get(4)).trim()); |
|
126 |
assertEquals("Valencia", ((String) r4.get(5)).trim()); |
|
127 |
|
|
128 |
log.info("SubTest 5."); |
|
129 |
String c5 = "Av;;Germanias;15;;2;Moncada;Valencia"; |
|
130 |
|
|
131 |
File f5 = new File( |
|
132 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain5.xml"); |
|
133 |
assertNotNull(f5); |
|
134 |
|
|
135 |
List<String> r5 = parser(f5, c5); |
|
136 |
assertNotNull(r5); |
|
137 |
|
|
138 |
assertEquals("Av", (String) r5.get(0)); |
|
139 |
assertEquals("Germanias", (String) r5.get(1)); |
|
140 |
assertEquals(15, Integer.parseInt((String) r5.get(2))); |
|
141 |
assertEquals(2, Integer.parseInt((String) r5.get(3))); |
|
142 |
assertEquals("Moncada", (String) r5.get(4)); |
|
143 |
assertEquals("Valencia", (String) r5.get(5)); |
|
144 |
|
|
145 |
log.info("SubTest 6."); |
|
146 |
String c6 = "Av. Germanias 15-2 Moncada (Valencia)"; |
|
147 |
|
|
148 |
File f6 = new File( |
|
149 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain6.xml"); |
|
150 |
assertNotNull(f6); |
|
151 |
|
|
152 |
List<String> r6 = parser(f6, c6); |
|
153 |
assertNotNull(r6); |
|
154 |
|
|
155 |
assertEquals("Av.", ((String) r6.get(0)).trim()); |
|
156 |
assertEquals("Germanias", ((String) r6.get(1)).trim()); |
|
157 |
assertEquals(15, Integer.parseInt(((String) r6.get(2)).trim())); |
|
158 |
assertEquals(2, Integer.parseInt(((String) r6.get(3)).trim())); |
|
159 |
assertEquals("Moncada", ((String) r6.get(4)).trim()); |
|
160 |
assertEquals("Valencia", ((String) r6.get(5)).trim()); |
|
161 |
|
|
162 |
log.info("SubTest 7."); |
|
163 |
String c7 = "Juana Aguirre;Piedras;No 623;Piso2;Dto.4;C1070AAM;Capital Federal;ARGENTINA"; |
|
164 |
|
|
165 |
File f7 = new File( |
|
166 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain7.xml"); |
|
167 |
assertNotNull(f7); |
|
168 |
|
|
169 |
List<String> r7 = parser(f7, c7); |
|
170 |
assertNotNull(r7); |
|
171 |
|
|
172 |
assertEquals("Juana Aguirre", ((String) r7.get(0)).trim()); |
|
173 |
assertEquals("Piedras", ((String) r7.get(1)).trim()); |
|
174 |
assertEquals("No 623", ((String) r7.get(2)).trim()); |
|
175 |
assertEquals("Piso2", ((String) r7.get(3)).trim()); |
|
176 |
assertEquals("Dto.4", ((String) r7.get(4)).trim()); |
|
177 |
assertEquals("C1070AAM", ((String) r7.get(5)).trim()); |
|
178 |
assertEquals("Capital Federal", ((String) r7.get(6)).trim()); |
|
179 |
assertEquals("ARGENTINA", ((String) r7.get(7)).trim()); |
|
180 |
|
|
181 |
log.info("SubTest 8."); |
|
182 |
String c8 = "5.548\t5478.254\t0.24578457\t256.21450045"; |
|
183 |
|
|
184 |
File f8 = new File( |
|
185 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain8.xml"); |
|
186 |
assertNotNull(f8); |
|
187 |
|
|
188 |
List<String> r8 = parser(f8, c8); |
|
189 |
assertNotNull(r8); |
|
190 |
|
|
191 |
assertEquals(5.548, Double.parseDouble(((String) r8.get(0)).trim())); |
|
192 |
assertEquals(5478.254, Double.parseDouble(((String) r8.get(1)).trim())); |
|
193 |
assertEquals(0.24578457, Double |
|
194 |
.parseDouble(((String) r8.get(2)).trim())); |
|
195 |
assertEquals(256.21450045, Double.parseDouble(((String) r8.get(3)) |
|
196 |
.trim())); |
|
197 |
|
|
198 |
log.info("TestNormAlgorithm. Test finished"); |
|
199 |
} |
|
200 |
|
|
201 |
public void testSplitFixed() { |
|
202 |
|
|
203 |
log.info("TestNormAlgorithm. Test tokens fixed"); |
|
204 |
|
|
205 |
String chain = "esto;/es;;; una_prueba; de un/ split de una cadena_de texto"; |
|
206 |
|
|
207 |
int parts = 4; |
|
208 |
boolean join = true; |
|
209 |
String[] separators = { " " }; |
|
210 |
List<String> result = NormAlgorithm.splitChainBySeparators(chain, |
|
211 |
parts, separators, join); |
|
212 |
log.info("Cadena inicial: " + chain); |
|
213 |
for (int i = 0; i < result.size(); i++) { |
|
214 |
log.info("Subcadena" + i + ": " + (String) result.get(i)); |
|
215 |
} |
|
216 |
assertEquals("esto;/es;;;", result.get(0)); |
|
217 |
assertEquals("una_prueba;", result.get(1)); |
|
218 |
assertEquals("de", result.get(2)); |
|
219 |
assertEquals("un/ split de una cadena_de texto", result.get(3)); |
|
220 |
|
|
221 |
log.info("TestNormAlgorithm. Test tokens fixed finished"); |
|
222 |
|
|
223 |
} |
|
224 |
|
|
225 |
public void testSplitSeparators() { |
|
226 |
|
|
227 |
log.info("TestNormAlgorithm. Test tokens with separators"); |
|
228 |
|
|
229 |
String chain = "esto;/es;;; una_prueba; de un/ split de una cadena_de texto"; |
|
230 |
|
|
231 |
int parts = 4; |
|
232 |
boolean join = true; |
|
233 |
String[] separators = { " " }; |
|
234 |
List<String> result = NormAlgorithm.splitChainBySeparators(chain, |
|
235 |
parts, separators, join); |
|
236 |
System.out.println("Cadena inicial: " + chain); |
|
237 |
for (int i = 0; i < result.size(); i++) { |
|
238 |
System.out.println("Subcadena" + i + ": " + (String) result.get(i)); |
|
239 |
} |
|
240 |
assertEquals("esto;/es;;;", result.get(0)); |
|
241 |
assertEquals("una_prueba;", result.get(1)); |
|
242 |
assertEquals("de", result.get(2)); |
|
243 |
assertEquals("un/ split de una cadena_de texto", result.get(3)); |
|
244 |
|
|
245 |
log.info("TestNormAlgorithm. Test tokens with separators finished"); |
|
246 |
|
|
247 |
} |
|
248 |
|
|
249 |
private List<String> parser(File f, String chain) throws MarshalException, FileNotFoundException, UnsupportedEncodingException, ValidationException, XMLException { |
|
250 |
NormalizationPattern pat = new NormalizationPattern(); |
|
251 |
pat.loadFromXML(f); |
|
252 |
NormAlgorithm na = new NormAlgorithm(pat); |
|
253 |
|
|
254 |
List<String> result = na.splitChain(chain); |
|
255 |
return result; |
|
256 |
|
|
257 |
} |
|
258 |
|
|
259 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestMarshall.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L main developer |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.FileNotFoundException; |
|
32 |
import java.io.IOException; |
|
33 |
import java.io.UnsupportedEncodingException; |
|
34 |
|
|
35 |
import junit.framework.TestCase; |
|
36 |
|
|
37 |
import org.apache.log4j.Logger; |
|
38 |
import org.exolab.castor.xml.MarshalException; |
|
39 |
import org.exolab.castor.xml.ValidationException; |
|
40 |
import org.gvsig.normalization.patterns.Element; |
|
41 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
42 |
|
|
43 |
import com.iver.andami.PluginServices; |
|
44 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
45 |
|
|
46 |
public class TestMarshall extends TestCase { |
|
47 |
|
|
48 |
private static final Logger log = PluginServices.getLogger(); |
|
49 |
|
|
50 |
public void testMarshallUnmarshall() throws MarshalException, |
|
51 |
ValidationException, XMLException, IOException { |
|
52 |
|
|
53 |
log.info("testMarshallUnmarshall. start test"); |
|
54 |
NormalizationPattern pat = new NormalizationPattern(); |
|
55 |
NormalizationPattern pat3 = new NormalizationPattern(); |
|
56 |
File file = new File( |
|
57 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain.xml"); |
|
58 |
|
|
59 |
// PARSER |
|
60 |
|
|
61 |
pat.loadFromXML(file); |
|
62 |
|
|
63 |
assertEquals(11, pat.getElements().size()); |
|
64 |
assertEquals(0, pat.getNofirstrows()); |
|
65 |
|
|
66 |
Element elem1 = (Element) pat.getElements().get(0); |
|
67 |
|
|
68 |
assertNotNull(elem1); |
|
69 |
assertEquals("NewField", elem1.getFieldname()); |
|
70 |
|
|
71 |
// SERIALIZER |
|
72 |
File ftemp = File.createTempFile("temp", "txt"); |
|
73 |
pat.saveToXML(ftemp); |
|
74 |
|
|
75 |
// PARSER |
|
76 |
|
|
77 |
assertNotNull(ftemp); |
|
78 |
|
|
79 |
pat3.loadFromXML(ftemp); |
|
80 |
|
|
81 |
Element elem2 = (Element) pat3.getElements().get(0); |
|
82 |
|
|
83 |
assertNotNull(elem2); |
|
84 |
|
|
85 |
assertEquals(elem1.getImportfield(), elem2.getImportfield()); |
|
86 |
assertEquals(elem1.getFieldwidth(), elem2.getFieldwidth()); |
|
87 |
assertEquals(elem1.getFieldname(), elem2.getFieldname()); |
|
88 |
assertEquals(elem1.getInfieldseparators().getDecimalseparator(), elem2 |
|
89 |
.getInfieldseparators().getDecimalseparator()); |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
public void testUnmarshall() throws MarshalException, |
|
94 |
FileNotFoundException, UnsupportedEncodingException, |
|
95 |
ValidationException, XMLException { |
|
96 |
|
|
97 |
log.info("testUnmarshall. start test"); |
|
98 |
File file = new File( |
|
99 |
"src-test/org/gvsig/normalization/operations/testdata/patSplitChain.xml"); |
|
100 |
// Marshal the person object |
|
101 |
NormalizationPattern pat = new NormalizationPattern(); |
|
102 |
pat.loadFromXML(file); |
|
103 |
|
|
104 |
log.info("pattern loaded"); |
|
105 |
// results |
|
106 |
assertEquals(11, pat.getElements().size()); |
|
107 |
assertEquals(0, ((Element) pat.getElements().get(3)).getFieldwidth()); |
|
108 |
assertEquals(true, ((Element) pat.getElements().get(2)) |
|
109 |
.getImportfield()); |
|
110 |
assertEquals(true, ((Element) pat.getElements().get(4)) |
|
111 |
.getFieldseparator().getSemicolonsep()); |
|
112 |
|
|
113 |
log.info("testMarshallUnmarshall. test finished"); |
|
114 |
} |
|
115 |
|
|
116 |
} |
tags/normalization_build105_gvsig1.10/libGeocoding/libGeocoding/src-test/org/gvsig/normalization/operations/TestAllTypeData.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L vsanjaime programador |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.normalization.operations; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
32 |
import java.util.ArrayList; |
|
33 |
|
|
34 |
import junit.framework.TestCase; |
|
35 |
|
|
36 |
import org.apache.log4j.Logger; |
|
37 |
import org.gvsig.normalization.patterns.NormalizationPattern; |
|
38 |
|
|
39 |
import com.iver.andami.PluginServices; |
|
40 |
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver; |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
45 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class TestAllTypeData extends TestCase { |
|
49 |
|
|
50 |
private static final Logger log = PluginServices.getLogger(); |
|
51 |
NormalizationPattern pat = new NormalizationPattern(); |
|
52 |
ArrayList<String> chains = new ArrayList<String>(); |
|
53 |
File file; |
|
54 |
|
|
55 |
public void setUp() { |
|
56 |
File f = new File( |
|
57 |
"src-test/org/gvsig/normalization/operations/testdata/pattotal.xml"); |
|
58 |
try { |
|
59 |
pat.loadFromXML(f); |
|
60 |
} catch (Exception e) { |
|
61 |
e.printStackTrace(); |
|
62 |
} |
|
63 |
|
|
64 |
chains.add("Javier#-7;-0.2578&01/10/2007&02/09&02-78"); |
|
65 |
chains.add("Javier#-7;-0.2578&01/10/2007&02/09&02-78"); |
|
66 |
chains.add("v"); |
|
67 |
chains.add(""); |
|
68 |
chains.add("Javier#-7;-0.2578&01/10/2007&02/09&02-78"); |
|
69 |
chains.add("Javier#-7;-0.2578&01/10/2007&02/09&02-78"); |
|
70 |
} |
|
71 |
|
|
72 |
public void testAllTypeData() { |
|
73 |
|
|
74 |
try { |
|
75 |
file = File.createTempFile("alltype", ".dbf"); |
|
76 |
|
|
77 |
StringListNormalization norm = new StringListNormalization(pat, |
|
78 |
chains, file); |
|
79 |
norm.preProcess(); |
|
80 |
for (int i = 0; i < chains.size(); i++) { |
|
81 |
try { |
|
82 |
norm.fillRow(i); |
|
83 |
} catch (Exception e) { |
|
84 |
e.printStackTrace(); |
|
85 |
} |
|
86 |
} |
|
87 |
norm.postProcess(); |
|
88 |
|
|
89 |
DBFDriver test = new DBFDriver(); |
Also available in: Unified diff