root / branches / v2_0_0_prep / libraries / libFMap_daldb / src-test / org / gvsig / fmap / dal / store / postgesql / TestPostgreSQL.java @ 27672
History | View | Annotate | Download (4.54 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.postgesql; |
32 |
|
33 |
import org.gvsig.fmap.dal.DALDbLibrary; |
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
35 |
import org.gvsig.fmap.dal.exception.DataException; |
36 |
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore; |
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.index.spatial.jts.JTSIndexLibrary; |
41 |
import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary; |
42 |
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary; |
43 |
import org.gvsig.tools.ToolsLocator; |
44 |
import org.gvsig.tools.evaluator.Evaluator; |
45 |
import org.gvsig.tools.evaluator.EvaluatorData; |
46 |
import org.gvsig.tools.evaluator.EvaluatorException; |
47 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
48 |
import org.gvsig.tools.persistence.xmlentity.XMLEntityManager; |
49 |
|
50 |
/**
|
51 |
* @author jmvivo
|
52 |
*
|
53 |
*/
|
54 |
public class TestPostgreSQL extends BaseTestFeatureStore { |
55 |
|
56 |
|
57 |
protected void setUp() throws Exception { |
58 |
super.setUp();
|
59 |
ToolsLocator.registerDefaultPersistenceManager(XMLEntityManager.class); |
60 |
|
61 |
DefaultGeometryLibrary defGeomLib = new DefaultGeometryLibrary();
|
62 |
defGeomLib.initialize(); |
63 |
|
64 |
DALDbLibrary libDb = new DALDbLibrary();
|
65 |
libDb.initialize(); |
66 |
|
67 |
JDBCLibrary libJDBC = new JDBCLibrary();
|
68 |
libJDBC.initialize(); |
69 |
|
70 |
PostgreSQLLibrary pgLib = new PostgreSQLLibrary();
|
71 |
pgLib.initialize(); |
72 |
|
73 |
JTSIndexLibrary jtsIndex = new JTSIndexLibrary();
|
74 |
jtsIndex.initialize(); |
75 |
|
76 |
defGeomLib.postInitialize(); |
77 |
libDb.postInitialize(); |
78 |
libJDBC.postInitialize(); |
79 |
pgLib.postInitialize(); |
80 |
jtsIndex.postInitialize(); |
81 |
} |
82 |
|
83 |
public DataStoreParameters getDefaultDataStoreParameters()
|
84 |
throws DataException {
|
85 |
PostgreSQLStoreParameters pgParameters = null;
|
86 |
pgParameters = (PostgreSQLStoreParameters) dataManager |
87 |
.createStoreParameters(PostgreSQLStoreProvider.NAME); |
88 |
|
89 |
pgParameters.setHost("localhost");
|
90 |
pgParameters.setUser("postgres");
|
91 |
pgParameters.setPassword("postgres");
|
92 |
pgParameters.setDBName("gis");
|
93 |
pgParameters.setTable("muni10000_peq");
|
94 |
pgParameters.setPkFields("gid");
|
95 |
|
96 |
return pgParameters;
|
97 |
} |
98 |
|
99 |
public boolean hasExplorer() { |
100 |
// TODO Auto-generated method stub
|
101 |
return false; |
102 |
} |
103 |
|
104 |
|
105 |
public void testCloserConnection() { |
106 |
try {
|
107 |
|
108 |
DataStoreParameters params = this.getDefaultDataStoreParameters();
|
109 |
|
110 |
FeatureStore store = null;
|
111 |
store = (FeatureStore) dataManager.createStore(params); |
112 |
|
113 |
FeatureQuery query = store.createFeatureQuery(); |
114 |
|
115 |
query.getOrder().add("gid", true); |
116 |
|
117 |
query.setFilter(new Evaluator() {
|
118 |
|
119 |
public Object evaluate(EvaluatorData data) |
120 |
throws EvaluatorException {
|
121 |
// TODO Auto-generated method stub
|
122 |
return Boolean.TRUE; |
123 |
} |
124 |
|
125 |
public String getCQL() { |
126 |
return "true = true"; |
127 |
} |
128 |
|
129 |
public String getDescription() { |
130 |
// TODO Auto-generated method stub
|
131 |
return null; |
132 |
} |
133 |
|
134 |
public String getName() { |
135 |
return "AlwaysTrue"; |
136 |
} |
137 |
|
138 |
public EvaluatorFieldsInfo getFieldsInfo() {
|
139 |
// TODO Auto-generated method stub
|
140 |
return null; |
141 |
} |
142 |
|
143 |
}); |
144 |
|
145 |
FeatureStoreTransform 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 |
transform = new StringsToLowerTransform();
|
156 |
transform.setFeatureStore(store); |
157 |
|
158 |
store.getTransforms().add(transform); |
159 |
|
160 |
for (int i = 0; i < 30; i++) { |
161 |
// this.fullStoreIteratorTest(store);
|
162 |
|
163 |
this.testIterationFastAndStandart(store, query);
|
164 |
} |
165 |
|
166 |
|
167 |
store.dispose(); |
168 |
|
169 |
|
170 |
|
171 |
} catch (DataException e) {
|
172 |
e.printStackTrace(); |
173 |
fail(); |
174 |
} |
175 |
|
176 |
} |
177 |
} |