svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_daldb / src-test / org / gvsig / fmap / dal / store / postgresql / TestPostgreSQL.java @ 29956
History | View | Annotate | Download (5.9 KB)
1 | 27525 | jmvivo | /* 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 | 28302 | jmvivo | package org.gvsig.fmap.dal.store.postgresql; |
32 | 27525 | jmvivo | |
33 | 27986 | jmvivo | import org.cresques.ProjectionLibrary; |
34 | import org.cresques.impl.CresquesCtsLibrary; |
||
35 | 27525 | jmvivo | import org.gvsig.fmap.dal.DALDbLibrary; |
36 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
37 | import org.gvsig.fmap.dal.exception.DataException; |
||
38 | import org.gvsig.fmap.dal.feature.BaseTestFeatureStore; |
||
39 | 27986 | jmvivo | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
40 | 27672 | jmvivo | import org.gvsig.fmap.dal.feature.FeatureQuery; |
41 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
42 | import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
||
43 | 27986 | jmvivo | import org.gvsig.fmap.dal.feature.FeatureType; |
44 | 28191 | jmvivo | import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
45 | 27595 | jmvivo | import org.gvsig.fmap.dal.index.spatial.jts.JTSIndexLibrary; |
46 | 27909 | jmvivo | import org.gvsig.fmap.dal.store.db.DBStoreLibrary; |
47 | 27525 | jmvivo | import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary; |
48 | 27986 | jmvivo | import org.gvsig.fmap.geom.Geometry; |
49 | 27595 | jmvivo | import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary; |
50 | 27672 | jmvivo | 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.EvaluatorFieldsInfo; |
||
54 | 27525 | jmvivo | |
55 | 27986 | jmvivo | |
56 | |||
57 | 27525 | jmvivo | /**
|
58 | * @author jmvivo
|
||
59 | *
|
||
60 | */
|
||
61 | 28191 | jmvivo | // public class TestPostgreSQL extends BaseTestEditableFeatureStore {
|
62 | 27525 | jmvivo | public class TestPostgreSQL extends BaseTestFeatureStore { |
63 | |||
64 | |||
65 | protected void setUp() throws Exception { |
||
66 | super.setUp();
|
||
67 | 29956 | jmvivo | // FIXME
|
68 | // ToolsLocator.registerDefaultPersistenceManager(XMLEntityManager.class);
|
||
69 | 27525 | jmvivo | |
70 | 27595 | jmvivo | DefaultGeometryLibrary defGeomLib = new DefaultGeometryLibrary();
|
71 | defGeomLib.initialize(); |
||
72 | |||
73 | 27986 | jmvivo | ProjectionLibrary projLib = new ProjectionLibrary();
|
74 | projLib.initialize(); |
||
75 | |||
76 | CresquesCtsLibrary cresquesLib = new CresquesCtsLibrary();
|
||
77 | cresquesLib.initialize(); |
||
78 | |||
79 | 27525 | jmvivo | DALDbLibrary libDb = new DALDbLibrary();
|
80 | libDb.initialize(); |
||
81 | |||
82 | 27909 | jmvivo | DBStoreLibrary libDbStore = new DBStoreLibrary();
|
83 | libDbStore.initialize(); |
||
84 | |||
85 | 27525 | jmvivo | JDBCLibrary libJDBC = new JDBCLibrary();
|
86 | libJDBC.initialize(); |
||
87 | |||
88 | PostgreSQLLibrary pgLib = new PostgreSQLLibrary();
|
||
89 | pgLib.initialize(); |
||
90 | |||
91 | 27595 | jmvivo | JTSIndexLibrary jtsIndex = new JTSIndexLibrary();
|
92 | jtsIndex.initialize(); |
||
93 | |||
94 | 27986 | jmvivo | projLib.postInitialize(); |
95 | cresquesLib.postInitialize(); |
||
96 | 27595 | jmvivo | defGeomLib.postInitialize(); |
97 | 27525 | jmvivo | libDb.postInitialize(); |
98 | 27909 | jmvivo | libDbStore.postInitialize(); |
99 | 27525 | jmvivo | libJDBC.postInitialize(); |
100 | pgLib.postInitialize(); |
||
101 | 27595 | jmvivo | jtsIndex.postInitialize(); |
102 | 27525 | jmvivo | } |
103 | |||
104 | public DataStoreParameters getDefaultDataStoreParameters()
|
||
105 | throws DataException {
|
||
106 | PostgreSQLStoreParameters pgParameters = null;
|
||
107 | pgParameters = (PostgreSQLStoreParameters) dataManager |
||
108 | .createStoreParameters(PostgreSQLStoreProvider.NAME); |
||
109 | |||
110 | pgParameters.setHost("localhost");
|
||
111 | pgParameters.setUser("postgres");
|
||
112 | pgParameters.setPassword("postgres");
|
||
113 | pgParameters.setDBName("gis");
|
||
114 | pgParameters.setTable("muni10000_peq");
|
||
115 | |||
116 | return pgParameters;
|
||
117 | } |
||
118 | |||
119 | public boolean hasExplorer() { |
||
120 | 27906 | jmvivo | return true; |
121 | 27525 | jmvivo | } |
122 | |||
123 | 27986 | jmvivo | public void testLoadMetadata() throws Exception { |
124 | DataStoreParameters params = this.getDefaultDataStoreParameters();
|
||
125 | 27672 | jmvivo | |
126 | 27986 | jmvivo | FeatureStore store = null;
|
127 | store = (FeatureStore) dataManager.createStore(params); |
||
128 | FeatureType fType = store.getDefaultFeatureType(); |
||
129 | FeatureAttributeDescriptor geomAttr; |
||
130 | |||
131 | |||
132 | |||
133 | if (fType.getDefaultGeometryAttributeIndex() >= 0) { |
||
134 | assertNotNull(store.getEnvelope()); |
||
135 | geomAttr = fType.getAttributeDescriptor(fType |
||
136 | .getDefaultGeometryAttributeIndex()); |
||
137 | assertTrue(geomAttr.getGeometryType() == Geometry.TYPES.MULTISURFACE); |
||
138 | assertTrue(geomAttr.getGeometrySubType() == Geometry.SUBTYPES.GEOM2D); |
||
139 | assertNotNull(store.getDynValue("DefaultSRS"));
|
||
140 | |||
141 | } |
||
142 | |||
143 | } |
||
144 | |||
145 | 27753 | jmvivo | public void testCloserConnection() throws Exception { |
146 | 27672 | jmvivo | |
147 | 27753 | jmvivo | DataStoreParameters params = this.getDefaultDataStoreParameters();
|
148 | 27672 | jmvivo | |
149 | 27753 | jmvivo | FeatureStore store = null;
|
150 | 27986 | jmvivo | store = (FeatureStore) dataManager.createStore(params); |
151 | 27672 | jmvivo | |
152 | 27753 | jmvivo | FeatureQuery query = store.createFeatureQuery(); |
153 | 27672 | jmvivo | |
154 | 27753 | jmvivo | query.getOrder().add("gid", true); |
155 | 27672 | jmvivo | |
156 | 27753 | jmvivo | query.setFilter(new Evaluator() {
|
157 | 27672 | jmvivo | |
158 | 27753 | jmvivo | public Object evaluate(EvaluatorData data) |
159 | throws EvaluatorException {
|
||
160 | // TODO Auto-generated method stub
|
||
161 | return Boolean.TRUE; |
||
162 | } |
||
163 | 27672 | jmvivo | |
164 | 27753 | jmvivo | public String getCQL() { |
165 | return "true = true"; |
||
166 | } |
||
167 | 27672 | jmvivo | |
168 | 27753 | jmvivo | public String getDescription() { |
169 | // TODO Auto-generated method stub
|
||
170 | return null; |
||
171 | } |
||
172 | 27672 | jmvivo | |
173 | 27753 | jmvivo | public String getName() { |
174 | return "AlwaysTrue"; |
||
175 | } |
||
176 | 27672 | jmvivo | |
177 | 27753 | jmvivo | public EvaluatorFieldsInfo getFieldsInfo() {
|
178 | // TODO Auto-generated method stub
|
||
179 | return null; |
||
180 | } |
||
181 | 27672 | jmvivo | |
182 | 27753 | jmvivo | }); |
183 | 27672 | jmvivo | |
184 | 27753 | jmvivo | FeatureStoreTransform transform = new StringsToLowerTransform();
|
185 | transform.setFeatureStore(store); |
||
186 | 27672 | jmvivo | |
187 | 27753 | jmvivo | store.getTransforms().add(transform); |
188 | 27672 | jmvivo | |
189 | 27753 | jmvivo | transform = new StringsToLowerTransform();
|
190 | transform.setFeatureStore(store); |
||
191 | 27672 | jmvivo | |
192 | 27753 | jmvivo | store.getTransforms().add(transform); |
193 | 27672 | jmvivo | |
194 | 27753 | jmvivo | transform = new StringsToLowerTransform();
|
195 | transform.setFeatureStore(store); |
||
196 | 27672 | jmvivo | |
197 | 27753 | jmvivo | store.getTransforms().add(transform); |
198 | 27672 | jmvivo | |
199 | 27753 | jmvivo | for (int i = 0; i < 30; i++) { |
200 | // this.fullStoreIteratorTest(store);
|
||
201 | 27672 | jmvivo | |
202 | 27753 | jmvivo | this.testIterationFastAndStandart(store, query);
|
203 | } |
||
204 | 27672 | jmvivo | |
205 | |||
206 | 27753 | jmvivo | store.dispose(); |
207 | 27672 | jmvivo | |
208 | } |
||
209 | 28017 | jmvivo | |
210 | public boolean usesResources() { |
||
211 | return true; |
||
212 | } |
||
213 | 28191 | jmvivo | |
214 | public NewFeatureStoreParameters getDefaultNewDataStoreParameters()
|
||
215 | throws Exception { |
||
216 | // TODO Auto-generated method stub
|
||
217 | return null; |
||
218 | } |
||
219 | 27525 | jmvivo | } |