Revision 39242
tags/v2_0_0_Build_2058/libraries/libFMap_dal/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
5 |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
6 |
|
|
7 |
<modelVersion>4.0.0</modelVersion> |
|
8 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
9 |
<name>libFMap_dal</name> |
|
10 |
<version>2.0-SNAPSHOT</version> |
|
11 |
<parent> |
|
12 |
<artifactId>gvsig-base-library-pom</artifactId> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<version>2.0-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.compat</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.i18n</artifactId> |
|
35 |
<scope>compile</scope> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.gvsig</groupId> |
|
39 |
<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.projection</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
50 |
<scope>compile</scope> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
55 |
<scope>compile</scope> |
|
56 |
</dependency> |
|
57 |
<dependency> |
|
58 |
<groupId>org.slf4j</groupId> |
|
59 |
<artifactId>slf4j-api</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>easymock</groupId> |
|
64 |
<artifactId>easymock</artifactId> |
|
65 |
<version>1.2_Java1.3</version> |
|
66 |
<scope>test</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>easymock</groupId> |
|
70 |
<artifactId>easymockclassextension</artifactId> |
|
71 |
<version>1.2</version> |
|
72 |
<scope>test</scope> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>xmlpull</groupId> |
|
76 |
<artifactId>xmlpull</artifactId> |
|
77 |
<scope>compile</scope> |
|
78 |
</dependency> |
|
79 |
<!-- Implementation dependencies for TESTS --> |
|
80 |
<dependency> |
|
81 |
<groupId>org.gvsig</groupId> |
|
82 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
83 |
<type>test-jar</type> |
|
84 |
</dependency> |
|
85 |
<dependency> |
|
86 |
<groupId>org.gvsig</groupId> |
|
87 |
<artifactId>org.gvsig.compat</artifactId> |
|
88 |
<classifier>se</classifier> |
|
89 |
<scope>test</scope> |
|
90 |
</dependency> |
|
91 |
<dependency> |
|
92 |
<groupId>org.gvsig</groupId> |
|
93 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
94 |
<classifier>impl</classifier> |
|
95 |
<scope>test</scope> |
|
96 |
</dependency> |
|
97 |
</dependencies> |
|
98 |
<properties> |
|
99 |
<build-dir>${basedir}/../build</build-dir> |
|
100 |
<eclipse.project.name>libFMap_dal</eclipse.project.name> |
|
101 |
</properties> |
|
102 |
|
|
103 |
<profiles> |
|
104 |
<profile> |
|
105 |
<id>se</id> |
|
106 |
<activation> |
|
107 |
<activeByDefault>true</activeByDefault> |
|
108 |
</activation> |
|
109 |
<dependencies> |
|
110 |
<!-- TESTS --> |
|
111 |
<dependency> |
|
112 |
<groupId>org.gvsig</groupId> |
|
113 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
114 |
<classifier>operation</classifier> |
|
115 |
<scope>test</scope> |
|
116 |
</dependency> |
|
117 |
<dependency> |
|
118 |
<groupId>org.gvsig</groupId> |
|
119 |
<artifactId>org.gvsig.projection</artifactId> |
|
120 |
<classifier>cresques-impl</classifier> |
|
121 |
<scope>test</scope> |
|
122 |
</dependency> |
|
123 |
<dependency> |
|
124 |
<groupId>org.geotools</groupId> |
|
125 |
<artifactId>gt2-legacy</artifactId> |
|
126 |
<scope>test</scope> |
|
127 |
</dependency> |
|
128 |
<dependency> |
|
129 |
<groupId>org.geotools</groupId> |
|
130 |
<artifactId>gt2-main</artifactId> |
|
131 |
<scope>test</scope> |
|
132 |
</dependency> |
|
133 |
<dependency> |
|
134 |
<groupId>org.opengis</groupId> |
|
135 |
<artifactId>geoapi</artifactId> |
|
136 |
<scope>test</scope> |
|
137 |
</dependency> |
|
138 |
<dependency> |
|
139 |
<groupId>javax.media</groupId> |
|
140 |
<artifactId>jai_core</artifactId> |
|
141 |
<scope>test</scope> |
|
142 |
</dependency> |
|
143 |
<dependency> |
|
144 |
<groupId>javax.media</groupId> |
|
145 |
<artifactId>jai_codec</artifactId> |
|
146 |
<scope>test</scope> |
|
147 |
</dependency> |
|
148 |
</dependencies> |
|
149 |
</profile> |
|
150 |
<profile> |
|
151 |
<id>cdc</id> |
|
152 |
<activation> |
|
153 |
<activeByDefault>false</activeByDefault> |
|
154 |
</activation> |
|
155 |
|
|
156 |
<dependencies> |
|
157 |
<!-- TESTS --> |
|
158 |
<dependency> |
|
159 |
<groupId>org.gvsig.mobile</groupId> |
|
160 |
<artifactId>org.gvsig.mobile.libProjection</artifactId> |
|
161 |
<version>0.0.1-SNAPSHOT</version> |
|
162 |
</dependency> |
|
163 |
</dependencies> |
|
164 |
</profile> |
|
165 |
<profile> |
|
166 |
<id>eclipse-project</id> |
|
167 |
<build> |
|
168 |
<defaultGoal>antrun:run</defaultGoal> |
|
169 |
<plugins> |
|
170 |
<plugin> |
|
171 |
<artifactId>maven-antrun-plugin</artifactId> |
|
172 |
<configuration> |
|
173 |
<tasks> |
|
174 |
<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml" |
|
175 |
target="eclipse.all"/> |
|
176 |
</tasks> |
|
177 |
</configuration> |
|
178 |
</plugin> |
|
179 |
</plugins> |
|
180 |
</build> |
|
181 |
</profile> |
|
182 |
</profiles> |
|
183 |
|
|
184 |
<build> |
|
185 |
<sourceDirectory>src</sourceDirectory> |
|
186 |
<testSourceDirectory>src-test</testSourceDirectory> |
|
187 |
<plugins> |
|
188 |
<plugin> |
|
189 |
<groupId>org.apache.maven.plugins</groupId> |
|
190 |
<artifactId>maven-compiler-plugin</artifactId> |
|
191 |
<configuration> |
|
192 |
<source>1.4</source> |
|
193 |
<target>1.4</target> |
|
194 |
</configuration> |
|
195 |
</plugin> |
|
196 |
<plugin> |
|
197 |
<groupId>org.apache.maven.plugins</groupId> |
|
198 |
<artifactId>maven-jar-plugin</artifactId> |
|
199 |
<configuration> |
|
200 |
<excludes> |
|
201 |
<exclude>**/impl/**</exclude> |
|
202 |
<exclude>**/spi/**</exclude> |
|
203 |
</excludes> |
|
204 |
</configuration> |
|
205 |
<executions> |
|
206 |
<!-- |
|
207 |
Generates a jar file only with the DAL default implementation |
|
208 |
--> |
|
209 |
<execution> |
|
210 |
<id>impl</id> |
|
211 |
<phase>package</phase> |
|
212 |
<goals> |
|
213 |
<goal>jar</goal> |
|
214 |
</goals> |
|
215 |
<configuration> |
|
216 |
<classifier>impl</classifier> |
|
217 |
<includes> |
|
218 |
<include>**/impl/**</include> |
|
219 |
</includes> |
|
220 |
<excludes> |
|
221 |
<exclude>**/spi/**</exclude> |
|
222 |
</excludes> |
|
223 |
</configuration> |
|
224 |
</execution> |
|
225 |
<!-- |
|
226 |
Generates a jar file only with the DAL SPI |
|
227 |
--> |
|
228 |
<execution> |
|
229 |
<id>spi</id> |
|
230 |
<phase>package</phase> |
|
231 |
<goals> |
|
232 |
<goal>jar</goal> |
|
233 |
</goals> |
|
234 |
<configuration> |
|
235 |
<classifier>spi</classifier> |
|
236 |
<includes> |
|
237 |
<include>**/spi/**</include> |
|
238 |
</includes> |
|
239 |
<excludes> |
|
240 |
<exclude>**/impl/**</exclude> |
|
241 |
</excludes> |
|
242 |
</configuration> |
|
243 |
</execution> |
|
244 |
<!-- |
|
245 |
Generates a jar file only with the test classes |
|
246 |
--> |
|
247 |
<execution> |
|
248 |
<goals> |
|
249 |
<goal>test-jar</goal> |
|
250 |
</goals> |
|
251 |
<configuration> |
|
252 |
<includes> |
|
253 |
<include>**/**</include> |
|
254 |
</includes> |
|
255 |
<excludes> |
|
256 |
<exclude>NONE</exclude> |
|
257 |
</excludes> |
|
258 |
</configuration> |
|
259 |
</execution> |
|
260 |
</executions> |
|
261 |
</plugin> |
|
262 |
<plugin> |
|
263 |
<artifactId>maven-antrun-plugin</artifactId> |
|
264 |
<executions> |
|
265 |
<execution> |
|
266 |
<id>services</id> |
|
267 |
<phase>package</phase> |
|
268 |
<goals> |
|
269 |
<goal>run</goal> |
|
270 |
</goals> |
|
271 |
<configuration> |
|
272 |
<tasks> |
|
273 |
<jar destfile="${project.build.directory}/${project.build.finalName}.jar" |
|
274 |
update="true"> |
|
275 |
<fileset dir="${basedir}/resources/api" /> |
|
276 |
</jar> |
|
277 |
<jar destfile="${project.build.directory}/${project.build.finalName}-impl.jar" |
|
278 |
update="true"> |
|
279 |
<fileset dir="${basedir}/resources/impl" /> |
|
280 |
</jar> |
|
281 |
</tasks> |
|
282 |
</configuration> |
|
283 |
</execution> |
|
284 |
</executions> |
|
285 |
</plugin> |
|
286 |
<plugin> |
|
287 |
<groupId>org.apache.maven.plugins</groupId> |
|
288 |
<artifactId>maven-surefire-plugin</artifactId> |
|
289 |
<configuration> |
|
290 |
<excludes> |
|
291 |
<exclude>**/BlockTest.java</exclude> |
|
292 |
</excludes> |
|
293 |
<additionalClasspathElements> |
|
294 |
<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement> |
|
295 |
<additionalClasspathElement>${basedir}/resources/impl</additionalClasspathElement> |
|
296 |
</additionalClasspathElements> |
|
297 |
<skipTests>true</skipTests> |
|
298 |
</configuration> |
|
299 |
</plugin> |
|
300 |
</plugins> |
|
301 |
</build> |
|
302 |
<reporting> |
|
303 |
<plugins> |
|
304 |
<plugin> |
|
305 |
<groupId>org.apache.maven.plugins</groupId> |
|
306 |
<artifactId>maven-javadoc-plugin</artifactId> |
|
307 |
<reportSets> |
|
308 |
<reportSet> |
|
309 |
<id>api</id> |
|
310 |
<configuration> |
|
311 |
<excludePackageNames>*.spi:*.impl</excludePackageNames> |
|
312 |
<name>Javadoc: API</name> |
|
313 |
<destDir>apidoc</destDir> |
|
314 |
<windowtitle>API Documentation</windowtitle> |
|
315 |
</configuration> |
|
316 |
<reports> |
|
317 |
<report>javadoc</report> |
|
318 |
</reports> |
|
319 |
</reportSet> |
|
320 |
<reportSet> |
|
321 |
<id>spi</id> |
|
322 |
<configuration> |
|
323 |
<doctitle>${project.name} ${project.version} SPI</doctitle> |
|
324 |
<subpackages>org.gvsig.fmap.dal.spi:org.gvsig.fmap.dal.feature.spi:org.gvsig.fmap.dal.raster.spi:org.gvsig.fmap.dal.resource.spi</subpackages> |
|
325 |
<name>Javadoc: SPI</name> |
|
326 |
<destDir>spidoc</destDir> |
|
327 |
<windowtitle>SPI Documentation</windowtitle> |
|
328 |
<links> |
|
329 |
<link>../apidoc/</link> |
|
330 |
</links> |
|
331 |
</configuration> |
|
332 |
<reports> |
|
333 |
<report>javadoc</report> |
|
334 |
</reports> |
|
335 |
</reportSet> |
|
336 |
<reportSet> |
|
337 |
<id>impl</id> |
|
338 |
<configuration> |
|
339 |
<doctitle>${project.name} ${project.version} Default implementation</doctitle> |
|
340 |
<subpackages>org.gvsig.fmap.dal.impl:org.gvsig.fmap.dal.feature.impl:org.gvsig.fmap.dal.raster.impl:org.gvsig.fmap.dal.resource.impl</subpackages> |
|
341 |
<name>Javadoc: Impl</name> |
|
342 |
<destDir>impldoc</destDir> |
|
343 |
<windowtitle>Default implementation Documentation</windowtitle> |
|
344 |
<links> |
|
345 |
<link>../apidoc/</link> |
|
346 |
<link>../spidoc/</link> |
|
347 |
</links> |
|
348 |
</configuration> |
|
349 |
<reports> |
|
350 |
<report>javadoc</report> |
|
351 |
</reports> |
|
352 |
</reportSet> |
|
353 |
</reportSets> |
|
354 |
</plugin> |
|
355 |
</plugins> |
|
356 |
</reporting> |
|
357 |
</project> |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/impl/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.dal.impl.DALDefaultImplLibrary |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/impl/org/gvsig/fmap/dal/i18n/text_en.properties | ||
---|---|---|
1 |
filling_index=Filling index |
|
2 |
updating_index=Updating index |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/impl/org/gvsig/fmap/dal/i18n/text.properties | ||
---|---|---|
1 |
filling_index=Llenando ?ndice |
|
2 |
updating_index=Actualizando ?ndice |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/api/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.dal.DALLibrary |
|
2 |
org.gvsig.fmap.dal.store.memory.MemoryStoreLibrary |
|
3 |
|
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/api/org/gvsig/fmap/dal/MetadataDefinitions.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="DataProvider" namespace="metadata"> |
|
6 |
<description>Metadata of a feature store</description> |
|
7 |
<fields> |
|
8 |
<field name="ProviderName" type="string" mandatory="true"> |
|
9 |
<description>The name of the provider of data</description> |
|
10 |
</field> |
|
11 |
<field name="ContainerName" type="string" mandatory="false"> |
|
12 |
<description>Name of the container of the data, by example, in a dbf, the file name of the dbf</description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
|
|
17 |
<class name="FeatureProvider" namespace="metadata"> |
|
18 |
<extends> |
|
19 |
<class namespace="metadata" name="DataProvider"/> |
|
20 |
</extends> |
|
21 |
<description>Metadata of a feature store</description> |
|
22 |
<fields> |
|
23 |
<field name="FeatureType" type="dynobject" subType="org.gvsig.fmap.dal.feature.FeatureType" mandatory="false"> |
|
24 |
<description>The definition of the structure of the store</description> |
|
25 |
</field> |
|
26 |
</fields> |
|
27 |
</class> |
|
28 |
|
|
29 |
<class name="SpatialProvider" namespace="metadata"> |
|
30 |
<extends> |
|
31 |
<class namespace="metadata" name="FeatureProvider"/> |
|
32 |
</extends> |
|
33 |
<description>Metadata of a feature store with spatial support</description> |
|
34 |
<fields> |
|
35 |
<field name="CRS" type="crs" mandatory="false"> |
|
36 |
<description></description> |
|
37 |
</field> |
|
38 |
<field name="Envelope" type="envelope" mandatory="false"> |
|
39 |
<description></description> |
|
40 |
</field> |
|
41 |
</fields> |
|
42 |
</class> |
|
43 |
|
|
44 |
</classes> |
|
45 |
</definitions> |
|
0 | 46 |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/resources/api/org/gvsig/fmap/dal/spi/ProviderParametersDefinition.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class namespace="dal" name="ProviderParameters"> |
|
6 |
<description>Parameters used for open a store</description> |
|
7 |
<fields> |
|
8 |
<field name="ProviderName" type="string" mandatory="true" group="Advanced"> |
|
9 |
<description>Name of the provider</description> |
|
10 |
</field> |
|
11 |
</fields> |
|
12 |
</class> |
|
13 |
|
|
14 |
<class namespace="dal" name="NewProviderParameters"> |
|
15 |
<extends> |
|
16 |
<class namespace="dal" name="ProviderParameters"/> |
|
17 |
</extends> |
|
18 |
<description>Parameters used for create a new store in the server</description> |
|
19 |
<fields> |
|
20 |
<field name="FeatureType" type="object" mandatory="true" hidden="true" classOfValue="org.gvsig.fmap.dal.feature.FeatureType"> |
|
21 |
<description>Define the structure of the new store</description> |
|
22 |
</field> |
|
23 |
</fields> |
|
24 |
</class> |
|
25 |
|
|
26 |
</classes> |
|
27 |
</definitions> |
|
0 | 28 |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/DataStoreTest.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal; |
|
2 |
|
|
3 |
import junit.framework.TestCase; |
|
4 |
|
|
5 |
public class DataStoreTest extends TestCase { |
|
6 |
|
|
7 |
public void testVoid() { |
|
8 |
|
|
9 |
} |
|
10 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/resource/spi/TestResource.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 |
* 2009 {} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.dal.resource.spi; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
30 |
import org.gvsig.fmap.dal.resource.ResourceParameters; |
|
31 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
32 |
import org.gvsig.fmap.dal.resource.exception.ResourceException; |
|
33 |
|
|
34 |
/** |
|
35 |
* Test non blocking resource implementation. |
|
36 |
* |
|
37 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
38 |
*/ |
|
39 |
public class TestResource extends AbstractResource { |
|
40 |
|
|
41 |
protected TestResource(ResourceParameters parameters) |
|
42 |
throws InitializeException { |
|
43 |
super(parameters); |
|
44 |
} |
|
45 |
|
|
46 |
public Object get() throws AccessResourceException { |
|
47 |
return getName(); |
|
48 |
} |
|
49 |
|
|
50 |
public String getName() throws AccessResourceException { |
|
51 |
return getClass().getName(); |
|
52 |
} |
|
53 |
|
|
54 |
public boolean isThis(ResourceParameters parameters) |
|
55 |
throws ResourceException { |
|
56 |
return false; |
|
57 |
} |
|
58 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/resource/spi/AbstractResourceTest.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 |
* 2009 {} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.dal.resource.spi; |
|
28 |
|
|
29 |
import junit.framework.TestCase; |
|
30 |
|
|
31 |
import org.easymock.MockControl; |
|
32 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
|
33 |
import org.gvsig.fmap.dal.resource.ResourceParameters; |
|
34 |
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyOpenException; |
|
35 |
|
|
36 |
/** |
|
37 |
* Unit tests for the class {@link AbstractResource} |
|
38 |
* |
|
39 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
40 |
*/ |
|
41 |
public class AbstractResourceTest extends TestCase { |
|
42 |
|
|
43 |
private AbstractResource resource; |
|
44 |
private MockControl paramsControl; |
|
45 |
private ResourceParameters params; |
|
46 |
|
|
47 |
protected void setUp() throws Exception { |
|
48 |
super.setUp(); |
|
49 |
paramsControl = MockControl.createNiceControl(ResourceParameters.class); |
|
50 |
params = (ResourceParameters) paramsControl.getMock(); |
|
51 |
resource = new TestResource(params); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Test method for {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#getLastTimeOpen()}. |
|
56 |
*/ |
|
57 |
public void testGetLastTimeOpen() throws ResourceNotifyOpenException { |
|
58 |
long time = resource.getLastTimeOpen(); |
|
59 |
resource.notifyOpen(); |
|
60 |
assertTrue("The resource last time open hasn't been updated", |
|
61 |
resource.getLastTimeOpen() > time); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Test method for {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#getLastTimeUsed()}. |
|
66 |
*/ |
|
67 |
public void testGetLastTimeUsed() throws Exception { |
|
68 |
long time = resource.getLastTimeUsed(); |
|
69 |
resource.execute(new ResourceAction() { |
|
70 |
public Object run() throws Exception { |
|
71 |
try { |
|
72 |
// Wait for 100 milliseconds |
|
73 |
Thread.sleep(100); |
|
74 |
} catch (InterruptedException e) { |
|
75 |
// No problem |
|
76 |
} |
|
77 |
return null; |
|
78 |
} |
|
79 |
}); |
|
80 |
assertTrue("The resource last time used hasn't been updated", |
|
81 |
resource.getLastTimeUsed() > time); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Test method for {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#openCount()}. |
|
86 |
*/ |
|
87 |
public void testOpenCount() throws Exception { |
|
88 |
assertEquals(0, resource.openCount()); |
|
89 |
resource.notifyOpen(); |
|
90 |
assertEquals(1, resource.openCount()); |
|
91 |
resource.notifyOpen(); |
|
92 |
resource.notifyOpen(); |
|
93 |
assertEquals(3, resource.openCount()); |
|
94 |
resource.notifyClose(); |
|
95 |
assertEquals(2, resource.openCount()); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Test method for |
|
100 |
* {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#execute(java.lang.Runnable)} |
|
101 |
* . |
|
102 |
*/ |
|
103 |
public void testExecute() throws Exception { |
|
104 |
final MutableBoolean testValue = new MutableBoolean(); |
|
105 |
resource.execute(new ResourceAction() { |
|
106 |
public Object run() throws Exception { |
|
107 |
testValue.setValue(true); |
|
108 |
return null; |
|
109 |
} |
|
110 |
}); |
|
111 |
assertTrue("Runnable execution not performed", testValue.isValue()); |
|
112 |
} |
|
113 |
|
|
114 |
public class MutableBoolean { |
|
115 |
private boolean value = false; |
|
116 |
|
|
117 |
public void setValue(boolean value) { |
|
118 |
this.value = value; |
|
119 |
} |
|
120 |
|
|
121 |
public boolean isValue() { |
|
122 |
return value; |
|
123 |
} |
|
124 |
} |
|
125 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/resource/spi/TestNonBlockingResource.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 |
* 2009 {} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.dal.resource.spi; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
30 |
import org.gvsig.fmap.dal.resource.ResourceParameters; |
|
31 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
32 |
import org.gvsig.fmap.dal.resource.exception.ResourceException; |
|
33 |
|
|
34 |
/** |
|
35 |
* Test resource implementation. |
|
36 |
* |
|
37 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
38 |
*/ |
|
39 |
public class TestNonBlockingResource extends AbstractNonBlockingResource { |
|
40 |
|
|
41 |
protected TestNonBlockingResource(ResourceParameters parameters) |
|
42 |
throws InitializeException { |
|
43 |
super(parameters); |
|
44 |
} |
|
45 |
|
|
46 |
public Object get() throws AccessResourceException { |
|
47 |
return getName(); |
|
48 |
} |
|
49 |
|
|
50 |
public String getName() throws AccessResourceException { |
|
51 |
return getClass().getName(); |
|
52 |
} |
|
53 |
|
|
54 |
public boolean isThis(ResourceParameters parameters) |
|
55 |
throws ResourceException { |
|
56 |
return false; |
|
57 |
} |
|
58 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/resource/spi/TestAbstractResourcePerformance.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.resource.spi; |
|
2 |
|
|
3 |
import junit.framework.TestCase; |
|
4 |
|
|
5 |
import org.easymock.MockControl; |
|
6 |
import org.gvsig.fmap.dal.resource.Resource; |
|
7 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
|
8 |
import org.gvsig.fmap.dal.resource.ResourceParameters; |
|
9 |
|
|
10 |
public class TestAbstractResourcePerformance extends TestCase { |
|
11 |
private MockControl paramsControl; |
|
12 |
private ResourceParameters params; |
|
13 |
private AbstractResource resource; |
|
14 |
private MockControl paramsControl2; |
|
15 |
private ResourceParameters params2; |
|
16 |
private AbstractNonBlockingResource nonBlockingResource; |
|
17 |
|
|
18 |
protected void setUp() throws Exception { |
|
19 |
super.setUp(); |
|
20 |
paramsControl = MockControl.createNiceControl(ResourceParameters.class); |
|
21 |
params = (ResourceParameters) paramsControl.getMock(); |
|
22 |
resource = new TestResource(params); |
|
23 |
paramsControl2 = |
|
24 |
MockControl.createNiceControl(ResourceParameters.class); |
|
25 |
params2 = (ResourceParameters) paramsControl2.getMock(); |
|
26 |
nonBlockingResource = new TestNonBlockingResource(params2); |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Test method for |
|
31 |
* {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#execute(java.lang.Runnable)} |
|
32 |
* . |
|
33 |
*/ |
|
34 |
public void testExecuteBlockingPerformance() throws Exception { |
|
35 |
executePerformance(new ResourceAction() { |
|
36 |
public Object run() throws Exception { |
|
37 |
return null; |
|
38 |
} |
|
39 |
}, resource); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Test method for |
|
44 |
* {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#execute(java.lang.Runnable)} |
|
45 |
* . |
|
46 |
*/ |
|
47 |
public void testExecuteNonBlockingPerformance() throws Exception { |
|
48 |
executePerformance(new ResourceAction() { |
|
49 |
public Object run() throws Exception { |
|
50 |
return null; |
|
51 |
} |
|
52 |
}, nonBlockingResource); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Test method for |
|
57 |
* {@link org.gvsig.fmap.dal.resource.spi.AbstractResource#execute(java.lang.Runnable)} |
|
58 |
* . |
|
59 |
*/ |
|
60 |
public void executePerformance(ResourceAction action, Resource resource) |
|
61 |
throws Exception { |
|
62 |
|
|
63 |
final int executions = 100000; |
|
64 |
long time1 = System.currentTimeMillis(); |
|
65 |
for (int i = 0; i < executions; i++) { |
|
66 |
resource.execute(action); |
|
67 |
} |
|
68 |
long time2 = System.currentTimeMillis(); |
|
69 |
|
|
70 |
System.out.print(resource.getName()); |
|
71 |
System.out.print(": total time: " + (time2 - time1) + " ms."); |
|
72 |
System.out.println(" - time per execution: " |
|
73 |
+ ((float) (time2 - time1) / (float) executions) + " ms."); |
|
74 |
} |
|
75 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import junit.framework.TestSuite; |
|
6 |
|
|
7 |
import org.gvsig.fmap.dal.commands.CommandTest; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureTest; |
|
9 |
|
|
10 |
public class AllTests extends TestCase{ |
|
11 |
public static Test suite() { |
|
12 |
TestSuite suite = new TestSuite("Test for libDataSource"); |
|
13 |
//$JUnit-BEGIN$ |
|
14 |
suite.addTestSuite(CommandTest.class); |
|
15 |
suite.addTestSuite(DataStoreTest.class); |
|
16 |
suite.addTestSuite(FeatureTest.class); |
|
17 |
|
|
18 |
//$JUnit-END$ |
|
19 |
return suite; |
|
20 |
} |
|
21 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/feature/BaseTestEditableFeatureStore.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 |
* 2009 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.dal.feature; |
|
32 |
|
|
33 |
import java.util.Iterator; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
36 |
import org.gvsig.fmap.dal.DataStore; |
|
37 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
38 |
import org.gvsig.fmap.dal.DataTypes; |
|
39 |
import org.gvsig.fmap.dal.exception.DataException; |
|
40 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
41 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
42 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
|
43 |
import org.gvsig.fmap.dal.feature.testmulithread.DeleteFirstAndLastFeature; |
|
44 |
import org.gvsig.fmap.dal.feature.testmulithread.DeleteLastFeature; |
|
45 |
import org.gvsig.fmap.dal.feature.testmulithread.InsertFeature; |
|
46 |
import org.gvsig.fmap.dal.feature.testmulithread.StoreTask; |
|
47 |
import org.gvsig.fmap.dal.feature.testmulithread.UpdateFeature; |
|
48 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
49 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
|
50 |
import org.gvsig.tools.evaluator.Evaluator; |
|
51 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
52 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
53 |
import org.gvsig.tools.evaluator.EvaluatorFieldValue; |
|
54 |
import org.gvsig.tools.observer.Observable; |
|
55 |
import org.gvsig.tools.observer.Observer; |
|
56 |
|
|
57 |
/** |
|
58 |
* @author jmvivo |
|
59 |
* |
|
60 |
*/ |
|
61 |
public abstract class BaseTestEditableFeatureStore extends BaseTestFeatureStore { |
|
62 |
|
|
63 |
public abstract NewFeatureStoreParameters getDefaultNewDataStoreParameters() |
|
64 |
throws Exception; |
|
65 |
|
|
66 |
public abstract boolean resourcesNotifyChanges(); |
|
67 |
|
|
68 |
//================================================= |
|
69 |
//================================================= |
|
70 |
|
|
71 |
|
|
72 |
public void fillPrimaryKeyInserFeature(EditableFeature feature) { |
|
73 |
return; |
|
74 |
} |
|
75 |
|
|
76 |
protected Evaluator getEvaluatorToLower(String attibuteName) { |
|
77 |
return new ToLower(attibuteName); |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
protected Evaluator getEvaluatorToUpper(String attibuteName) { |
|
82 |
return new ToUpper(attibuteName); |
|
83 |
} |
|
84 |
|
|
85 |
public class ToLower extends AbstractEvaluator { |
|
86 |
private String attributeName; |
|
87 |
|
|
88 |
public ToLower(String attrName) { |
|
89 |
this.attributeName = attrName; |
|
90 |
this.getFieldsInfo().addFieldValue(this.attributeName); |
|
91 |
} |
|
92 |
|
|
93 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
94 |
String value = (String) data.getDataValue(this.attributeName); |
|
95 |
if (value == null) { |
|
96 |
return null; |
|
97 |
} |
|
98 |
return value.toLowerCase(); |
|
99 |
} |
|
100 |
|
|
101 |
public String getSQL() { |
|
102 |
return null; |
|
103 |
} |
|
104 |
|
|
105 |
public String getDescription() { |
|
106 |
return null; |
|
107 |
} |
|
108 |
|
|
109 |
public String getName() { |
|
110 |
return null; |
|
111 |
} |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
public class ToUpper extends AbstractEvaluator { |
|
116 |
private String attributeName; |
|
117 |
|
|
118 |
public ToUpper(String attrName) { |
|
119 |
this.attributeName = attrName; |
|
120 |
this.getFieldsInfo().addFieldValue(this.attributeName); |
|
121 |
} |
|
122 |
|
|
123 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
124 |
String value = (String) data.getDataValue(this.attributeName); |
|
125 |
if (value == null) { |
|
126 |
return null; |
|
127 |
} |
|
128 |
return value.toUpperCase(); |
|
129 |
} |
|
130 |
|
|
131 |
public String getSQL() { |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
public String getDescription() { |
|
136 |
return null; |
|
137 |
} |
|
138 |
|
|
139 |
public EvaluatorFieldValue[] getFieldValues(String name) { |
|
140 |
return null; |
|
141 |
} |
|
142 |
|
|
143 |
public String getName() { |
|
144 |
return null; |
|
145 |
} |
|
146 |
|
|
147 |
} |
|
148 |
|
|
149 |
protected FeatureStore getStoreCopy(FeatureStore source, |
|
150 |
NewFeatureStoreParameters targetParams) throws DataException, |
|
151 |
ValidateDataParametersException { |
|
152 |
DataServerExplorer explorer = source.getExplorer(); |
|
153 |
source.export(explorer, source.getProviderName(), targetParams); |
|
154 |
FeatureStore result = (FeatureStore) dataManager.openStore(source.getProviderName(), targetParams); |
|
155 |
|
|
156 |
return result; |
|
157 |
} |
|
158 |
|
|
159 |
protected void clearCopy(FeatureStore source, |
|
160 |
NewFeatureStoreParameters targetParams) throws Exception { |
|
161 |
DataServerExplorer explorer = source.getExplorer(); |
|
162 |
explorer.remove(targetParams); |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
protected boolean compareFeatures(Feature f1, Feature f2, |
|
167 |
String[] attrsNames, UpdateFeature updated, long index, |
|
168 |
long lastIndex) throws DataException, EvaluatorException { |
|
169 |
FeatureAttributeDescriptor attr1; |
|
170 |
FeatureAttributeDescriptor attr2; |
|
171 |
EditableFeature f2e = f2.getEditable(); |
|
172 |
updated.applyUpdateList(f2e, index, lastIndex); |
|
173 |
|
|
174 |
Object v1, v2; |
|
175 |
for (int i = 0; i < attrsNames.length; i++) { |
|
176 |
attr1 = f1.getType().getAttributeDescriptor(attrsNames[i]); |
|
177 |
attr2 = f2e.getType().getAttributeDescriptor(attrsNames[i]); |
|
178 |
if (attr1 != attr2) { |
|
179 |
if (!compareAttributes(attr1, attr1)) { |
|
180 |
return false; |
|
181 |
} |
|
182 |
} |
|
183 |
v1 = f1.get(attr1.getName()); |
|
184 |
v2 = f2.get(attr2.getName()); |
|
185 |
if (!compareFeatureValue(v1, v2, attr1)) { |
|
186 |
return false; |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
return true; |
|
191 |
} |
|
192 |
|
|
193 |
protected boolean compareFeatures(Feature f1, Feature f2, |
|
194 |
UpdateFeature updated, long index, long lastIndex) |
|
195 |
throws DataException, EvaluatorException { |
|
196 |
if (!compareTypes(f1.getType(), f2.getType())) { |
|
197 |
System.out.println("compareFeatures() type !="); |
|
198 |
return false; |
|
199 |
} |
|
200 |
Iterator iter = f1.getType().iterator(); |
|
201 |
FeatureAttributeDescriptor attr; |
|
202 |
EditableFeature f1e = f1.getEditable(); |
|
203 |
updated.applyUpdateList(f1e, index, lastIndex); |
|
204 |
Object v1, v2; |
|
205 |
while (iter.hasNext()) { |
|
206 |
attr = (FeatureAttributeDescriptor) iter.next(); |
|
207 |
v1 = f1e.get(attr.getName()); |
|
208 |
v2 = f2.get(attr.getName()); |
|
209 |
if (!compareFeatureValue(v1, v2, attr)) { |
|
210 |
return false; |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
return true; |
|
216 |
|
|
217 |
} |
|
218 |
|
|
219 |
|
|
220 |
//--------------- |
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
//================================================= |
|
226 |
//================================================= |
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
public void testExport() throws Exception { |
|
232 |
DataStoreParameters parameters = null; |
|
233 |
|
|
234 |
parameters = getDefaultDataStoreParameters(); |
|
235 |
|
|
236 |
FeatureStore store = (FeatureStore) dataManager.createStore(parameters); |
|
237 |
|
|
238 |
NewFeatureStoreParameters newParams = this |
|
239 |
.getDefaultNewDataStoreParameters(); |
|
240 |
try { |
|
241 |
this.clearCopy(store, newParams); |
|
242 |
} catch (RemoveException e) { |
|
243 |
// Dp nothing |
|
244 |
} |
|
245 |
|
|
246 |
FeatureStore result = this.getStoreCopy(store, newParams); |
|
247 |
|
|
248 |
fullStoreIteratorTest(result); |
|
249 |
|
|
250 |
FeatureSet set; |
|
251 |
FeatureSet originalSet; |
|
252 |
if (result.getDefaultFeatureType().getPrimaryKey() != null |
|
253 |
&& result.getDefaultFeatureType().getPrimaryKey().length > 0) { |
|
254 |
FeatureQuery queryR = result.createFeatureQuery(); |
|
255 |
FeatureQuery queryO = store.createFeatureQuery(); |
|
256 |
FeatureAttributeDescriptor[] pk = result.getDefaultFeatureType() |
|
257 |
.getPrimaryKey(); |
|
258 |
for (int i = 0; i < pk.length; i++) { |
|
259 |
queryO.getOrder().add(pk[i].getName(), true); |
|
260 |
queryR.getOrder().add(pk[i].getName(), true); |
|
261 |
} |
|
262 |
|
|
263 |
|
|
264 |
set = result.getFeatureSet(queryR); |
|
265 |
originalSet = store.getFeatureSet(queryO); |
|
266 |
|
|
267 |
|
|
268 |
} else { |
|
269 |
set = result.getFeatureSet(); |
|
270 |
originalSet = store.getFeatureSet(); |
|
271 |
} |
|
272 |
assertEquals(set.getSize(), originalSet.getSize()); |
|
273 |
|
|
274 |
DisposableIterator originalIter = originalSet.iterator(); |
|
275 |
DisposableIterator iter = set.iterator(); |
|
276 |
assertTrue(compareFeatureIterators(originalIter, iter)); |
|
277 |
originalIter.dispose(); |
|
278 |
iter.dispose(); |
|
279 |
|
|
280 |
if (store.getEnvelope() != result.getEnvelope()) { |
|
281 |
if (store.getEnvelope() != null) { |
|
282 |
assertTrue(store.getEnvelope().equals(result.getEnvelope())); |
|
283 |
} else { |
|
284 |
fail("Envelope: src=" + store.getEnvelope() + " traget=" |
|
285 |
+ store.getEnvelope()); |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
set.dispose(); |
|
290 |
originalSet.dispose(); |
|
291 |
|
|
292 |
result.dispose(); |
|
293 |
this.clearCopy(store, newParams); |
|
294 |
store.dispose(); |
|
295 |
|
|
296 |
} |
|
297 |
|
|
298 |
public void testRemove() throws Exception { |
|
299 |
DataStoreParameters parameters = null; |
|
300 |
|
|
301 |
parameters = getDefaultDataStoreParameters(); |
|
302 |
|
|
303 |
FeatureStore store = (FeatureStore) dataManager.createStore(parameters); |
|
304 |
|
|
305 |
NewFeatureStoreParameters newParams = this |
|
306 |
.getDefaultNewDataStoreParameters(); |
|
307 |
try { |
|
308 |
this.clearCopy(store, newParams); |
|
309 |
} catch (RemoveException e) { |
|
310 |
// Dp nothing |
|
311 |
} |
|
312 |
|
|
313 |
FeatureStore result = this.getStoreCopy(store, newParams); |
|
314 |
|
|
315 |
result.edit(FeatureStore.MODE_FULLEDIT); |
|
316 |
|
|
317 |
FeatureSet set = result.getFeatureSet(getDefaultQuery(result)); |
|
318 |
FeatureSet originalSet = store.getFeatureSet(getDefaultQuery(store)); |
|
319 |
assertEquals(set.getSize(), originalSet.getSize()); |
|
320 |
|
|
321 |
DisposableIterator originalIter = originalSet.iterator(); |
|
322 |
DisposableIterator iter = set.iterator(); |
|
323 |
int i = 0; |
|
324 |
while (iter.hasNext()) { |
|
325 |
assertTrue("" + i, compareFeatures((Feature) originalIter.next(), |
|
326 |
(Feature) iter.next())); |
|
327 |
i++; |
|
328 |
} |
|
329 |
|
|
330 |
iter.remove(); |
|
331 |
|
|
332 |
|
|
333 |
assertEquals(originalSet.getSize() - 1, set.getSize()); |
|
334 |
|
|
335 |
iter.dispose(); |
|
336 |
originalIter.dispose(); |
|
337 |
|
|
338 |
|
|
339 |
originalIter = originalSet.iterator(); |
|
340 |
iter = set.iterator(); |
|
341 |
i = 0; |
|
342 |
while (iter.hasNext()) { |
|
343 |
assertTrue("" + i, compareFeatures((Feature) originalIter.next(), |
|
344 |
(Feature) iter.next())); |
|
345 |
i++; |
|
346 |
} |
|
347 |
|
|
348 |
iter.remove(); |
|
349 |
|
|
350 |
assertEquals(originalSet.getSize() - 2, set.getSize()); |
|
351 |
|
|
352 |
iter.dispose(); |
|
353 |
originalIter.dispose(); |
|
354 |
|
|
355 |
set.dispose(); |
|
356 |
|
|
357 |
result.finishEditing(); |
|
358 |
|
|
359 |
set = result.getFeatureSet(); |
|
360 |
assertEquals(originalSet.getSize() - 2, set.getSize()); |
|
361 |
|
|
362 |
originalIter = originalSet.iterator(); |
|
363 |
iter = set.iterator(); |
|
364 |
i = 0; |
|
365 |
while (iter.hasNext()) { |
|
366 |
assertTrue("" + i, compareFeatures((Feature) originalIter.next(), |
|
367 |
(Feature) iter.next())); |
|
368 |
i++; |
|
369 |
} |
|
370 |
|
|
371 |
iter.dispose(); |
|
372 |
originalIter.dispose(); |
|
373 |
|
|
374 |
|
|
375 |
set.dispose(); |
|
376 |
originalSet.dispose(); |
|
377 |
|
|
378 |
result.dispose(); |
|
379 |
this.clearCopy(store, newParams); |
|
380 |
store.dispose(); |
|
381 |
|
|
382 |
|
|
383 |
} |
|
384 |
|
|
385 |
public void testInsert() throws Exception { |
|
386 |
DataStoreParameters parameters = null; |
|
387 |
|
|
388 |
parameters = getDefaultDataStoreParameters(); |
|
389 |
|
|
390 |
|
|
391 |
FeatureStore store = (FeatureStore) dataManager |
|
392 |
.createStore(parameters); |
|
393 |
|
|
394 |
NewFeatureStoreParameters newParams = this |
|
395 |
.getDefaultNewDataStoreParameters(); |
|
396 |
try { |
|
397 |
this.clearCopy(store, newParams); |
|
398 |
} catch (RemoveException e) { |
|
399 |
//Do nothing |
|
400 |
} |
|
401 |
|
|
402 |
FeatureStore result = this.getStoreCopy(store, newParams); |
|
403 |
|
|
404 |
result.edit(FeatureStore.MODE_FULLEDIT); |
|
405 |
|
|
406 |
FeatureSet set = result.getFeatureSet(getDefaultQuery(result)); |
|
407 |
FeatureSet originalSet = store.getFeatureSet(getDefaultQuery(store)); |
|
408 |
assertEquals(set.getSize(), originalSet.getSize()); |
|
409 |
|
|
410 |
EditableFeature newFeature = result.createNewFeature(true); |
|
411 |
fillPrimaryKeyInserFeature(newFeature); |
|
412 |
set.insert(newFeature); |
|
413 |
DisposableIterator originalIter = originalSet.iterator(); |
|
414 |
DisposableIterator iter = set.iterator(); |
|
415 |
int i = 0; |
|
416 |
while (originalIter.hasNext()) { |
|
417 |
assertTrue("" + i, compareFeatures((Feature) originalIter |
|
418 |
.next(), (Feature) iter.next())); |
|
419 |
i++; |
|
420 |
} |
|
421 |
assertTrue(iter.hasNext()); |
|
422 |
assertNotNull(iter.next()); |
|
423 |
assertFalse(iter.hasNext()); |
|
424 |
|
|
425 |
assertEquals(originalSet.getSize() + 1, set.getSize()); |
|
426 |
|
|
427 |
iter.dispose(); |
|
428 |
originalIter.dispose(); |
|
429 |
|
|
430 |
originalIter = originalSet.iterator(); |
|
431 |
iter = set.iterator(); |
|
432 |
i = 0; |
|
433 |
while (originalIter.hasNext()) { |
|
434 |
assertTrue("" + i, compareFeatures((Feature) originalIter |
|
435 |
.next(), (Feature) iter.next())); |
|
436 |
i++; |
|
437 |
} |
|
438 |
assertTrue(iter.hasNext()); |
|
439 |
assertNotNull(iter.next()); |
|
440 |
|
|
441 |
newFeature = result.createNewFeature(true); |
|
442 |
fillPrimaryKeyInserFeature(newFeature); |
|
443 |
set.insert(newFeature); |
|
444 |
|
|
445 |
assertEquals(originalSet.getSize() + 2, set.getSize()); |
|
446 |
|
|
447 |
iter.dispose(); |
|
448 |
originalIter.dispose(); |
|
449 |
|
|
450 |
set.dispose(); |
|
451 |
|
|
452 |
result.finishEditing(); |
|
453 |
|
|
454 |
set = result.getFeatureSet(); |
|
455 |
assertEquals(originalSet.getSize() + 2, set.getSize()); |
|
456 |
|
|
457 |
originalIter = originalSet.iterator(); |
|
458 |
iter = set.iterator(); |
|
459 |
i = 0; |
|
460 |
while (originalIter.hasNext()) { |
|
461 |
assertTrue("" + i, compareFeatures((Feature) originalIter |
|
462 |
.next(), (Feature) iter.next())); |
|
463 |
i++; |
|
464 |
} |
|
465 |
|
|
466 |
assertNotNull(iter.next()); |
|
467 |
assertNotNull(iter.next()); |
|
468 |
assertFalse(iter.hasNext()); |
|
469 |
|
|
470 |
iter.dispose(); |
|
471 |
originalIter.dispose(); |
|
472 |
|
|
473 |
set.dispose(); |
|
474 |
originalSet.dispose(); |
|
475 |
|
|
476 |
result.dispose(); |
|
477 |
this.clearCopy(store, newParams); |
|
478 |
store.dispose(); |
|
479 |
|
|
480 |
|
|
481 |
} |
|
482 |
|
|
483 |
|
|
484 |
|
|
485 |
public void testConcurrentRemove() throws Exception { |
|
486 |
DataStoreParameters parameters = null; |
|
487 |
|
|
488 |
parameters = getDefaultDataStoreParameters(); |
|
489 |
|
|
490 |
|
|
491 |
FeatureStore store = (FeatureStore) dataManager.createStore(parameters); |
|
492 |
|
|
493 |
NewFeatureStoreParameters newParams = this |
|
494 |
.getDefaultNewDataStoreParameters(); |
|
495 |
try { |
|
496 |
this.clearCopy(store, newParams); |
|
497 |
} catch (RemoveException e) { |
|
498 |
// Dp nothing |
|
499 |
} |
|
500 |
|
|
501 |
FeatureStore result = this.getStoreCopy(store, newParams); |
|
502 |
|
|
503 |
result.edit(FeatureStore.MODE_FULLEDIT); |
|
504 |
|
|
505 |
DeleteFirstAndLastFeature deleteFeature = new DeleteFirstAndLastFeature( |
|
506 |
"1", result, StoreTask.TIME_TO_WAIT_NO_WAIT); |
|
507 |
|
|
508 |
FeatureSet set = result.getFeatureSet(); |
|
509 |
|
|
510 |
DisposableIterator iter = set.iterator(); |
|
511 |
assertTrue(iter.hasNext()); |
|
512 |
assertNotNull(iter.next()); |
|
513 |
|
|
514 |
deleteFeature.start(); |
|
515 |
|
|
516 |
while (deleteFeature.getCurrentStatus() <= StoreTask.STATUS_RUNING) { |
|
517 |
Thread.yield(); |
|
518 |
Thread.sleep(100); |
|
519 |
if (deleteFeature.isOutOfDate()) { |
|
520 |
break; |
|
521 |
} |
|
522 |
} |
|
523 |
|
|
524 |
assertEquals(deleteFeature.getCurrentStatus(), |
|
525 |
StoreTask.STATUS_FINISHED_OK); |
|
526 |
|
|
527 |
Exception ex = null; |
|
528 |
try { |
|
529 |
iter.next(); |
|
530 |
} catch (Exception e) { |
|
531 |
ex = e; |
|
532 |
} |
|
533 |
assertNotNull(ex); |
|
534 |
assertEquals(ConcurrentDataModificationException.class, ex.getClass()); |
|
535 |
|
|
536 |
ex = null; |
|
537 |
try { |
|
538 |
set.getSize(); |
|
539 |
} catch (Exception e) { |
|
540 |
ex = e; |
|
541 |
} |
|
542 |
assertNotNull(ex); |
|
543 |
assertEquals(ConcurrentDataModificationException.class, ex.getClass()); |
|
544 |
|
|
545 |
iter.dispose(); |
|
546 |
result.dispose(); |
|
547 |
this.clearCopy(store, newParams); |
|
548 |
store.dispose(); |
|
549 |
|
|
550 |
} |
|
551 |
|
|
552 |
public void testConcurrentInsert() throws Exception{ |
|
553 |
DataStoreParameters parameters = null; |
|
554 |
|
|
555 |
parameters = getDefaultDataStoreParameters(); |
|
556 |
|
|
557 |
|
|
558 |
FeatureStore store = (FeatureStore) dataManager.createStore(parameters); |
|
559 |
|
|
560 |
NewFeatureStoreParameters newParams = this |
|
561 |
.getDefaultNewDataStoreParameters(); |
|
562 |
try { |
|
563 |
this.clearCopy(store, newParams); |
|
564 |
} catch (RemoveException e) { |
|
565 |
// Dp nothing |
|
566 |
} |
|
567 |
|
|
568 |
FeatureStore result = this.getStoreCopy(store, newParams); |
|
569 |
|
|
570 |
result.edit(FeatureStore.MODE_FULLEDIT); |
|
571 |
|
|
572 |
InsertFeature insertFeature = new InsertFeature("1", result, |
|
573 |
StoreTask.TIME_TO_WAIT_NO_WAIT, this); |
|
574 |
|
|
575 |
FeatureSet set = result.getFeatureSet(); |
|
576 |
|
|
577 |
DisposableIterator iter = set.iterator(); |
|
578 |
assertTrue(iter.hasNext()); |
|
579 |
assertNotNull(iter.next()); |
|
580 |
|
|
581 |
insertFeature.start(); |
|
582 |
|
|
583 |
while (insertFeature.getCurrentStatus() <= StoreTask.STATUS_RUNING) { |
|
584 |
Thread.yield(); |
|
585 |
Thread.sleep(100); |
|
586 |
if (insertFeature.isOutOfDate()) { |
|
587 |
break; |
|
588 |
} |
|
589 |
} |
|
590 |
|
|
591 |
assertEquals(StoreTask.STATUS_FINISHED_OK, insertFeature |
|
592 |
.getCurrentStatus()); |
|
593 |
|
|
594 |
Exception ex = null; |
|
595 |
try { |
|
596 |
iter.next(); |
|
597 |
} catch (Exception e) { |
|
598 |
ex = e; |
|
599 |
} |
|
600 |
assertNotNull(ex); |
|
601 |
assertEquals(ConcurrentDataModificationException.class, ex.getClass()); |
|
602 |
|
|
603 |
ex = null; |
|
604 |
try { |
|
605 |
set.getSize(); |
|
606 |
} catch (Exception e) { |
|
607 |
ex = e; |
|
608 |
} |
|
609 |
assertNotNull(ex); |
|
610 |
assertEquals(ConcurrentDataModificationException.class, ex.getClass()); |
|
611 |
|
|
612 |
iter.dispose(); |
|
613 |
result.dispose(); |
|
614 |
this.clearCopy(store, newParams); |
|
615 |
store.dispose(); |
|
616 |
} |
|
617 |
|
|
618 |
public void testConcurrentUpdate() throws Exception { |
|
619 |
DataStoreParameters parameters = null; |
|
620 |
|
|
621 |
parameters = getDefaultDataStoreParameters(); |
|
622 |
|
|
623 |
|
|
624 |
FeatureStore store = (FeatureStore) dataManager.createStore(parameters); |
|
625 |
|
|
626 |
NewFeatureStoreParameters newParams = this |
Also available in: Unified diff