Revision 32478
branches/v2_0_0_prep/libraries/org.gvsig.geocoding/src-test/org/gvsig/geocoding/data/FilterTest.java | ||
---|---|---|
1 |
package org.gvsig.geocoding.data; |
|
2 |
|
|
3 |
import org.gvsig.LayerServer; |
|
4 |
import org.gvsig.fmap.dal.DALLocator; |
|
5 |
import org.gvsig.fmap.dal.DataManager; |
|
6 |
import org.gvsig.fmap.dal.exception.DataException; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.tools.evaluator.Evaluator; |
|
11 |
import org.gvsig.tools.evaluator.sqljep.SQLJEPEvaluator; |
|
12 |
import org.gvsig.tools.evaluator.sqljep.SQLJEPLibrary; |
|
13 |
import org.gvsig.tools.library.Library; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
/** |
|
18 |
* Test |
|
19 |
* |
|
20 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
21 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicent Sanjaime Calvet</a> |
|
22 |
*/ |
|
23 |
public class FilterTest extends |
|
24 |
org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase { |
|
25 |
|
|
26 |
@SuppressWarnings("unused") |
|
27 |
private Logger log = LoggerFactory.getLogger(FilterTest.class); |
|
28 |
private DataManager manager = null; |
|
29 |
private FeatureSet features = null; |
|
30 |
|
|
31 |
/** |
|
32 |
* tearDown |
|
33 |
*/ |
|
34 |
protected void tearDown() throws Exception { |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* Simple search |
|
40 |
* |
|
41 |
* @throws DataException |
|
42 |
*/ |
|
43 |
public void testSimpleFilter() throws Exception { |
|
44 |
|
|
45 |
FeatureStore store = LayerServer.getSHPStore(LayerServer |
|
46 |
.getStreetsFile()); |
|
47 |
System.out.println("Number of features: " |
|
48 |
+ store.getFeatureSet().getSize()); |
|
49 |
|
|
50 |
FeatureQuery query = store.createFeatureQuery(); |
|
51 |
Evaluator exp = manager.createExpresion("STREET_TYP like '%C%'"); |
|
52 |
query.setFilter(exp); |
|
53 |
features = store.getFeatureSet(query); |
|
54 |
System.out.println("Number of features finded: " + features.getSize()); |
|
55 |
assertEquals(1185, features.getSize()); |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
protected void doSetUp() throws Exception { |
|
60 |
|
|
61 |
Library sql = new SQLJEPLibrary(); |
|
62 |
sql.initialize(); |
|
63 |
sql.postInitialize(); |
|
64 |
|
|
65 |
manager = DALLocator.getDataManager(); |
|
66 |
manager.registerDefaultEvaluator(SQLJEPEvaluator.class); |
|
67 |
|
|
68 |
} |
|
69 |
} |
|
0 | 70 |
branches/v2_0_0_prep/libraries/org.gvsig.geocoding/src-test/org/gvsig/geocoding/data/AllTests.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Prodevelop S.L main development |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.geocoding.data; |
|
29 |
|
|
30 |
import junit.framework.Test; |
|
31 |
import junit.framework.TestSuite; |
|
32 |
|
|
33 |
/** |
|
34 |
* All Test |
|
35 |
* |
|
36 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
37 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
38 |
*/ |
|
39 |
public class AllTests { |
|
40 |
|
|
41 |
public static Test suite() { |
|
42 |
TestSuite suite = new TestSuite("Test for org.gvsig.geocoding.data"); |
|
43 |
// $JUnit-BEGIN$ |
|
44 |
suite.addTestSuite(FilterTest.class); |
|
45 |
|
|
46 |
// $JUnit-END$ |
|
47 |
return suite; |
|
48 |
} |
|
49 |
|
|
50 |
} |
|
0 | 51 |
Also available in: Unified diff