svn-gvsig-desktop / trunk / extensions / extGPE-gvSIG / src-test / org / gvsig / fmap / drivers / gpe / reader / v2 / GPEParserTest.java @ 27067
History | View | Annotate | Download (4.36 KB)
1 |
package org.gvsig.fmap.drivers.gpe.reader.v2; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.FileNotFoundException; |
5 |
import java.io.IOException; |
6 |
|
7 |
import junit.framework.TestCase; |
8 |
|
9 |
import org.cresques.cts.IProjection; |
10 |
import org.gvsig.fmap.drivers.gpe.reader.GMLVectorialDriver; |
11 |
import org.gvsig.gpe.GPERegister; |
12 |
import org.gvsig.gpe.exceptions.ParserCreationException; |
13 |
import org.gvsig.gpe.parser.GPEParser; |
14 |
|
15 |
import com.iver.cit.gvsig.fmap.MapContext; |
16 |
import com.iver.cit.gvsig.fmap.MapControl; |
17 |
import com.iver.cit.gvsig.fmap.ViewPort; |
18 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
19 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
20 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
21 |
|
22 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
23 |
*
|
24 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
25 |
*
|
26 |
* This program is free software; you can redistribute it and/or
|
27 |
* modify it under the terms of the GNU General Public License
|
28 |
* as published by the Free Software Foundation; either version 2
|
29 |
* of the License, or (at your option) any later version.
|
30 |
*
|
31 |
* This program is distributed in the hope that it will be useful,
|
32 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
33 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
34 |
* GNU General Public License for more details.
|
35 |
*
|
36 |
* You should have received a copy of the GNU General Public License
|
37 |
* along with this program; if not, write to the Free Software
|
38 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
39 |
*
|
40 |
* For more information, contact:
|
41 |
*
|
42 |
* Generalitat Valenciana
|
43 |
* Conselleria d'Infraestructures i Transport
|
44 |
* Av. Blasco Ib??ez, 50
|
45 |
* 46010 VALENCIA
|
46 |
* SPAIN
|
47 |
*
|
48 |
* +34 963862235
|
49 |
* gvsig@gva.es
|
50 |
* www.gvsig.gva.es
|
51 |
*
|
52 |
* or
|
53 |
*
|
54 |
* IVER T.I. S.A
|
55 |
* Salamanca 50
|
56 |
* 46005 Valencia
|
57 |
* Spain
|
58 |
*
|
59 |
* +34 963163400
|
60 |
* dac@iver.es
|
61 |
*/
|
62 |
/* CVS MESSAGES:
|
63 |
*
|
64 |
* $Id$
|
65 |
* $Log$
|
66 |
*
|
67 |
*/
|
68 |
/**
|
69 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
70 |
*/
|
71 |
public abstract class GPEParserTest extends TestCase { |
72 |
private String gpeDriversFile = "config" + File.separatorChar + |
73 |
"parser.properties";
|
74 |
private MapControl mapControl = null; |
75 |
private GMLVectorialDriver driver = null; |
76 |
private FLyrVect layer = null; |
77 |
|
78 |
/*
|
79 |
* (non-Javadoc)
|
80 |
* @see junit.framework.TestCase#setUp()
|
81 |
*/
|
82 |
public void setUp() throws FileNotFoundException, IOException{ |
83 |
// LayerFactory.setDriversPath("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
84 |
// LayerFactory.setWritersPath("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
85 |
// System.out.println("****************READERS****************");
|
86 |
// for (int i=0 ; i<LayerFactory.getDM().getDriverNames().length ; i++){
|
87 |
// System.out.println(LayerFactory.getDM().getDriverNames()[i]);
|
88 |
// }
|
89 |
// System.out.println("****************WRITERS****************");
|
90 |
// for (int i=0 ; i<LayerFactory.getWM().getWriterNames().length ; i++){
|
91 |
// System.out.println(LayerFactory.getWM().getWriterNames()[i]);
|
92 |
// }
|
93 |
// System.out.println("*************** GPE register *************");
|
94 |
GPERegister.addParsersFile(new File(gpeDriversFile)); |
95 |
driver = new GMLVectorialDriver();
|
96 |
driver.open(new File(getFile())); |
97 |
} |
98 |
|
99 |
/*
|
100 |
* (non-Javadoc)
|
101 |
* @see junit.framework.TestCase#tearDown()
|
102 |
*/
|
103 |
public void tearDown(){ |
104 |
for (int i=0 ; i<getLayer().getNumErrors() ; i++){ |
105 |
System.out.println(getLayer().getError(i));
|
106 |
} |
107 |
assertEquals(getLayer().getNumErrors(),0);
|
108 |
|
109 |
} |
110 |
|
111 |
/**
|
112 |
* The test
|
113 |
* @throws Exception
|
114 |
*/
|
115 |
public void testParse() throws Exception{ |
116 |
IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
117 |
ViewPort vp = new ViewPort(proj);
|
118 |
MapContext mapContext = new MapContext(vp);
|
119 |
mapControl = new MapControl();
|
120 |
mapControl.setMapContext(mapContext); |
121 |
makeAsserts(); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* @return The GPE parser
|
126 |
* @throws GPEParserCreationException
|
127 |
*/
|
128 |
protected GPEParser getParser() throws ParserCreationException{ |
129 |
return GPERegister.createParser("GML"); |
130 |
} |
131 |
|
132 |
/**
|
133 |
* @return the file to load
|
134 |
*/
|
135 |
public abstract String getFile(); |
136 |
|
137 |
/**
|
138 |
* Make the asserts
|
139 |
* @throws Exception
|
140 |
*/
|
141 |
public abstract void makeAsserts() throws Exception; |
142 |
|
143 |
/**
|
144 |
* @return the MapControl
|
145 |
*/
|
146 |
public MapControl getMapControl() {
|
147 |
return mapControl;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* @return the parent layer
|
152 |
*/
|
153 |
public FLyrVect getLayer(){
|
154 |
if (layer == null){ |
155 |
layer = (FLyrVect)LayerFactory.createLayer("Test", driver, CRSFactory.getCRS("EPSG:23030")); |
156 |
} |
157 |
return layer;
|
158 |
} |
159 |
|
160 |
} |