Revision 18234
import/extWFST/libRemoteServices/.cvsignore | ||
---|---|---|
1 |
remote-clients.jar |
|
2 |
dist |
|
3 |
bin |
|
4 |
bin-test |
|
0 | 5 |
import/extWFST/libRemoteServices/build.xml | ||
---|---|---|
1 |
<project name="libRemoteServices" default="dist" basedir="."> |
|
2 |
<description> |
|
3 |
Genera el jar con RemoteClient y sus dependencias |
|
4 |
</description> |
|
5 |
<!-- set global properties for this build --> |
|
6 |
<property name="src" location="src" /> |
|
7 |
<property name="build" location="bin" /> |
|
8 |
<property name="src-test" location="test" /> |
|
9 |
<property name="build-test" location="bin-test" /> |
|
10 |
<property name="dist" location="dist" /> |
|
11 |
<property name="lib" location="lib" /> |
|
12 |
<property name="andamiJar" location="../_fwAndami/andami.jar" /> |
|
13 |
<property name="andamiLibs" location="../_fwAndami/lib" /> |
|
14 |
<property name="fmapLibs" location="../libFMap" /> |
|
15 |
<property name="jarName" value="remote-clients" /> |
|
16 |
<property name="targetDir" location="../libFMap/lib" /> |
|
17 |
<!--<property name="compile-classpath" value="${andamiJar}:${fmapLibs}/lib/driver-manager-1.0.jar:${andamiLibs}/lib/tempFileManager.jar:${lib}/kxml2.jar" />--> |
|
18 |
<import file="../binaries/ant/utilities.xml"/> |
|
19 |
|
|
20 |
<target name="init"> |
|
21 |
<!-- Create the time stamp --> |
|
22 |
<tstamp /> |
|
23 |
<echo> |
|
24 |
Compiling ${ant.project.name}...</echo> |
|
25 |
<!-- Create the build directory structure used by compile --> |
|
26 |
<mkdir dir="${build}" /> |
|
27 |
</target> |
|
28 |
|
|
29 |
<target name="dist" depends="init" description="generate the distribution"> |
|
30 |
<!-- Create the distribution directory --> |
|
31 |
<mkdir dir="${dist}" /> |
|
32 |
|
|
33 |
<!-- Put everything in ${build} into the cms-${DSTAMP}.jar file --> |
|
34 |
<jar jarfile="${dist}/${jarName}.jar" basedir="${build}" /> |
|
35 |
<jar jarfile="${dist}/${jarName}.jar" basedir="." includes="images/*.gif" update="true" /> |
|
36 |
|
|
37 |
<move todir="${targetDir}/"> |
|
38 |
<fileset dir="${dist}" includes="**/**" /> |
|
39 |
</move> |
|
40 |
<copy todir="${targetDir}/"> |
|
41 |
<fileset dir="${lib}" includes="*.jar" /> |
|
42 |
</copy> |
|
43 |
</target> |
|
44 |
|
|
45 |
<target name="batch-build" |
|
46 |
description="compile the sources, create the jar file" |
|
47 |
depends="init,compile,create-jar,move-to-fmap"> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="compile" description="compile the source"> |
|
51 |
<!-- Compile the Java code from ${src} to ${build} --> |
|
52 |
<mkdir dir="${build}" /> |
|
53 |
<loadEclipseClasspath project="${basedir}"/> |
|
54 |
<gvSIG-javac |
|
55 |
classpath="${eclipseClasspath}"/> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="move-to-fmap" description="Move jars and required libraries to fmap"> |
|
59 |
<copy todir="${targetDir}"> |
|
60 |
<fileset dir="./lib" includes="*.jar" /> |
|
61 |
</copy> |
|
62 |
<copy todir="."> |
|
63 |
<fileset dir="${dist}" includes="${jarName}.jar" /> |
|
64 |
</copy> |
|
65 |
<move todir="${targetDir}/"> |
|
66 |
<fileset dir="${dist}" includes="**/**" /> |
|
67 |
</move> |
|
68 |
</target> |
|
69 |
|
|
70 |
<target name="create-jar" description="Crea el jar de la aplicacion"> |
|
71 |
<mkdir dir="${dist}" /> |
|
72 |
<jar jarfile="${dist}/${jarName}.jar" basedir="${build}" /> |
|
73 |
<jar jarfile="${dist}/${jarName}.jar" basedir="." includes="images/*" update="true" /> |
|
74 |
</target> |
|
75 |
|
|
76 |
<target name="clean" description="clean up"> |
|
77 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
78 |
<delete dir="${build}" /> |
|
79 |
<delete dir="${dist}" /> |
|
80 |
</target> |
|
81 |
|
|
82 |
<target name="run-tests" depends="batch-build,compile-tests"> |
|
83 |
<antcall target="generic-run-tests"> |
|
84 |
<param name="TestSuite.Name" value="org.gvsig.remoteClient.AllTests"/> |
|
85 |
</antcall> |
|
86 |
</target> |
|
87 |
</project> |
|
88 |
|
|
0 | 89 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/taskplanning/retrieving/URLRetrieveTest.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.3 2006-05-16 17:10:27 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.2 2006/05/15 09:39:52 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.1 2006/05/12 07:45:49 jaume |
|
53 |
* some warnings removed |
|
54 |
* |
|
55 |
* Revision 1.1 2006/05/12 07:15:45 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
package org.gvsig.remoteClient.taskplanning.retrieving; |
|
61 |
|
|
62 |
import java.io.File; |
|
63 |
|
|
64 |
import junit.framework.TestCase; |
|
65 |
|
|
66 |
import org.gvsig.remoteClient.taskplanning.IQueue; |
|
67 |
import org.gvsig.remoteClient.taskplanning.IRunnableTask; |
|
68 |
/** |
|
69 |
* |
|
70 |
* @author jaume |
|
71 |
* |
|
72 |
*/ |
|
73 |
public class URLRetrieveTest extends TestCase { |
|
74 |
private final static String tempDirectoryPath = System.getProperty("java.io.tmpdir")+"tmp-andami"; |
|
75 |
IQueue queue; |
|
76 |
IRunnableTask task1, task2, task3, task4; |
|
77 |
boolean finished1, finished2, finished3, finished4; |
|
78 |
RetrieveListener listener1 = new RetrieveListener() { |
|
79 |
public void transferEventReceived(RetrieveEvent event) { |
|
80 |
int e = event.getType(); |
|
81 |
printMessage("listener1", event.getType()); |
|
82 |
if (e==RetrieveEvent.REQUEST_FINISHED || e == RetrieveEvent.REQUEST_FAILED || e == RetrieveEvent.REQUEST_CANCELLED ) |
|
83 |
finished1 = true; |
|
84 |
} |
|
85 |
}; |
|
86 |
|
|
87 |
String protocol = URLRequest.HTTP; |
|
88 |
String host1 = "192.168.0.223"; |
|
89 |
String page1 = "cgi-bin/mapserv_46.exe?map=c:\\ms4w\\Apache\\cgi-bin\\demo.map&&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=comunidades&SRS=EPSG:23030&BBOX=507522.0,4154976.282477341,942309.0,4552983.717522658&WIDTH=332&HEIGHT=305&FORMAT=image/png&STYLES=&TRANSPARENT=TRUE"; |
|
90 |
URLRequest request1; |
|
91 |
|
|
92 |
String host2 = "localhost"; |
|
93 |
String page2 = "aegCapabilities1.3.xml"; |
|
94 |
URLRequest request2; |
|
95 |
RetrieveListener listener2 = new RetrieveListener() { |
|
96 |
public void transferEventReceived(RetrieveEvent event) { |
|
97 |
int e = event.getType(); |
|
98 |
printMessage("listener2", event.getType()); |
|
99 |
if (e==RetrieveEvent.REQUEST_FINISHED || e == RetrieveEvent.REQUEST_FAILED || e==RetrieveEvent.REQUEST_CANCELLED ) |
|
100 |
finished2 = true; |
|
101 |
|
|
102 |
} |
|
103 |
}; |
|
104 |
|
|
105 |
String host3 = "localhost"; |
|
106 |
String page3 = "avalencia.ecw"; |
|
107 |
URLRequest request3; |
|
108 |
RetrieveListener listener3 = new RetrieveListener() { |
|
109 |
public void transferEventReceived(RetrieveEvent event) { |
|
110 |
int e = event.getType(); |
|
111 |
printMessage("listener3", event.getType()); |
|
112 |
if (e==RetrieveEvent.REQUEST_FINISHED || e == RetrieveEvent.REQUEST_FAILED || e == RetrieveEvent.REQUEST_CANCELLED ) |
|
113 |
finished3 = true; |
|
114 |
|
|
115 |
} |
|
116 |
}; |
|
117 |
|
|
118 |
String host4 = "192.168.0.223"; |
|
119 |
String page4 = "prueba.rar"; |
|
120 |
URLRequest request4; |
|
121 |
RetrieveListener listener4 = new RetrieveListener() { |
|
122 |
public void transferEventReceived(RetrieveEvent event) { |
|
123 |
int e = event.getType(); |
|
124 |
printMessage("listener4", event.getType()); |
|
125 |
if (e==RetrieveEvent.REQUEST_FINISHED || e == RetrieveEvent.REQUEST_FAILED || e == RetrieveEvent.REQUEST_CANCELLED ) |
|
126 |
finished4 = true; |
|
127 |
|
|
128 |
} |
|
129 |
}; |
|
130 |
{ |
|
131 |
cleanFiles(); |
|
132 |
} |
|
133 |
private static void cleanFiles(){ |
|
134 |
try{ |
|
135 |
File tempDirectory = new File(tempDirectoryPath); |
|
136 |
|
|
137 |
File[] files = tempDirectory.listFiles(); |
|
138 |
if (files!=null) { |
|
139 |
for (int i = 0; i < files.length; i++) { |
|
140 |
// s?lo por si en un futuro se necesitan crear directorios temporales |
|
141 |
files[i].delete(); |
|
142 |
} |
|
143 |
} |
|
144 |
tempDirectory.delete(); |
|
145 |
} catch (Exception e) { } |
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
public void setUp() { |
|
150 |
File tmpDir = new File(tempDirectoryPath); |
|
151 |
if (!tmpDir.exists()) |
|
152 |
tmpDir.mkdir(); |
|
153 |
finished1 = finished2 = finished3 = finished4 = false; |
|
154 |
System.out.println("\n\n\nSetting up test.."); |
|
155 |
queue = new RetrieveQueue("http://192.168.0.223/cgi-bin/mapserv_46.exe?map=c:\\ms4w\\Apache\\cgi-bin\\demo.map"); |
|
156 |
|
|
157 |
request1 = new URLRequest(); |
|
158 |
// http://192.168.0.223/cgi-bin/mapserv_46.exe?map=c:\\ms4w\\Apache\\cgi-bin\\demo.map&&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=comunidades&SRS=EPSG:23030&BBOX=507522.0,4154976.282477341,942309.0,4552983.717522658&WIDTH=332&HEIGHT=305&FORMAT=image/png&STYLES=&TRANSPARENT=TRUE |
|
159 |
request1.setProtocol(protocol); |
|
160 |
request1.setHost(host1); |
|
161 |
request1.setFile(page1); |
|
162 |
request1.setFileName(tempDirectoryPath+File.separator+"task1"); |
|
163 |
request1.setRequestType(URLRequest.GET); |
|
164 |
task1 = new URLRetrieveTask(request1, listener1); |
|
165 |
|
|
166 |
request2 = new URLRequest(); |
|
167 |
// http://localhost/aegCapabilities1.3.xml |
|
168 |
request2.setProtocol(protocol); |
|
169 |
request2.setHost(host2); |
|
170 |
request2.setFile(page2); |
|
171 |
request2.setFileName(tempDirectoryPath+File.separator+"task2"); |
|
172 |
request2.setRequestType(URLRequest.GET); |
|
173 |
task2 = new URLRetrieveTask(request2, listener2); |
|
174 |
|
|
175 |
request3 = new URLRequest(); |
|
176 |
// http://localhost/avalencia.ecw |
|
177 |
request3.setProtocol(protocol); |
|
178 |
request3.setHost(host3); |
|
179 |
request3.setFile(page3); |
|
180 |
request3.setFileName(tempDirectoryPath+File.separator+"task3"); |
|
181 |
request3.setRequestType(URLRequest.GET); |
|
182 |
task3 = new URLRetrieveTask(request3, listener3); |
|
183 |
|
|
184 |
request4 = new URLRequest(); |
|
185 |
// http://192.168.0.223/prueba.rar |
|
186 |
request4.setProtocol(protocol); |
|
187 |
request4.setHost(host4); |
|
188 |
request4.setFile(page4); |
|
189 |
request4.setFileName(tempDirectoryPath+File.separator+"task4"); |
|
190 |
request4.setRequestType(URLRequest.GET); |
|
191 |
|
|
192 |
task4 = new URLRetrieveTask(request4, listener4); |
|
193 |
|
|
194 |
} |
|
195 |
|
|
196 |
public void testRetrieve() { |
|
197 |
queue.put(task1); |
|
198 |
queue.put(task2); |
|
199 |
|
|
200 |
while(!queue.isEmpty()) { |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
public void testCancelling() { |
|
205 |
long time = System.currentTimeMillis(); |
|
206 |
|
|
207 |
queue.put(task1); |
|
208 |
queue.put(task2); |
|
209 |
boolean more = true; |
|
210 |
while (!queue.isEmpty()) { |
|
211 |
if (more && System.currentTimeMillis()-time > 1000) { // wait 1 seconds and cancel |
|
212 |
task2.cancel(); |
|
213 |
more = false; |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
public void testRequestManager() { |
|
219 |
System.out.println("tests parallel downloading from different servers"); |
|
220 |
request3.setFileName("task3"); |
|
221 |
// http://localhost/avalencia.ecw |
|
222 |
|
|
223 |
request4.setFileName("task4"); |
|
224 |
// http://192.168.0.223/prueba.rar |
|
225 |
RequestManager manager = RequestManager.getInstance(); |
|
226 |
manager.addURLRequest(request3, listener3); |
|
227 |
manager.addURLRequest(request4, listener4); |
|
228 |
manager.addURLRequest(request4, listener1); |
|
229 |
while (!(finished1 && finished3 && finished4)) { |
|
230 |
|
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
public void testCocurrentTransfers() { |
|
235 |
finished1 = finished2 = finished3 = finished4 = false; |
|
236 |
System.out.println("tests to merge two or more equivalent transfers into one"); |
|
237 |
RequestManager manager = RequestManager.getInstance(); |
|
238 |
//manager.removeURLRequest(request3); |
|
239 |
request3.setFileName("task3"); |
|
240 |
|
|
241 |
manager.addURLRequest(request3, listener1); |
|
242 |
manager.addURLRequest(request3, listener2); |
|
243 |
manager.addURLRequest(request3, listener3); |
|
244 |
|
|
245 |
manager.addURLRequest(request3, listener4); |
|
246 |
while (!(finished1 && finished2 && finished3 && finished4)) { |
|
247 |
|
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
public void printMessage(String who, int code) { |
|
252 |
switch (code) { |
|
253 |
case RetrieveEvent.CONNECTING: |
|
254 |
System.out.println(who+": connecting"); |
|
255 |
break; |
|
256 |
case RetrieveEvent.TRANSFERRING: |
|
257 |
System.out.println(who+": transferring"); |
|
258 |
break; |
|
259 |
case RetrieveEvent.REQUEST_CANCELLED: |
|
260 |
System.out.println(who+": cancelled"); |
|
261 |
break; |
|
262 |
case RetrieveEvent.REQUEST_FINISHED: |
|
263 |
System.out.println(who+": finished"); |
|
264 |
break; |
|
265 |
case RetrieveEvent.REQUEST_FAILED: |
|
266 |
System.err.println(who+": failed"); |
|
267 |
break; |
|
268 |
case RetrieveEvent.NOT_STARTED: |
|
269 |
System.out.println(who+": not started"); |
|
270 |
break; |
|
271 |
case RetrieveEvent.POSTPROCESSING: |
|
272 |
System.out.println(who+": postprocessing"); |
|
273 |
break; |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
0 | 277 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestSuite; |
|
5 |
|
|
6 |
import org.gvsig.remoteClient.gml.GMLReaderTest; |
|
7 |
import org.gvsig.remoteClient.kml.KmlReaderTest; |
|
8 |
import org.gvsig.remoteClient.taskplanning.retrieving.URLRetrieveTest; |
|
9 |
import org.gvsig.remoteClient.wcs.wcs_1_0_0.WCSProtocolHandler_1_0_0Test; |
|
10 |
import org.gvsig.remoteClient.wfs.wfs_1_0_0.WFSProtocolHandlerTest1_0_0; |
|
11 |
import org.gvsig.remoteClient.wfs.wfs_1_1_0.WFSProtocolHandlerTest1_1_0; |
|
12 |
import org.gvsig.remoteClient.wms.WMSStatusTest; |
|
13 |
import org.gvsig.remoteClient.wms.wms_1_1_1.WMSProtocolHandler_1_1_1Test; |
|
14 |
|
|
15 |
public class AllTests { |
|
16 |
|
|
17 |
public static Test suite() { |
|
18 |
TestSuite suite = new TestSuite("Test for org.gvsig.remoteClient"); |
|
19 |
//$JUnit-BEGIN$ |
|
20 |
suite.addTestSuite(GMLReaderTest.class); |
|
21 |
suite.addTestSuite(KmlReaderTest.class); |
|
22 |
suite.addTestSuite(Test.class); |
|
23 |
|
|
24 |
//commented until there is a way to simulate the needed servers. |
|
25 |
//suite.addTestSuite(URLRetrieveTest.class); |
|
26 |
suite.addTestSuite(WCSProtocolHandler_1_0_0Test.class); |
|
27 |
suite.addTestSuite(WFSProtocolHandlerTest1_0_0.class); |
|
28 |
suite.addTestSuite(WFSProtocolHandlerTest1_1_0.class); |
|
29 |
suite.addTestSuite(WMSProtocolHandler_1_1_1Test.class); |
|
30 |
suite.addTestSuite(WMSStatusTest.class); |
|
31 |
|
|
32 |
//$JUnit-END$ |
|
33 |
return suite; |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
0 | 37 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/wcs/wcs_1_0_0/WCSProtocolHandler_1_0_0Test.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/* |
|
42 |
* $Id$ |
|
43 |
* $Log$ |
|
44 |
* Revision 1.8 2006-05-12 07:45:49 jaume |
|
45 |
* some warnings removed |
|
46 |
* |
|
47 |
* Revision 1.7 2006/03/15 08:54:31 jaume |
|
48 |
* *** empty log message *** |
|
49 |
* |
|
50 |
* Revision 1.6 2006/03/06 07:16:08 jaume |
|
51 |
* *** empty log message *** |
|
52 |
* |
|
53 |
* Revision 1.5 2006/03/02 07:17:08 jaume |
|
54 |
* *** empty log message *** |
|
55 |
* |
|
56 |
* Revision 1.3 2006/03/01 18:07:11 jaume |
|
57 |
* *** empty log message *** |
|
58 |
* |
|
59 |
* Revision 1.2 2006/03/01 17:56:28 jaume |
|
60 |
* *** empty log message *** |
|
61 |
* |
|
62 |
* Revision 1.1 2006/02/28 15:26:59 jaume |
|
63 |
* *** empty log message *** |
|
64 |
* |
|
65 |
*/ |
|
66 |
package org.gvsig.remoteClient.wcs.wcs_1_0_0; |
|
67 |
|
|
68 |
import java.io.File; |
|
69 |
|
|
70 |
import junit.framework.TestCase; |
|
71 |
/** |
|
72 |
* |
|
73 |
* @author jaume |
|
74 |
* |
|
75 |
*/ |
|
76 |
public class WCSProtocolHandler_1_0_0Test extends TestCase { |
|
77 |
WCSProtocolHandler1_0_0 handler1, handler2, handler3, handler4; |
|
78 |
|
|
79 |
public void setUp() { |
|
80 |
System.out.println("Setting up test.."); |
|
81 |
handler1 = new WCSProtocolHandler1_0_0(); |
|
82 |
handler2 = new WCSProtocolHandler1_0_0(); |
|
83 |
handler3 = new WCSProtocolHandler1_0_0(); |
|
84 |
handler4 = new WCSProtocolHandler1_0_0(); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
public void testParsing() { |
|
90 |
long t1 = System.currentTimeMillis(); |
|
91 |
assertTrue(handler1.parseCapabilities(new File("testdata/wcs/WCS-hypnosGetCapabilities.xml"))); |
|
92 |
assertTrue(handler1.parseDescribeCoverage(new File("testdata/wcs/WCS-hypnosDescribeCoverage.xml"))); |
|
93 |
assertTrue(handler2.parseCapabilities(new File("testdata/wcs/WCS-simonCITCostasGetCapabilities.xml"))); |
|
94 |
assertTrue(handler2.parseDescribeCoverage(new File("testdata/wcs/WCS-simonCITCostasDescribeCoverage.xml"))); |
|
95 |
assertTrue(handler3.parseCapabilities(new File("testdata/wcs/WCS-simonCITSpotGetCapabilities.xml"))); |
|
96 |
assertTrue(handler3.parseDescribeCoverage(new File("testdata/wcs/WCS-simonCITSpotDescribeCoverage.xml"))); |
|
97 |
assertTrue(handler4.parseCapabilities(new File("testdata/wcs/WCS-ionicGetCapabilities.xml"))); |
|
98 |
assertTrue(handler4.parseDescribeCoverage(new File("testdata/wcs/WCS-ionicDescribeCoverage.xml"))); |
|
99 |
long t2 = System.currentTimeMillis(); |
|
100 |
System.out.println("Test parsing done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
101 |
} |
|
102 |
} |
|
0 | 103 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/gml/GMLReaderTest.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.gml; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.io.File; |
|
5 |
import java.io.IOException; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.Hashtable; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.Map; |
|
10 |
import java.util.Set; |
|
11 |
|
|
12 |
import org.gvsig.remoteClient.gml.factories.GeometriesFactory; |
|
13 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
|
14 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
|
15 |
import org.gvsig.remoteClient.gml.factories.XMLSchemasFactory; |
|
16 |
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory; |
|
17 |
import org.gvsig.remoteClient.gml.v2.GMLSimpleFeature_v2; |
|
18 |
import org.xmlpull.v1.XmlPullParserException; |
|
19 |
|
|
20 |
import junit.framework.TestCase; |
|
21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
22 |
* |
|
23 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
24 |
* |
|
25 |
* This program is free software; you can redistribute it and/or |
|
26 |
* modify it under the terms of the GNU General Public License |
|
27 |
* as published by the Free Software Foundation; either version 2 |
|
28 |
* of the License, or (at your option) any later version. |
|
29 |
* |
|
30 |
* This program is distributed in the hope that it will be useful, |
|
31 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
* GNU General Public License for more details. |
|
34 |
* |
|
35 |
* You should have received a copy of the GNU General Public License |
|
36 |
* along with this program; if not, write to the Free Software |
|
37 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
38 |
* |
|
39 |
* For more information, contact: |
|
40 |
* |
|
41 |
* Generalitat Valenciana |
|
42 |
* Conselleria d'Infraestructures i Transport |
|
43 |
* Av. Blasco Ib??ez, 50 |
|
44 |
* 46010 VALENCIA |
|
45 |
* SPAIN |
|
46 |
* |
|
47 |
* +34 963862235 |
|
48 |
* gvsig@gva.es |
|
49 |
* www.gvsig.gva.es |
|
50 |
* |
|
51 |
* or |
|
52 |
* |
|
53 |
* IVER T.I. S.A |
|
54 |
* Salamanca 50 |
|
55 |
* 46005 Valencia |
|
56 |
* Spain |
|
57 |
* |
|
58 |
* +34 963163400 |
|
59 |
* dac@iver.es |
|
60 |
*/ |
|
61 |
/* CVS MESSAGES: |
|
62 |
* |
|
63 |
* $Id$ |
|
64 |
* $Log$ |
|
65 |
* Revision 1.9 2007-06-11 12:33:37 jaume |
|
66 |
* *** empty log message *** |
|
67 |
* |
|
68 |
* Revision 1.8 2006/12/29 17:54:48 jorpiell |
|
69 |
* Se tienen en cuenta los simpleTypes y los choices, adem?s de los atributos multiples |
|
70 |
* |
|
71 |
* Revision 1.7 2006/12/26 19:20:52 jorpiell |
|
72 |
* Se ha a?adido un nuevo fichero al test |
|
73 |
* |
|
74 |
* Revision 1.6 2006/12/22 11:25:44 csanchez |
|
75 |
* Nuevo parser GML 2.x para gml's sin esquema |
|
76 |
* |
|
77 |
* Revision 1.5 2006/10/11 08:48:49 jorpiell |
|
78 |
* Test actualizado |
|
79 |
* |
|
80 |
* Revision 1.4 2006/10/10 12:52:28 jorpiell |
|
81 |
* Soporte para features complejas. |
|
82 |
* |
|
83 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
84 |
* Cambios del 10 copiados al head |
|
85 |
* |
|
86 |
* Revision 1.1.2.2 2006/09/25 11:35:15 jorpiell |
|
87 |
* Se tienen en cuanta tablas a distintos niveles. En caso de anidamiento se cogen los resultados de la primera tabla que aparezca. |
|
88 |
* |
|
89 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell |
|
90 |
* Ya no se depende de geotools |
|
91 |
* |
|
92 |
* Revision 1.2 2006/09/18 12:08:55 jorpiell |
|
93 |
* Se han hecho algunas modificaciones que necesitaba el WFS |
|
94 |
* |
|
95 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
96 |
* Primer commit del driver de Gml |
|
97 |
* |
|
98 |
* |
|
99 |
*/ |
|
100 |
/** |
|
101 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
102 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
103 |
*/ |
|
104 |
public class GMLReaderTest extends TestCase { |
|
105 |
private static String gmlFileWFSDuplicados = "testdata/wfs/WFS-AtlasAvesGetFeature.xml"; |
|
106 |
private static String gmlFilePoints = "testdata/gml/GML-points.gml"; |
|
107 |
private static String gmlFileLines = "testdata/gml/GML-lines.gml"; |
|
108 |
private static String gmlFilePolygons = "testdata/gml/GML-polygons.gml"; |
|
109 |
private static String gmlNomenclatorIdee = "testdata/gml/GMLNomenclatorIdee.gml"; |
|
110 |
private static String gmlNoSchema="testdata/gml/GMLNomenclatorIdeeWithoutSchema.gml"; |
|
111 |
private IGeometriesFactory factory = new GeometriesFactory(); |
|
112 |
|
|
113 |
public void testWFSDuplicados() throws Exception{ |
|
114 |
assertEquals(parseFile(gmlFileWFSDuplicados),199); |
|
115 |
} |
|
116 |
|
|
117 |
public void testParsePoints() throws Exception{ |
|
118 |
assertEquals(parseFile(gmlFilePoints),25); |
|
119 |
} |
|
120 |
|
|
121 |
public void testParseLines() throws Exception{ |
|
122 |
assertEquals(parseFile(gmlFileLines),10); |
|
123 |
} |
|
124 |
|
|
125 |
public void testParsePolygons() throws Exception{ |
|
126 |
assertEquals(parseFile(gmlFilePolygons),3); |
|
127 |
} |
|
128 |
|
|
129 |
public void testNomenclatorIdee() throws Exception{ |
|
130 |
assertEquals(parseFile(gmlNomenclatorIdee),1); |
|
131 |
} |
|
132 |
|
|
133 |
public void testParseNoSchema() throws Exception{ |
|
134 |
assertEquals(parseFile(gmlNoSchema),1); |
|
135 |
} |
|
136 |
|
|
137 |
public int parseFile(String file) throws Exception{ |
|
138 |
//Creamos un nuevo lector de GML, parseando los schemas y creando la tabla hash |
|
139 |
//con la estructura de tipos que necesitamos |
|
140 |
GMLReader reader = new GMLReader(new File(file),factory); |
|
141 |
|
|
142 |
//Estas son las coordenadas de referencia en el plano |
|
143 |
//donde se dibujar?n las geometrias, hace referencia al <coordinates> |
|
144 |
Rectangle2D extent = reader.getExtent(); |
|
145 |
|
|
146 |
IGMLFeaturesIterator iterator = reader.getFeaturesIterator(); |
|
147 |
|
|
148 |
System.out.println("******* PARSEANDO ESQUEMA XML : \n"); |
|
149 |
System.out.println("******* VERSION GML "+reader.getVersion()); |
|
150 |
System.out.println("******* Espacio de Nombres por defecto : "+reader.getTargetNamespace()); |
|
151 |
XMLElementsFactory.printEntities(); |
|
152 |
XMLTypesFactory.printTypes(); |
|
153 |
XMLSchemasFactory.printSchemas(); |
|
154 |
|
|
155 |
int i=0; |
|
156 |
while (iterator.hasNext()){ |
|
157 |
System.out.println("********* FEATURE NUMBER " + i + " ***********"); |
|
158 |
GMLSimpleFeature_v2 feature = (GMLSimpleFeature_v2) iterator.next(); |
|
159 |
Map values = feature.getValues(); |
|
160 |
Set keys = values.keySet(); |
|
161 |
Iterator it = keys.iterator(); |
|
162 |
System.out.println("********* DATOS QUE CONTIENE: ************\n" + feature.getGeom()); |
|
163 |
while (it.hasNext()){ |
|
164 |
String key = (String)it.next(); |
|
165 |
Object value = values.get(key); |
|
166 |
if (value instanceof ArrayList){ |
|
167 |
printArrayList(key,(ArrayList)value,1); |
|
168 |
}else if(value instanceof Hashtable){ |
|
169 |
printComplexType((Hashtable)value,1); |
|
170 |
}else{ |
|
171 |
System.out.print(key + ": "); |
|
172 |
System.out.println(value); |
|
173 |
} |
|
174 |
} |
|
175 |
i++; |
|
176 |
} |
|
177 |
System.out.println("NUM FEATURES: " + i); |
|
178 |
return i; |
|
179 |
} |
|
180 |
|
|
181 |
private void printComplexType(Map values,int level){ |
|
182 |
String tab = ""; |
|
183 |
for (int i=0 ; i<level ; i++){ |
|
184 |
tab = tab + "\t"; |
|
185 |
} |
|
186 |
level++; |
|
187 |
Set keys = values.keySet(); |
|
188 |
Iterator it = keys.iterator(); |
|
189 |
while (it.hasNext()){ |
|
190 |
String key = (String)it.next(); |
|
191 |
Object value = values.get(key); |
|
192 |
if (value instanceof ArrayList){ |
|
193 |
ArrayList lValues = (ArrayList)value; |
|
194 |
printArrayList(key,lValues,level); |
|
195 |
}else if(value instanceof Hashtable){ |
|
196 |
printComplexType((Hashtable)value,level); |
|
197 |
}else{ |
|
198 |
System.out.print(tab + key + ": "); |
|
199 |
System.out.print(value + "\n"); |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
private void printArrayList(String name,ArrayList al, int level){ |
|
205 |
String tab = ""; |
|
206 |
int myLevel = level - 1; |
|
207 |
for (int i=0 ; i<myLevel ; i++){ |
|
208 |
tab = tab + "\t"; |
|
209 |
} |
|
210 |
System.out.println(tab + name + ": HAY " + al.size() + " OCURRENCIAS DEL ATRIBUTO " + name); |
|
211 |
for (int k=0 ; k<al.size() ; k++){ |
|
212 |
System.out.print(tab + "\t" + "OCURRENCIA NUMERO " + (k+1) + "\n"); |
|
213 |
Object oc = al.get(k); |
|
214 |
if (oc instanceof ArrayList){ |
|
215 |
System.out.print("VECTOR"); |
|
216 |
}else if(oc instanceof Hashtable){ |
|
217 |
printComplexType((Hashtable)oc,level); |
|
218 |
}else{ |
|
219 |
System.out.print(tab + "\t" + oc + "\n"); |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
} |
|
0 | 224 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/wfs/wfs_1_0_0/WFSProtocolHandlerTest1_0_0.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.wfs.wfs_1_0_0; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.remoteClient.wcs.wcs_1_0_0.WCSProtocolHandler1_0_0; |
|
6 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
|
7 |
import org.gvsig.remoteClient.wfs.wfs_1_0_0.WFSProtocolHandler1_0_0; |
|
8 |
|
|
9 |
import junit.framework.TestCase; |
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id$ |
|
53 |
* $Log$ |
|
54 |
* Revision 1.2 2006-10-10 12:52:28 jorpiell |
|
55 |
* Soporte para features complejas. |
|
56 |
* |
|
57 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
58 |
* Primer commit del driver de Gml |
|
59 |
* |
|
60 |
* Revision 1.3 2006/05/23 13:23:13 jorpiell |
|
61 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource |
|
62 |
* |
|
63 |
* Revision 1.2 2006/04/20 16:39:16 jorpiell |
|
64 |
* A?adida la operacion de describeFeatureType y el parser correspondiente. |
|
65 |
* |
|
66 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell |
|
67 |
* A?adidas algunas de las clases del servicio WFS |
|
68 |
* |
|
69 |
* |
|
70 |
*/ |
|
71 |
/** |
|
72 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
73 |
*/ |
|
74 |
public class WFSProtocolHandlerTest1_0_0 extends TestCase { |
|
75 |
WFSProtocolHandler1_0_0 handler; |
|
76 |
|
|
77 |
public void setUp() { |
|
78 |
System.out.println("Setting up test.."); |
|
79 |
handler = new WFSProtocolHandler1_0_0(); |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
public void testParsingDescribeFeatureType() { |
|
84 |
long t1 = System.currentTimeMillis(); |
|
85 |
assertTrue(handler.parseCapabilities(new File("testdata/wfs/WFS-dmsolutionsGetCapabilities.xml"))); |
|
86 |
handler.setCurrentFeature("popplace"); |
|
87 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-dmsolutionsDescribeFeatureType.xml"),null)); |
|
88 |
long t2 = System.currentTimeMillis(); |
|
89 |
System.out.println("Test parsing vivid done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
90 |
} |
|
91 |
|
|
92 |
public void testParsingDescribeFeatureType2() { |
|
93 |
long t1 = System.currentTimeMillis(); |
|
94 |
assertTrue(handler.parseCapabilities(new File("testdata/wfs/WFS-sercartlinGetCapabilities.xml"))); |
|
95 |
handler.setCurrentFeature("topp:tasmania_roads"); |
|
96 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-sercartlinDescribeFeatureType.xml"),"cit")); |
|
97 |
long t2 = System.currentTimeMillis(); |
|
98 |
System.out.println("Test parsing sercartlin done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
99 |
} |
|
100 |
|
|
101 |
public void testParsingDescribeFeatureType3() { |
|
102 |
long t1 = System.currentTimeMillis(); |
|
103 |
assertTrue(handler.parseCapabilities(new File("testdata/wfs/WFS-IDEEGetCapabilities.xml"))); |
|
104 |
handler.setCurrentFeature("BDLL200_Provincia"); |
|
105 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-IDEEDescribeFeatureType.xml"),null)); |
|
106 |
long t2 = System.currentTimeMillis(); |
|
107 |
System.out.println("Test parsing TNT done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
} |
|
0 | 113 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/wfs/wfs_1_1_0/WFSProtocolHandlerTest1_1_0.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.wfs.wfs_1_1_0; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.remoteClient.wfs.wfs_1_0_0.WFSProtocolHandler1_0_0; |
|
6 |
|
|
7 |
import junit.framework.TestCase; |
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id$ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell |
|
53 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
/** |
|
58 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
59 |
*/ |
|
60 |
public class WFSProtocolHandlerTest1_1_0 extends TestCase { |
|
61 |
WFSProtocolHandler1_1_0 handler; |
|
62 |
|
|
63 |
public void setUp() { |
|
64 |
System.out.println("Setting up test.."); |
|
65 |
handler = new WFSProtocolHandler1_1_0(); |
|
66 |
} |
|
67 |
|
|
68 |
public void testParsingDescribeFeatureType1() { |
|
69 |
// long t1 = System.currentTimeMillis(); |
|
70 |
// assertTrue(handler.parseCapabilities(new File("test/WFS-1_1_0SercartlinGetCapabilities.xml"))); |
|
71 |
// handler.setCurrentFeature("popplace"); |
|
72 |
// |
|
73 |
// assertTrue(handler.parseDescribeFeatureType(new File("test/WFS-dmsolutionsDescribeFeatureType.xml"),null)); |
|
74 |
// long t2 = System.currentTimeMillis(); |
|
75 |
// System.out.println("Test parsing vivid done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
76 |
} |
|
77 |
|
|
78 |
public void testParsingDescribeFeatureType2() { |
|
79 |
long t1 = System.currentTimeMillis(); |
|
80 |
assertTrue(handler.parseCapabilities(new File("testdata/wfs/WFS-1_1_0IDEEGetCapabilities.xml"))); |
|
81 |
handler.setCurrentFeature("ideewfs:VerticeRedOrdenInferior"); |
|
82 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-1_1_0IDEEDescribeFeatureType.xml"),null)); |
|
83 |
long t2 = System.currentTimeMillis(); |
|
84 |
Object obj = handler.getFeatures().get("ideewfs:VerticeRedOrdenInferior"); |
|
85 |
System.out.println("Test parsing vivid done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
86 |
} |
|
87 |
|
|
88 |
public void testParsingDescribeFeatureTypeTNT() { |
|
89 |
long t1 = System.currentTimeMillis(); |
|
90 |
assertTrue(handler.parseCapabilities(new File("testdata/wfs/WFS-1_1_0TNTGetCapabilities.xml"))); |
|
91 |
handler.setCurrentFeature("BDLL200_Provincia"); |
|
92 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-1_1_0TNTDescribeFeatureType1.xml"),null)); |
|
93 |
assertTrue(handler.parseDescribeFeatureType(new File("testdata/wfs/WFS-1_1_0TNTDescribeFeatureType2.xml"),null)); |
|
94 |
long t2 = System.currentTimeMillis(); |
|
95 |
System.out.println("Test parsing IDEE done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
96 |
} |
|
97 |
} |
|
0 | 98 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/Tests/Test.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.Tests; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.remoteClient.wms.WMSClient; |
|
8 |
import org.gvsig.remoteClient.wms.WMSStatus; |
|
9 |
|
|
10 |
public class Test extends TestCase |
|
11 |
{ |
|
12 |
|
|
13 |
public static void main(String[] args) |
|
14 |
{ |
|
15 |
try |
|
16 |
{ |
|
17 |
WMSClient wmsclient = new WMSClient("http://orto.cth.gva.es:80/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos?"); |
|
18 |
//http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=3&STYLES=&SRS=EPSG:4326&BBOX=-1.5597948439,37.8178641941,0.5286772976,40.8151000365&WIDTH=500&HEIGHT=500&FORMAT=image/jpeg&EXCEPTIONS=XML |
|
19 |
|
|
20 |
wmsclient.connect(null); |
|
21 |
//System.out.println(); |
|
22 |
//System.out.println(Utilities.Vector2CS(layerNames)); |
|
23 |
|
|
24 |
WMSStatus status = new WMSStatus(); |
|
25 |
status.addLayerName("3"); |
|
26 |
// status.addLayerName("europa_rivieren"); |
|
27 |
// status.addStyleName("default"); |
|
28 |
// status.addStyleName("default"); |
|
29 |
status.setSrs("EPSG:4326"); |
|
30 |
|
|
31 |
Rectangle2D extent = new Rectangle2D.Double(-1.5597948439,37.8178641941,-1.5597948439-0.5286772976,37.8178641941-40.8151000365); |
|
32 |
|
|
33 |
status.setExtent(extent); |
|
34 |
status.setFormat("image/jpeg"); |
|
35 |
status.setHeight(500); |
|
36 |
status.setWidth(500); |
|
37 |
|
|
38 |
//wmsclient.getMap(status); |
|
39 |
|
|
40 |
//wmsclient.getFeatureInfo(status,300,300); |
|
41 |
|
|
42 |
System.out.println(); |
|
43 |
} |
|
44 |
catch(Exception e) |
|
45 |
{ |
|
46 |
System.out.println(e.getMessage()); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
} |
|
0 | 51 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/kml/KmlReaderTest.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.kml; |
|
2 |
|
|
3 |
|
|
4 |
import java.io.File; |
|
5 |
import java.io.FileInputStream; |
|
6 |
import java.io.FileNotFoundException; |
|
7 |
import java.io.InputStream; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.Map; |
|
10 |
import java.util.Set; |
|
11 |
|
|
12 |
import junit.framework.TestCase; |
|
13 |
|
|
14 |
import org.gvsig.remoteClient.gml.engine.IFeaturesIterator; |
|
15 |
import org.gvsig.remoteClient.gml.factories.GeometriesFactory; |
|
16 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
|
17 |
import org.gvsig.remoteClient.gml.v2.GMLSimpleFeature_v2; |
|
18 |
import org.gvsig.remoteClient.kml.exceptions.KmlException; |
|
19 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
20 |
* |
|
21 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
22 |
* |
|
23 |
* This program is free software; you can redistribute it and/or |
|
24 |
* modify it under the terms of the GNU General Public License |
|
25 |
* as published by the Free Software Foundation; either version 2 |
|
26 |
* of the License, or (at your option) any later version. |
|
27 |
* |
|
28 |
* This program is distributed in the hope that it will be useful, |
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
31 |
* GNU General Public License for more details. |
|
32 |
* |
|
33 |
* You should have received a copy of the GNU General Public License |
|
34 |
* along with this program; if not, write to the Free Software |
|
35 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
36 |
* |
|
37 |
* For more information, contact: |
|
38 |
* |
|
39 |
* Generalitat Valenciana |
|
40 |
* Conselleria d'Infraestructures i Transport |
|
41 |
* Av. Blasco Ib??ez, 50 |
|
42 |
* 46010 VALENCIA |
|
43 |
* SPAIN |
|
44 |
* |
|
45 |
* +34 963862235 |
|
46 |
* gvsig@gva.es |
|
47 |
* www.gvsig.gva.es |
|
48 |
* |
|
49 |
* or |
|
50 |
* |
|
51 |
* IVER T.I. S.A |
|
52 |
* Salamanca 50 |
|
53 |
* 46005 Valencia |
|
54 |
* Spain |
|
55 |
* |
|
56 |
* +34 963163400 |
|
57 |
* dac@iver.es |
|
58 |
*/ |
|
59 |
/* CVS MESSAGES: |
|
60 |
* |
|
61 |
* $Id$ |
|
62 |
* $Log$ |
|
63 |
* Revision 1.1 2007-02-12 13:49:18 jorpiell |
|
64 |
* A?adido el driver de KML |
|
65 |
* |
|
66 |
* |
|
67 |
*/ |
|
68 |
/** |
|
69 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
70 |
*/ |
|
71 |
public class KmlReaderTest extends TestCase { |
|
72 |
private static String kmlGoogleExample = "testdata/kml/KML_Samples.kml"; |
|
73 |
private static String kmlPlaceMarket = "testdata/kml/KML_PlaceMarket.kml"; |
|
74 |
private static String kmlGorliz = "testdata/kml/gorliz.kml"; |
|
75 |
private IGeometriesFactory factory = new GeometriesFactory(); |
|
76 |
|
|
77 |
public void testGoogleExample() throws Exception{ |
|
78 |
assertEquals(parseFile(kmlGoogleExample),20); |
|
79 |
} |
|
80 |
|
|
81 |
public void testPlaceMarket() throws Exception{ |
|
82 |
assertEquals(parseFile(kmlPlaceMarket),1); |
|
83 |
} |
|
84 |
|
|
85 |
public void testGorliz() throws Exception{ |
|
86 |
assertEquals(parseFile(kmlGorliz),51); |
|
87 |
} |
|
88 |
|
|
89 |
public int parseFile(String file) throws Exception{ |
|
90 |
KmlDriver driver = new KmlDriver(createInputStream(new File(file)),factory); |
|
91 |
|
|
92 |
System.out.println("********* FILE START: " + file + "***********"); |
|
93 |
|
|
94 |
IFeaturesIterator iterator = driver.getFeaturesIterator(); |
|
95 |
int i=0; |
|
96 |
while (iterator.hasNext()){ |
|
97 |
//Object feature = iterator.next(); |
|
98 |
System.out.println("********* FEATURE NUMBER " + i + " ***********"); |
|
99 |
GMLSimpleFeature_v2 feature = (GMLSimpleFeature_v2) iterator.next(); |
|
100 |
if (feature != null){ |
|
101 |
System.out.println("Geometria: " + feature.getGeom()); |
|
102 |
Map values = feature.getValues(); |
|
103 |
Set keys = values.keySet(); |
|
104 |
Iterator it = keys.iterator(); |
|
105 |
while (it.hasNext()){ |
|
106 |
String key = (String)it.next(); |
|
107 |
System.out.print(key + ": "); |
|
108 |
System.out.println(values.get(key)); |
|
109 |
}} |
|
110 |
i++; |
|
111 |
} |
|
112 |
System.out.println("NUM FEATURES: " + i); |
|
113 |
return i; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* It creates an InputStream. The Kml file can have the |
|
118 |
* KML or the KMZ extension |
|
119 |
* @return |
|
120 |
* @throws KmlException |
|
121 |
*/ |
|
122 |
private InputStream createInputStream(File file) throws KmlException{ |
|
123 |
try { |
|
124 |
if (file.getName().toUpperCase().endsWith("KML")){ |
|
125 |
return new FileInputStream(file); |
|
126 |
}else if(file.getName().toUpperCase().endsWith("KMZ")){ |
|
127 |
return null; |
|
128 |
}else{ |
|
129 |
throw new KmlException(file); |
|
130 |
} |
|
131 |
} catch (FileNotFoundException e) { |
|
132 |
throw new KmlException(file,e); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
} |
|
138 |
|
|
0 | 139 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/wms/WMSStatusTest.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.wms; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.Vector; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
/** |
|
8 |
* |
|
9 |
* @author jaume |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class WMSStatusTest extends TestCase { |
|
13 |
WMSStatus st1, st2, st3, st4; |
|
14 |
protected void setUp() { |
|
15 |
st1 = new WMSStatus(); |
|
16 |
// Layer names |
|
17 |
Vector v1 = new Vector(); |
|
18 |
v1.add("a"); |
|
19 |
v1.add("b"); |
|
20 |
v1.add("c"); |
|
21 |
st1.setLayerNames(v1); |
|
22 |
v1.clear(); |
|
23 |
// Styles |
|
24 |
v1.add("s1"); |
|
25 |
v1.add("s2"); |
|
26 |
v1.add("s3"); |
|
27 |
st1.setStyles(v1); |
|
28 |
// Transparency |
|
29 |
st1.setTransparency(false); |
|
30 |
v1.clear(); |
|
31 |
v1.add("TIME=february"); |
|
32 |
v1.add("WAVELENGTH=200nm"); |
|
33 |
st1.setDimensions(v1); |
|
34 |
// Extent |
|
35 |
Rectangle2D rect1 = new Rectangle2D.Double(1.0, 1.00000001, 5.000000, 6.8); |
|
36 |
st1.setExtent(rect1); |
|
37 |
// Exception format |
|
38 |
st1.setExceptionFormat("bla"); |
|
39 |
// SRS |
|
40 |
st1.setSrs("bla bla"); |
|
41 |
// Format |
|
42 |
st1.setFormat("image/mpeg"); |
|
43 |
// Width |
|
44 |
st1.setWidth(800); |
|
45 |
// Height |
|
46 |
st1.setHeight(600); |
|
47 |
// Online resource |
|
48 |
st1.setOnlineResource("alkjf"); |
|
49 |
|
|
50 |
st2 = new WMSStatus(); |
|
51 |
// Layer names |
|
52 |
Vector v2 = new Vector(); |
|
53 |
v2.add("a"); |
|
54 |
v2.add("b"); |
|
55 |
v2.add("c"); |
|
56 |
st2.setLayerNames(v2); |
|
57 |
v2.clear(); |
|
58 |
// Styles |
|
59 |
v2.add("s1"); |
|
60 |
v2.add("s2"); |
|
61 |
v2.add("s3"); |
|
62 |
st2.setStyles(v2); |
|
63 |
// Transparency |
|
64 |
st2.setTransparency(false); |
|
65 |
v2.clear(); |
|
66 |
// Dimensions |
|
67 |
v2.add("TIME=february"); |
|
68 |
v2.add("WAVELENGTH=200nm"); |
|
69 |
st2.setDimensions(v2); |
|
70 |
// Extent |
|
71 |
Rectangle2D rect2 = new Rectangle2D.Double(1.0, 1.00000001, 5.000000, 6.8); |
|
72 |
st2.setExtent(rect2); |
|
73 |
// Exception format |
|
74 |
st2.setExceptionFormat("bla"); |
|
75 |
// SRS |
|
76 |
st2.setSrs("bla bla"); |
|
77 |
// Format |
|
78 |
st2.setFormat("image/mpeg"); |
|
79 |
// Width |
|
80 |
st2.setWidth(800); |
|
81 |
// Height |
|
82 |
st2.setHeight(600); |
|
83 |
// Online resource |
|
84 |
st2.setOnlineResource("alkjf"); |
|
85 |
|
|
86 |
st3 = new WMSStatus(); |
|
87 |
// Layer names |
|
88 |
Vector v3 = new Vector(); |
|
89 |
v3.add("a"); |
|
90 |
v3.add("b"); |
|
91 |
v3.add("c"); |
|
92 |
st3.setLayerNames(v3); |
|
93 |
v3.clear(); |
|
94 |
// Styles |
|
95 |
v3.add("s1"); |
|
96 |
v3.add("s2"); |
|
97 |
v3.add("s3"); |
|
98 |
st3.setStyles(v3); |
|
99 |
// Transparency |
|
100 |
st3.setTransparency(false); |
|
101 |
v3.clear(); |
|
102 |
// Dimensions |
|
103 |
v3.add("TIME=february"); |
|
104 |
v3.add("WAVELENGTH=200nm"); |
|
105 |
st3.setDimensions(v3); |
|
106 |
// Extent |
|
107 |
Rectangle2D rect3 = new Rectangle2D.Double(2.0, 1.00000001, 5.000000, 6.8); |
|
108 |
st3.setExtent(rect3); |
|
109 |
// Exception format |
|
110 |
st3.setExceptionFormat("bla"); |
|
111 |
// SRS |
|
112 |
st3.setSrs("bla bla"); |
|
113 |
// Format |
|
114 |
st3.setFormat("image/mpeg"); |
|
115 |
// Width |
|
116 |
st3.setWidth(800); |
|
117 |
// Height |
|
118 |
st3.setHeight(600); |
|
119 |
// Online resource |
|
120 |
st3.setOnlineResource("alkjf"); |
|
121 |
|
|
122 |
st4 = new WMSStatus(); |
|
123 |
// Layer names |
|
124 |
Vector v4 = new Vector(); |
|
125 |
v4.add("a"); |
|
126 |
v4.add("b"); |
|
127 |
v4.add("c"); |
|
128 |
st4.setLayerNames(v4); |
|
129 |
v4.clear(); |
|
130 |
// Styles |
|
131 |
v4.add("s1"); |
|
132 |
v4.add("s2"); |
|
133 |
v4.add("s3"); |
|
134 |
st4.setStyles(v4); |
|
135 |
// Transparency |
|
136 |
st4.setTransparency(false); |
|
137 |
v4.clear(); |
|
138 |
// Dimensions |
|
139 |
v4.add("TIME=february"); |
|
140 |
v4.add("WAVELENGTH=200nm"); |
|
141 |
st4.setDimensions(v4); |
|
142 |
// Extent |
|
143 |
Rectangle2D rect4 = new Rectangle2D.Double(2.0, 1.00000001, 5.000000, 6.8); |
|
144 |
st4.setExtent(rect3); |
|
145 |
// Exception format |
|
146 |
st4.setExceptionFormat("bla"); |
|
147 |
// SRS |
|
148 |
st4.setSrs("bla bla"); |
|
149 |
// Format |
|
150 |
st4.setFormat("image/mpeg"); |
|
151 |
// Width |
|
152 |
st4.setWidth(800); |
|
153 |
// Height |
|
154 |
st4.setHeight(600); |
|
155 |
// Online resource |
|
156 |
st4.setOnlineResource("alkjfa"); |
|
157 |
} |
|
158 |
|
|
159 |
public void testEquality() { |
|
160 |
assertTrue(st1.equals(st2)); |
|
161 |
assertFalse(st1.equals(st3)); // (distinct extent) |
|
162 |
assertFalse(st3.equals(st4)); // (distinct online resources) |
|
163 |
} |
|
164 |
} |
|
0 | 165 |
import/extWFST/libRemoteServices/test/org/gvsig/remoteClient/wms/wms_1_1_1/WMSProtocolHandler_1_1_1Test.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.remoteClient.wms.wms_1_1_1; |
|
42 |
|
|
43 |
import java.io.File; |
|
44 |
|
|
45 |
import junit.framework.TestCase; |
|
46 |
|
|
47 |
/** |
|
48 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
49 |
*/ |
|
50 |
public class WMSProtocolHandler_1_1_1Test extends TestCase { |
|
51 |
WMSProtocolHandler1_1_1 handler1, handler2, handler3, handler4; |
|
52 |
|
|
53 |
public void setUp() { |
|
54 |
System.out.println("Setting up test.."); |
|
55 |
handler1 = new WMSProtocolHandler1_1_1(); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
public void testParsing() { |
|
61 |
long t1 = System.currentTimeMillis(); |
|
62 |
handler1.parse(new File("testdata/wms/wms.xml")); |
Also available in: Unified diff