root / trunk / org.gvsig.postgresql / org.gvsig.postgresql.provider / src / test / java / org / gvsig / fmap / dal / store / postgresql / TestPostgreSQL.java @ 5
History | View | Annotate | Download (4.64 KB)
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 {{Task}}
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
package org.gvsig.fmap.dal.store.postgresql; |
32 |
|
33 |
import org.gvsig.fmap.dal.DataStoreParameters; |
34 |
import org.gvsig.fmap.dal.exception.DataException; |
35 |
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore; |
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
39 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
40 |
import org.gvsig.fmap.dal.feature.FeatureType; |
41 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
42 |
import org.gvsig.fmap.geom.Geometry; |
43 |
import org.gvsig.tools.evaluator.Evaluator; |
44 |
import org.gvsig.tools.evaluator.EvaluatorData; |
45 |
import org.gvsig.tools.evaluator.EvaluatorException; |
46 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
47 |
|
48 |
/**
|
49 |
* @author jmvivo
|
50 |
*
|
51 |
*/
|
52 |
// public class TestPostgreSQL extends BaseTestEditableFeatureStore {
|
53 |
public class TestPostgreSQL extends BaseTestFeatureStore { |
54 |
|
55 |
@Override
|
56 |
protected void doSetUp() throws Exception { |
57 |
super.doSetUp();
|
58 |
} |
59 |
|
60 |
public DataStoreParameters getDefaultDataStoreParameters()
|
61 |
throws DataException {
|
62 |
PostgreSQLStoreParameters pgParameters = null;
|
63 |
pgParameters = (PostgreSQLStoreParameters) dataManager |
64 |
.createStoreParameters(PostgreSQLStoreProvider.NAME); |
65 |
|
66 |
pgParameters.setHost("localhost");
|
67 |
pgParameters.setUser("postgres");
|
68 |
pgParameters.setPassword("postgres");
|
69 |
pgParameters.setDBName("gis");
|
70 |
pgParameters.setTable("muni10000_peq");
|
71 |
|
72 |
return pgParameters;
|
73 |
} |
74 |
|
75 |
public boolean hasExplorer() { |
76 |
return true; |
77 |
} |
78 |
|
79 |
public void testLoadMetadata() throws Exception { |
80 |
DataStoreParameters params = this.getDefaultDataStoreParameters();
|
81 |
|
82 |
FeatureStore store = null;
|
83 |
store = (FeatureStore) dataManager.createStore(params); |
84 |
FeatureType fType = store.getDefaultFeatureType(); |
85 |
FeatureAttributeDescriptor geomAttr; |
86 |
|
87 |
|
88 |
|
89 |
if (fType.getDefaultGeometryAttributeIndex() >= 0) { |
90 |
assertNotNull(store.getEnvelope()); |
91 |
geomAttr = fType.getAttributeDescriptor(fType |
92 |
.getDefaultGeometryAttributeIndex()); |
93 |
assertTrue(geomAttr.getGeometryType() == Geometry.TYPES.MULTISURFACE); |
94 |
assertTrue(geomAttr.getGeometrySubType() == Geometry.SUBTYPES.GEOM2D); |
95 |
assertNotNull(store.getDynValue("CRS"));
|
96 |
|
97 |
} |
98 |
|
99 |
} |
100 |
|
101 |
public void testCloserConnection() throws Exception { |
102 |
|
103 |
DataStoreParameters params = this.getDefaultDataStoreParameters();
|
104 |
|
105 |
FeatureStore store = null;
|
106 |
store = (FeatureStore) dataManager.createStore(params); |
107 |
|
108 |
FeatureQuery query = store.createFeatureQuery(); |
109 |
|
110 |
query.getOrder().add("gid", true); |
111 |
|
112 |
query.setFilter(new Evaluator() {
|
113 |
|
114 |
public Object evaluate(EvaluatorData data) |
115 |
throws EvaluatorException {
|
116 |
// TODO Auto-generated method stub
|
117 |
return Boolean.TRUE; |
118 |
} |
119 |
|
120 |
public String getSQL() { |
121 |
return "true = true"; |
122 |
} |
123 |
|
124 |
public String getDescription() { |
125 |
// TODO Auto-generated method stub
|
126 |
return null; |
127 |
} |
128 |
|
129 |
public String getName() { |
130 |
return "AlwaysTrue"; |
131 |
} |
132 |
|
133 |
public EvaluatorFieldsInfo getFieldsInfo() {
|
134 |
// TODO Auto-generated method stub
|
135 |
return null; |
136 |
} |
137 |
|
138 |
}); |
139 |
|
140 |
FeatureStoreTransform transform = new StringsToLowerTransform();
|
141 |
transform.setFeatureStore(store); |
142 |
|
143 |
store.getTransforms().add(transform); |
144 |
|
145 |
transform = new StringsToLowerTransform();
|
146 |
transform.setFeatureStore(store); |
147 |
|
148 |
store.getTransforms().add(transform); |
149 |
|
150 |
transform = new StringsToLowerTransform();
|
151 |
transform.setFeatureStore(store); |
152 |
|
153 |
store.getTransforms().add(transform); |
154 |
|
155 |
for (int i = 0; i < 30; i++) { |
156 |
// this.fullStoreIteratorTest(store);
|
157 |
|
158 |
this.testIterationFastAndStandart(store, query);
|
159 |
} |
160 |
|
161 |
|
162 |
store.dispose(); |
163 |
|
164 |
} |
165 |
|
166 |
public boolean usesResources() { |
167 |
return true; |
168 |
} |
169 |
|
170 |
public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
|
171 |
throws Exception { |
172 |
// TODO Auto-generated method stub
|
173 |
return null; |
174 |
} |
175 |
} |