root / branches / v2_0_0_prep / libraries / libGPE / src-test / org / gvsig / xmlschema / writer / WriterBaseTest.java @ 30754
History | View | Annotate | Download (3.98 KB)
1 |
package org.gvsig.xmlschema.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 junit.framework.TestCase; |
11 |
|
12 |
import org.gvsig.xmlschema.XMLSchemaBaseTest; |
13 |
import org.gvsig.xmlschema.exceptions.SchemaCreationException; |
14 |
import org.gvsig.xmlschema.exceptions.SchemaWrittingException; |
15 |
import org.gvsig.xmlschema.som.IXSSchema; |
16 |
import org.gvsig.xmlschema.utils.DOMObjectsFactory; |
17 |
import org.gvsig.xmlschema.utils.SchemaDocumentBuilder; |
18 |
import org.xml.sax.SAXException; |
19 |
|
20 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
21 |
*
|
22 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* as published by the Free Software Foundation; either version 2
|
27 |
* of the License, or (at your option) any later version.
|
28 |
*
|
29 |
* This program is distributed in the hope that it will be useful,
|
30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
* GNU General Public License for more details.
|
33 |
*
|
34 |
* You should have received a copy of the GNU General Public License
|
35 |
* along with this program; if not, write to the Free Software
|
36 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
37 |
*
|
38 |
* For more information, contact:
|
39 |
*
|
40 |
* Generalitat Valenciana
|
41 |
* Conselleria d'Infraestructures i Transport
|
42 |
* Av. Blasco Ib??ez, 50
|
43 |
* 46010 VALENCIA
|
44 |
* SPAIN
|
45 |
*
|
46 |
* +34 963862235
|
47 |
* gvsig@gva.es
|
48 |
* www.gvsig.gva.es
|
49 |
*
|
50 |
* or
|
51 |
*
|
52 |
* IVER T.I. S.A
|
53 |
* Salamanca 50
|
54 |
* 46005 Valencia
|
55 |
* Spain
|
56 |
*
|
57 |
* +34 963163400
|
58 |
* dac@iver.es
|
59 |
*/
|
60 |
/* CVS MESSAGES:
|
61 |
*
|
62 |
* $Id: WriterBaseTest.java 164 2007-07-02 10:00:46Z jorpiell $
|
63 |
* $Log$
|
64 |
* Revision 1.3 2007/07/02 09:59:03 jorpiell
|
65 |
* The generated xsd schemas have to be valid
|
66 |
*
|
67 |
* Revision 1.2 2007/06/22 12:21:18 jorpiell
|
68 |
* The typeNotFoundException has been deleted. It never was thrown
|
69 |
*
|
70 |
* Revision 1.1 2007/06/14 16:15:03 jorpiell
|
71 |
* builds to create the jars generated and add the schema code to the libGPEProject
|
72 |
*
|
73 |
* Revision 1.1 2007/06/14 13:50:07 jorpiell
|
74 |
* The schema jar name has been changed
|
75 |
*
|
76 |
* Revision 1.2 2007/06/07 14:54:13 jorpiell
|
77 |
* Add the schema support
|
78 |
*
|
79 |
* Revision 1.1 2007/05/30 12:25:48 jorpiell
|
80 |
* Add the element collection
|
81 |
*
|
82 |
*
|
83 |
*/
|
84 |
/**
|
85 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
86 |
*/
|
87 |
public abstract class WriterBaseTest extends XMLSchemaBaseTest { |
88 |
private IXSSchema schema = null; |
89 |
private String fileName = "FILETEMP.xsd"; |
90 |
private SchemaDocumentBuilder documentBuilder = null; |
91 |
private DOMObjectsFactory elementsFactory = null; |
92 |
|
93 |
/**
|
94 |
* @return the documentBuilder
|
95 |
*/
|
96 |
public SchemaDocumentBuilder getDocumentBuilder() {
|
97 |
return documentBuilder;
|
98 |
} |
99 |
|
100 |
/**
|
101 |
* @return the elementsFactory
|
102 |
*/
|
103 |
public DOMObjectsFactory getElementsFactory() {
|
104 |
return elementsFactory;
|
105 |
} |
106 |
|
107 |
protected void doSetUp() throws Exception { |
108 |
super.doSetUp();
|
109 |
documentBuilder = SchemaDocumentBuilder.getInstance(); |
110 |
schema = documentBuilder.createXSSchema(getNamespaceURI(),getNamespacePrefix()); |
111 |
elementsFactory = DOMObjectsFactory.getInstance(); |
112 |
} |
113 |
|
114 |
public void tearDown() throws Exception{ |
115 |
new File(fileName).delete(); |
116 |
} |
117 |
|
118 |
public void testCompare() throws SchemaWrittingException, ParserConfigurationException, SAXException, IOException, SchemaCreationException{ |
119 |
writeSchema(); |
120 |
schema.write(new FileOutputStream(fileName)); |
121 |
schema = SchemaDocumentBuilder.getInstance().parse(new FileInputStream(fileName)); |
122 |
readSchema(); |
123 |
} |
124 |
|
125 |
/**
|
126 |
* @return the schema
|
127 |
*/
|
128 |
public IXSSchema getSchema() {
|
129 |
return schema;
|
130 |
} |
131 |
|
132 |
public String getNamespaceURI(){ |
133 |
return "http://www.gvsig.org/cit"; |
134 |
} |
135 |
|
136 |
/**
|
137 |
* Gets the namespace prefix
|
138 |
* @return
|
139 |
*/
|
140 |
public String getNamespacePrefix(){ |
141 |
return "cit"; |
142 |
} |
143 |
|
144 |
public abstract void writeSchema(); |
145 |
|
146 |
public abstract void readSchema(); |
147 |
|
148 |
|
149 |
} |