Statistics
| Revision:

root / trunk / libraries / libGPE / src-test / org / gvsig / xmlschema / writer / ChoiceWritingTest.java @ 12175

History | View | Annotate | Download (3.47 KB)

1
package org.gvsig.xmlschema.writer;
2

    
3
import java.util.Iterator;
4

    
5
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
6
import org.gvsig.xmlschema.som.IXSChoice;
7
import org.gvsig.xmlschema.som.IXSComplexTypeDefinition;
8
import org.gvsig.xmlschema.som.IXSContentType;
9
import org.gvsig.xmlschema.som.IXSTypeDefinition;
10

    
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: ChoiceWritingTest.java 12175 2007-06-14 16:15:05Z jorpiell $
54
 * $Log$
55
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
56
 * builds to create the jars generated and add the schema code to the libGPEProject
57
 *
58
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
59
 * The schema jar name has been changed
60
 *
61
 * Revision 1.3  2007/06/08 11:35:16  jorpiell
62
 * IXSSchema interface updated
63
 *
64
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
65
 * Add the schema support
66
 *
67
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
68
 * Add the element collection
69
 *
70
 *
71
 */
72
/**
73
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
74
 */
75
public class ChoiceWritingTest extends WriterBaseTest {
76
        private String typeName1 = "river_type";
77
        private String typeType1 = IXSComplexTypeDefinition.CHOICE;
78
        private String contentType1 = IXSContentType.WITOUT_CONTENT;
79
        private String contentRestriction1 = IXSContentType.WITOUT_RESTRICTION;
80
        private String type1ElementName1 = "length";
81
        private String type1ElementType1 = "xs:double";        
82
        private String type1ElementName2 = "name";
83
        private String type1ElementType2 = "xs:string";
84
        
85
        /*
86
         * (non-Javadoc)
87
         * @see org.gvsig.gpe.schema.writer.WriterBaseTest#readSchema()
88
         */
89
        public void readSchema() throws TypeNotFoundException {
90
                IXSTypeDefinition type = getSchema().getTypeByName(getNamespaceURI(), typeName1);
91
                assertNotNull(type);
92
                assertEquals(type.getQName().getLocalName(), typeName1);
93
                IXSComplexTypeDefinition cType = (IXSComplexTypeDefinition)type;
94
                Iterator it = cType.getItems().iterator();
95
                IXSChoice choice = null;
96
                while (it.hasNext()){
97
                        choice = (IXSChoice) it.next();
98
                }
99
                assertNotNull(choice);                                
100
        }
101

    
102
        /*
103
         * (non-Javadoc)
104
         * @see org.gvsig.gpe.schema.writer.WriterBaseTest#writeSchema()
105
         */
106
        public void writeSchema() {
107
                IXSComplexTypeDefinition complexType = getSchema().addComplexType(
108
                                typeName1, typeType1, contentType1, contentRestriction1);
109
                complexType.addElement(
110
                                type1ElementName1,
111
                                type1ElementType1);                
112
                complexType.addElement(
113
                                type1ElementName2,
114
                                type1ElementType2);                        
115
        }
116
}