svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.geocoding / src-test / org / gvsig / geocoding / update / TestUpdateFeature.java @ 32479
History | View | Annotate | Download (3.32 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 Prodevelop S.L main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.geocoding.update; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.IOException; |
32 |
import java.util.Iterator; |
33 |
|
34 |
import org.gvsig.LayerServer; |
35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.DataManager; |
37 |
import org.gvsig.fmap.dal.exception.DataException; |
38 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
39 |
import org.gvsig.fmap.dal.feature.Feature; |
40 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
42 |
import org.gvsig.fmap.dal.store.shp.SHPStoreParameters; |
43 |
import org.gvsig.fmap.dal.store.shp.SHPStoreProvider; |
44 |
import org.gvsig.tools.persistence.PersistenceException; |
45 |
import org.slf4j.Logger; |
46 |
import org.slf4j.LoggerFactory; |
47 |
|
48 |
/**
|
49 |
* Test
|
50 |
*
|
51 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
52 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicent Sanjaime Calvet</a>
|
53 |
*/
|
54 |
|
55 |
public class TestUpdateFeature extends |
56 |
org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase { |
57 |
|
58 |
private static final Logger log = LoggerFactory |
59 |
.getLogger(TestUpdateFeature.class); |
60 |
|
61 |
/**
|
62 |
* tearDown
|
63 |
*/
|
64 |
public void tearDown() { |
65 |
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* geocoding Massive
|
70 |
*
|
71 |
* @throws IOException
|
72 |
* @throws PersistenceException
|
73 |
* @throws DataException
|
74 |
*
|
75 |
* @throws DataException
|
76 |
*/
|
77 |
public void testUpdateFeature() throws Exception { |
78 |
|
79 |
FeatureStore streetsStore = LayerServer.getSHPStore(LayerServer.getStreetsFile()); |
80 |
streetsStore.edit(FeatureStore.MODE_FULLEDIT); |
81 |
|
82 |
FeatureSet selfeats = (FeatureSet) streetsStore.getDataSet(); |
83 |
int size = (int) selfeats.getSize(); |
84 |
if (size > 0) { |
85 |
Iterator<Feature> it = selfeats.iterator(0); |
86 |
EditableFeature shpfeat = (EditableFeature) it.next().getEditable(); |
87 |
shpfeat.set("MUNI", "yyy"); |
88 |
shpfeat.set("PROV", "yyy"); |
89 |
shpfeat.set("PAIS", "yyy"); |
90 |
selfeats.update(shpfeat); |
91 |
selfeats.dispose(); |
92 |
} |
93 |
streetsStore.finishEditing(); |
94 |
|
95 |
FeatureSet set = (FeatureSet) streetsStore.getDataSet(); |
96 |
Iterator<Feature> it2 = set.iterator(0); |
97 |
Feature feat = it2.next(); |
98 |
String muni = (String) feat.get("MUNI"); |
99 |
String prov = (String) feat.get("PROV"); |
100 |
String pais = (String) feat.get("PAIS"); |
101 |
|
102 |
assertEquals("yyy", muni);
|
103 |
assertEquals("yyy", prov);
|
104 |
assertEquals("yyy", pais);
|
105 |
} |
106 |
|
107 |
@Override
|
108 |
protected void doSetUp() throws Exception { |
109 |
|
110 |
|
111 |
} |
112 |
|
113 |
} |