svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src-test / org / gvsig / fmap / data / store / dbf / TestDBF.java @ 24452
History | View | Annotate | Download (3.08 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 |
* 2008 IVER T.I. S.A. {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.data.store.dbf; |
29 |
|
30 |
import java.io.File; |
31 |
import java.util.Iterator; |
32 |
|
33 |
import junit.framework.TestCase; |
34 |
|
35 |
import org.gvsig.fmap.data.DALFileLibrary; |
36 |
import org.gvsig.fmap.data.DALLibrary; |
37 |
import org.gvsig.fmap.data.DALLocator; |
38 |
import org.gvsig.fmap.data.DataManager; |
39 |
import org.gvsig.fmap.data.exceptions.DataException; |
40 |
import org.gvsig.fmap.data.feature.Feature; |
41 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
42 |
import org.gvsig.fmap.data.feature.FeatureSet; |
43 |
import org.gvsig.fmap.data.feature.FeatureStore; |
44 |
import org.gvsig.fmap.data.feature.FeatureType; |
45 |
|
46 |
public class TestDBF extends TestCase { |
47 |
|
48 |
public static final File file = new File(TestDBF.class.getResource( |
49 |
"data/prueba.dbf").getFile());
|
50 |
|
51 |
private static DataManager dataManager = null; |
52 |
|
53 |
|
54 |
protected void setUp() throws Exception { |
55 |
super.setUp();
|
56 |
DALLibrary lib = new DALLibrary();
|
57 |
lib.initialize(); |
58 |
lib.postInitialize(); |
59 |
|
60 |
DALFileLibrary libFile = new DALFileLibrary();
|
61 |
libFile.initialize(); |
62 |
libFile.postInitialize(); |
63 |
|
64 |
DBFLibrary dbfLib = new DBFLibrary();
|
65 |
dbfLib.initialize(); |
66 |
dbfLib.postInitialize(); |
67 |
|
68 |
dataManager = DALLocator.getDataManager(); |
69 |
} |
70 |
|
71 |
public void testSimpleIteration() { |
72 |
FeatureStore store = null;
|
73 |
DBFStoreParameters dbfParameters = null;
|
74 |
|
75 |
try {
|
76 |
dbfParameters = (DBFStoreParameters) dataManager |
77 |
.createStoreParameters(DBFStoreProvider.NAME); |
78 |
|
79 |
dbfParameters.setFile(file); |
80 |
|
81 |
store = (FeatureStore) dataManager.createStore(dbfParameters); |
82 |
FeatureSet set; |
83 |
FeatureType type = store.getDefaultFeatureType(); |
84 |
set = store.getFeatureSet(); |
85 |
|
86 |
Iterator it = set.iterator();
|
87 |
Iterator ftIt;
|
88 |
FeatureAttributeDescriptor desc; |
89 |
|
90 |
Feature feature; |
91 |
while (it.hasNext()) {
|
92 |
ftIt = type.iterator(); |
93 |
|
94 |
feature = (Feature) it.next(); |
95 |
// while (ftIt.hasNext()) {
|
96 |
// desc = (FeatureAttributeDescriptor) ftIt.next();
|
97 |
// System.out.println(desc.getName() + ":"
|
98 |
// + feature.get(desc.getIndex()));
|
99 |
//
|
100 |
// }
|
101 |
System.out.println(feature.get("NOMBRE")); |
102 |
|
103 |
|
104 |
} |
105 |
|
106 |
set.dispose(); |
107 |
|
108 |
|
109 |
} catch (DataException e3) {
|
110 |
e3.printStackTrace(); |
111 |
fail(); |
112 |
return;
|
113 |
} |
114 |
|
115 |
|
116 |
} |
117 |
|
118 |
} |