root / branches / v2_0_0_prep / libraries / libGPE / src-test / org / gvsig / gpe / writer / schemas / GPEWriterWithSchemaBaseTest.java @ 28113
History | View | Annotate | Download (4.4 KB)
1 |
package org.gvsig.gpe.writer.schemas; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.FileOutputStream; |
5 |
import java.io.IOException; |
6 |
|
7 |
import org.gvsig.gpe.writer.GPEWriterBaseTest; |
8 |
import org.gvsig.xmlschema.som.IXSSchema; |
9 |
import org.gvsig.xmlschema.utils.DOMObjectsFactory; |
10 |
import org.gvsig.xmlschema.utils.SchemaDocumentBuilder; |
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id: GPEWriterWithSchemaBaseTest.java 173 2007-11-06 12:10:57Z jpiera $
|
55 |
* $Log$
|
56 |
* Revision 1.8 2007/07/02 10:00:46 jorpiell
|
57 |
* The generated xsd schemas have to be valid
|
58 |
*
|
59 |
* Revision 1.7 2007/06/29 12:20:41 jorpiell
|
60 |
* The schema validation is made independently of the concrete writer
|
61 |
*
|
62 |
* Revision 1.6 2007/06/29 12:19:14 jorpiell
|
63 |
* The schema validation is made independently of the concrete writer
|
64 |
*
|
65 |
* Revision 1.5 2007/06/22 12:38:59 jorpiell
|
66 |
* The typeNotFoundException has been deleted. It never was thrown
|
67 |
*
|
68 |
* Revision 1.4 2007/06/22 12:21:18 jorpiell
|
69 |
* The typeNotFoundException has been deleted. It never was thrown
|
70 |
*
|
71 |
* Revision 1.3 2007/06/14 13:50:06 jorpiell
|
72 |
* The schema jar name has been changed
|
73 |
*
|
74 |
* Revision 1.2 2007/06/07 14:55:21 jorpiell
|
75 |
* Add the schema support
|
76 |
*
|
77 |
* Revision 1.1 2007/06/07 14:52:28 jorpiell
|
78 |
* Add the schema support
|
79 |
*
|
80 |
*
|
81 |
*/
|
82 |
/**
|
83 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
84 |
*/
|
85 |
public abstract class GPEWriterWithSchemaBaseTest extends GPEWriterBaseTest{ |
86 |
private IXSSchema schema = null; |
87 |
private String schemafileName = "SCHEMAFILETEMP"; |
88 |
private SchemaDocumentBuilder documentBuilder = null; |
89 |
private DOMObjectsFactory elementsFactory = null; |
90 |
private File schemaFile = null; |
91 |
|
92 |
/**
|
93 |
* Initialize the schemas factory
|
94 |
*/
|
95 |
public void setUp() throws Exception{ |
96 |
documentBuilder = SchemaDocumentBuilder.getInstance(); |
97 |
schema = documentBuilder.createXSSchema(getNamespaceURI(),getNamespacePrefix()); |
98 |
elementsFactory = DOMObjectsFactory.getInstance(); |
99 |
super.setUp();
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* Delete the schema file
|
104 |
*/
|
105 |
public void tearDown() throws Exception{ |
106 |
getSchemaFile().delete(); |
107 |
super.tearDown();
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* Writes the schema a parses the file
|
112 |
*/
|
113 |
public void testWriter() throws Exception{ |
114 |
writeSchema(); |
115 |
getSchema().write(new FileOutputStream(getSchemaFile())); |
116 |
getGpeManager().setProperty("schemaName", getSchemaFile().getAbsolutePath());
|
117 |
//getWriterHandler().getSchemaDocument().addSchema(
|
118 |
// new URI(getSchemaFile().getPath()),
|
119 |
// getSchema());
|
120 |
//getWriterHandler().getSchemaDocument().setTargetNamespace(getNamespaceURI());
|
121 |
super.testWriter();
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* Writes the schema
|
126 |
* @throws TypeNotFoundException
|
127 |
*/
|
128 |
public abstract void writeSchema(); |
129 |
|
130 |
/**
|
131 |
* Gets the namespace URI
|
132 |
* @return
|
133 |
*/
|
134 |
public String getNamespaceURI(){ |
135 |
return "http://www.gvsig.org/cit"; |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Gets the namespace prefix
|
140 |
* @return
|
141 |
*/
|
142 |
public String getNamespacePrefix(){ |
143 |
return "cit"; |
144 |
} |
145 |
|
146 |
/**
|
147 |
* @return the schemaFile
|
148 |
* @throws IOException
|
149 |
*/
|
150 |
public File getSchemaFile() throws IOException { |
151 |
if (schemaFile == null){ |
152 |
schemaFile = new File(schemafileName); |
153 |
} |
154 |
return schemaFile;
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* @return the elementsFactory
|
159 |
*/
|
160 |
public DOMObjectsFactory getElementsFactory() {
|
161 |
return elementsFactory;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* @return the schema
|
166 |
*/
|
167 |
public IXSSchema getSchema() {
|
168 |
return schema;
|
169 |
} |
170 |
|
171 |
|
172 |
} |