root / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / schemas / GPENotSupportedFeatureTest.java @ 12418
History | View | Annotate | Download (3.6 KB)
1 |
package org.gvsig.gpe.writers.schemas; |
---|---|
2 |
|
3 |
import org.gvsig.gpe.containers.Layer; |
4 |
import org.gvsig.gpe.warnings.NotSupportedElementWarning; |
5 |
import org.gvsig.gpe.warnings.NotSupportedFeatureWarning; |
6 |
import org.gvsig.xmlschema.utils.TypeUtils; |
7 |
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
9 |
*
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
11 |
*
|
12 |
* This program is free software; you can redistribute it and/or
|
13 |
* modify it under the terms of the GNU General Public License
|
14 |
* as published by the Free Software Foundation; either version 2
|
15 |
* of the License, or (at your option) any later version.
|
16 |
*
|
17 |
* This program is distributed in the hope that it will be useful,
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
* GNU General Public License for more details.
|
21 |
*
|
22 |
* You should have received a copy of the GNU General Public License
|
23 |
* along with this program; if not, write to the Free Software
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
25 |
*
|
26 |
* For more information, contact:
|
27 |
*
|
28 |
* Generalitat Valenciana
|
29 |
* Conselleria d'Infraestructures i Transport
|
30 |
* Av. Blasco Ib??ez, 50
|
31 |
* 46010 VALENCIA
|
32 |
* SPAIN
|
33 |
*
|
34 |
* +34 963862235
|
35 |
* gvsig@gva.es
|
36 |
* www.gvsig.gva.es
|
37 |
*
|
38 |
* or
|
39 |
*
|
40 |
* IVER T.I. S.A
|
41 |
* Salamanca 50
|
42 |
* 46005 Valencia
|
43 |
* Spain
|
44 |
*
|
45 |
* +34 963163400
|
46 |
* dac@iver.es
|
47 |
*/
|
48 |
/* CVS MESSAGES:
|
49 |
*
|
50 |
* $Id: GPENotSupportedFeatureTest.java 12418 2007-06-29 12:19:48Z jorpiell $
|
51 |
* $Log$
|
52 |
* Revision 1.1 2007-06-29 12:19:14 jorpiell
|
53 |
* The schema validation is made independently of the concrete writer
|
54 |
*
|
55 |
* Revision 1.1 2007/06/28 13:04:33 jorpiell
|
56 |
* The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
|
57 |
*
|
58 |
*
|
59 |
*/
|
60 |
/**
|
61 |
* This test try to add a Feature with a type that doesn't exist
|
62 |
* in its layer schema
|
63 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
64 |
*/
|
65 |
public abstract class GPENotSupportedFeatureTest extends GPENotSupportedSchema { |
66 |
private String layerId = "l1"; |
67 |
private String layerName = "Parent layer"; |
68 |
private String layerDescription = "This is a test of a wrong layer feature"; |
69 |
private String layerSrs = "EPSG:23030"; |
70 |
private String layerXsElementName = "cities"; |
71 |
private String feature1Name = "city"; |
72 |
private String feature1Id = "f1"; |
73 |
private String element1Name = "Population"; |
74 |
private Integer element1Value = new Integer(30000); |
75 |
private String element1Type = TypeUtils.getXSType(element1Value.getClass()); |
76 |
//Schema
|
77 |
private String xsFeature1Name = "river"; |
78 |
|
79 |
/*
|
80 |
* (non-Javadoc)
|
81 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
|
82 |
*/
|
83 |
public void readObjects() { |
84 |
Layer[] layers = getLayers();
|
85 |
assertEquals(layers.length, 1);
|
86 |
Layer layer = layers[0];
|
87 |
|
88 |
assertEquals(layer.getFeatures().size(),0);
|
89 |
|
90 |
//Two warinings
|
91 |
assertEquals(getErrorHandler().getWarningsSize(),1);
|
92 |
for (int i=0 ; i<getErrorHandler().getWarningsSize() ; i++){ |
93 |
assertTrue(getErrorHandler().getWarningAt(i) instanceof NotSupportedFeatureWarning);
|
94 |
System.out.println(getErrorHandler().getWarningAt(i));
|
95 |
} |
96 |
} |
97 |
|
98 |
/*
|
99 |
* (non-Javadoc)
|
100 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
|
101 |
*/
|
102 |
public void writeObjects() { |
103 |
getWriterHandler().initialize(); |
104 |
getWriterHandler().startLayer(layerId, layerName, layerDescription, layerSrs, layerXsElementName); |
105 |
getWriterHandler().startFeature(feature1Id,feature1Name, xsFeature1Name); |
106 |
getWriterHandler().startElement(element1Name, |
107 |
element1Value, |
108 |
element1Type); |
109 |
getWriterHandler().endElement(); |
110 |
getWriterHandler().endFeature(); |
111 |
getWriterHandler().endLayer(); |
112 |
getWriterHandler().close(); |
113 |
} |
114 |
|
115 |
} |