svn-gvsig-desktop / trunk / libraries / libDataSourceDBBaseDrivers / src-test / org / gvsig / data / datastores / vectorial / db / jdbc / postgresql / postgresqlTest.java @ 19965
History | View | Annotate | Download (2.58 KB)
1 |
package org.gvsig.data.datastores.vectorial.db.jdbc.postgresql; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
import java.util.NoSuchElementException; |
5 |
|
6 |
import org.gvsig.data.DataManager; |
7 |
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCTest; |
8 |
import org.gvsig.data.exception.InitializeException; |
9 |
import org.gvsig.data.exception.ReadException; |
10 |
import org.gvsig.data.vectorial.IFeatureCollection; |
11 |
import org.gvsig.data.vectorial.IFeatureStore; |
12 |
|
13 |
public class postgresqlTest extends JDBCTest { |
14 |
|
15 |
private static String SERVER_IP="192.168.0.66"; |
16 |
private static String SERVER_PORT="5432"; |
17 |
private static String SERVER_DBNAME="gis"; |
18 |
private static String SERVER_SCHEMA="ds_test"; |
19 |
private static String SERVER_USER="testCase"; |
20 |
private static String SERVER_PASWD="testCase"; |
21 |
|
22 |
|
23 |
private static String DS_NAME = PostgresqlStore.DATASTORE_NAME; |
24 |
|
25 |
|
26 |
public void testSimpleIteration(){ |
27 |
Register.selfRegister(); |
28 |
DataManager manager = DataManager.getManager(); |
29 |
|
30 |
|
31 |
PostgresqlStoreParameters dparam = |
32 |
(PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME); |
33 |
|
34 |
dparam.setHost(SERVER_IP); |
35 |
dparam.setPort(SERVER_PORT); |
36 |
dparam.setUser(SERVER_USER); |
37 |
dparam.setPassw(SERVER_PASWD); |
38 |
dparam.setSchema(SERVER_SCHEMA); |
39 |
dparam.setDb(SERVER_DBNAME); |
40 |
dparam.setTableName("prueba");
|
41 |
dparam.setFieldId(new String[] {"gid"}); |
42 |
dparam.setFields(new String[] {"*"}); |
43 |
dparam.setDefaultGeometryField("the_geom");
|
44 |
|
45 |
storeTest(dparam, null, null, false); |
46 |
|
47 |
} |
48 |
|
49 |
public void testSimpleIteration38K_regs(){ |
50 |
Register.selfRegister(); |
51 |
DataManager manager = DataManager.getManager(); |
52 |
|
53 |
|
54 |
PostgresqlStoreParameters dparam = |
55 |
(PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME); |
56 |
|
57 |
dparam.setHost(SERVER_IP); |
58 |
dparam.setPort(SERVER_PORT); |
59 |
dparam.setUser(SERVER_USER); |
60 |
dparam.setPassw(SERVER_PASWD); |
61 |
dparam.setSchema(null);
|
62 |
dparam.setDb(SERVER_DBNAME); |
63 |
dparam.setTableName("hidropol");
|
64 |
// dparam.setTableName("ejes");
|
65 |
dparam.setFieldId(new String[] {"gid"}); |
66 |
dparam.setFields(new String[] {"*"}); |
67 |
dparam.setDefaultGeometryField("the_geom");
|
68 |
|
69 |
// storeTest(dparam, null, null, false);
|
70 |
|
71 |
IFeatureStore fs=null;
|
72 |
try {
|
73 |
fs = (IFeatureStore) manager.createDataStore(dparam); |
74 |
} catch (InitializeException e) {
|
75 |
e.printStackTrace(); |
76 |
fail(); |
77 |
} |
78 |
IFeatureCollection fc=null;
|
79 |
try {
|
80 |
fc = (IFeatureCollection) fs.getDataCollection(); |
81 |
} catch (ReadException e) {
|
82 |
e.printStackTrace(); |
83 |
fail(); |
84 |
} |
85 |
|
86 |
int i=0; |
87 |
int count = fc.size();
|
88 |
Iterator iter = fc.iterator();
|
89 |
while (true){ |
90 |
try{
|
91 |
iter.next(); |
92 |
i++; |
93 |
} catch (NoSuchElementException e) { |
94 |
break;
|
95 |
} |
96 |
} |
97 |
assertEquals(count, i); |
98 |
|
99 |
|
100 |
} |
101 |
|
102 |
} |