Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writer / schemas / GPENotSupportedElementTest.java @ 21944

History | View | Annotate | Download (4.77 KB)

1
package org.gvsig.gpe.writer.schemas;
2

    
3
import org.gvsig.gpe.containers.CoordinatesSequence;
4
import org.gvsig.gpe.containers.Feature;
5
import org.gvsig.gpe.containers.Layer;
6
import org.gvsig.gpe.warnings.NotSupportedElementWarning;
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: GPENotSupportedElementTest.java 162 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
 * Revision 1.1  2007/06/22 12:21:18  jorpiell
59
 * The typeNotFoundException has been deleted. It never was thrown
60
 *
61
 *
62
 */
63
/**
64
 * This class is used to test the warning that is
65
 * thrown when the consumer application tries to write
66
 * an element that is not in the XML schema 
67
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
68
 */
69
public abstract class GPENotSupportedElementTest extends GPENotSupportedSchema {
70
        private String namespace = "http://www,gvsig.org/cit";
71
        private String layer1Id = "l1";
72
        private String layer1Name = "Parent layer";
73
        private String layer1Description = "This is a test of a wrong eleemnt";
74
        private String layer1Srs = "EPSG:23030";
75
        private String layer1XsElementName = "cities";
76
        private String feature1Name = "city";
77
        private String feature1Id = "f1";
78
        private String point1Id = "p1";
79
        private double point1X = generateRandomPoint();
80
        private double point1Y = generateRandomPoint();
81
        private double point1Z = generateRandomPoint();
82
        private String element1Name = "Population";
83
        private Integer element1Value = new Integer(30000);
84
        private String element2Name = "Country";
85
        private String element2Value = "USA";
86
        private String element3Name = "Capital";
87
        private Boolean element3Value = new Boolean(false);
88
        private String element4Name = "Size";
89
        private Integer element4Value = new Integer(100000);
90
        //Schema 
91
        private String xsFeature1Name = "city";
92
        
93
        /*
94
         * (non-Javadoc)
95
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
96
         */
97
        public void readObjects() {
98
                Layer[] layers = getLayers();
99
                assertEquals(layers.length, 1);                
100
                Layer layer = layers[0];
101
        
102
                assertEquals(layer.getFeatures().size(), 1);
103
                //FEATURE 1
104
                Feature feature1 = (Feature)layer.getFeatures().get(0);
105
                
106
                boolean elementNotSupported = false;
107
                for (int i=0 ; i<getErrorHandler().getWarningsSize() ; i++){
108
                        if (getErrorHandler().getWarningAt(i) instanceof NotSupportedElementWarning){
109
                                elementNotSupported = true;
110
                        }                        
111
                }
112
                assertTrue(elementNotSupported);
113
        }
114

    
115
        /*
116
         * (non-Javadoc)
117
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
118
         */
119
        public void writeObjects() {
120
                getWriterHandler().initialize();
121
                getWriterHandler().startLayer(layer1Id, null, layer1Name, layer1Description, layer1Srs);
122
                getWriterHandler().startFeature(feature1Id,feature1Name, xsFeature1Name);
123
                getWriterHandler().startPoint(point1Id, new CoordinatesSequence(point1X, point1Y, point1Z), layer1Srs);
124
                getWriterHandler().endPoint();        
125
                getWriterHandler().startElement(namespace,
126
                                element1Name,
127
                                element1Value);
128
                getWriterHandler().endElement();
129
                getWriterHandler().startElement(namespace,
130
                                element2Name,
131
                                element2Value);
132
                getWriterHandler().endElement();
133
                getWriterHandler().startElement(namespace,
134
                                element3Name,
135
                                element3Value);
136
                getWriterHandler().endElement();
137
                getWriterHandler().startElement(namespace,
138
                                element4Name,
139
                                element4Value);
140
                getWriterHandler().endElement();
141
                getWriterHandler().endFeature();                
142
                getWriterHandler().endLayer();
143
                getWriterHandler().close();                
144
        }
145
}