Statistics
| Revision:

root / org.gvsig.xmlschema / library / trunk / org.gvsig.xmlschema / org.gvsig.xmlschema.prov / org.gvsig.xmlschema.prov.dom / src / test / java / org / gvsig / xmlschema / prov / som / writer / WriterBaseTest.java @ 250

History | View | Annotate | Download (4 KB)

1
package org.gvsig.xmlschema.prov.som.writer;
2

    
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileOutputStream;
6
import java.io.IOException;
7

    
8
import javax.xml.parsers.ParserConfigurationException;
9

    
10
import org.xml.sax.SAXException;
11

    
12
import org.gvsig.xmlschema.lib.api.exceptions.SchemaCreationException;
13
import org.gvsig.xmlschema.lib.api.exceptions.SchemaWrittingException;
14
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
15
import org.gvsig.xmlschema.lib.spi.XMLSchemaBaseTest;
16
import org.gvsig.xmlschema.prov.som.utils.DOMObjectsFactory;
17
import org.gvsig.xmlschema.prov.som.utils.SchemaDocumentBuilder;
18

    
19
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
20
 *
21
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
22
 *
23
 * This program is free software; you can redistribute it and/or
24
 * modify it under the terms of the GNU General Public License
25
 * as published by the Free Software Foundation; either version 2
26
 * of the License, or (at your option) any later version.
27
 *
28
 * This program is distributed in the hope that it will be useful,
29
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
 * GNU General Public License for more details.
32
 *
33
 * You should have received a copy of the GNU General Public License
34
 * along with this program; if not, write to the Free Software
35
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
36
 *
37
 * For more information, contact:
38
 *
39
 *  Generalitat Valenciana
40
 *   Conselleria d'Infraestructures i Transport
41
 *   Av. Blasco Ib??ez, 50
42
 *   46010 VALENCIA
43
 *   SPAIN
44
 *
45
 *      +34 963862235
46
 *   gvsig@gva.es
47
 *      www.gvsig.gva.es
48
 *
49
 *    or
50
 *
51
 *   IVER T.I. S.A
52
 *   Salamanca 50
53
 *   46005 Valencia
54
 *   Spain
55
 *
56
 *   +34 963163400
57
 *   dac@iver.es
58
 */
59
/* CVS MESSAGES:
60
 *
61
 * $Id: WriterBaseTest.java 164 2007-07-02 10:00:46Z jorpiell $
62
 * $Log$
63
 * Revision 1.3  2007/07/02 09:59:03  jorpiell
64
 * The generated xsd schemas have to be valid
65
 *
66
 * Revision 1.2  2007/06/22 12:21:18  jorpiell
67
 * The typeNotFoundException has been deleted. It never was thrown
68
 *
69
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
70
 * builds to create the jars generated and add the schema code to the libGPEProject
71
 *
72
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
73
 * The schema jar name has been changed
74
 *
75
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
76
 * Add the schema support
77
 *
78
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
79
 * Add the element collection
80
 *
81
 *
82
 */
83
/**
84
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
85
 */
86
public abstract class WriterBaseTest extends XMLSchemaBaseTest {
87
        private IXSSchema schema = null;
88
        private String fileName = "FILETEMP.xsd";
89
        private SchemaDocumentBuilder documentBuilder = null;
90
        private DOMObjectsFactory elementsFactory = null;
91

    
92
        /**
93
         * @return the documentBuilder
94
         */
95
        public SchemaDocumentBuilder getDocumentBuilder() {
96
                return documentBuilder;
97
        }
98

    
99
        /**
100
         * @return the elementsFactory
101
         */
102
        public DOMObjectsFactory getElementsFactory() {
103
                return elementsFactory;
104
        }
105

    
106
        protected void doSetUp() throws Exception {
107
                super.doSetUp();
108
                documentBuilder = SchemaDocumentBuilder.getInstance();
109
                schema = documentBuilder.createXSSchema(getNamespaceURI(),getNamespacePrefix());        
110
                elementsFactory = DOMObjectsFactory.getInstance();
111
        }
112
        
113
        public void tearDown() throws Exception{
114
                new File(fileName).delete();
115
        }
116
        
117
        public void testCompare() throws SchemaWrittingException, ParserConfigurationException, SAXException, IOException, SchemaCreationException{
118
                writeSchema();
119
                schema.write(new FileOutputStream(fileName));
120
                schema = SchemaDocumentBuilder.getInstance().parse(new FileInputStream(fileName));
121
                readSchema();
122
        }        
123
        
124
        /**
125
         * @return the schema
126
         */
127
        public IXSSchema getSchema() {
128
                return schema;
129
        }
130
        
131
        public String getNamespaceURI(){
132
                return "http://www.gvsig.org/cit";
133
        }
134
        
135
        /**
136
         * Gets the namespace prefix
137
         * @return
138
         */
139
        public String getNamespacePrefix(){
140
                return "cit";
141
        }
142
        
143
        public abstract void writeSchema();
144
        
145
        public abstract void readSchema();
146

    
147

    
148
}