Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java @ 103:4042844339ee
Testcases for VerticalProfile and VerticalProfile Instantaneouspoint added
gnv-artifacts/trunk@152 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 29 Sep 2009 12:01:41 +0000 |
parents | 994a39b084d6 |
children | 11b2d43da90d |
comparison
equal
deleted
inserted
replaced
102:994a39b084d6 | 103:4042844339ee |
---|---|
20 import org.w3c.dom.Document; | 20 import org.w3c.dom.Document; |
21 import org.xml.sax.SAXException; | 21 import org.xml.sax.SAXException; |
22 | 22 |
23 import de.intevation.artifactdatabase.Config; | 23 import de.intevation.artifactdatabase.Config; |
24 import de.intevation.artifactdatabase.FactoryBootstrap; | 24 import de.intevation.artifactdatabase.FactoryBootstrap; |
25 import de.intevation.artifactdatabase.ArtifactDatabaseImpl.CallContextImpl; | |
26 import de.intevation.artifacts.Artifact; | 25 import de.intevation.artifacts.Artifact; |
27 import de.intevation.artifacts.ArtifactFactory; | 26 import de.intevation.artifacts.ArtifactFactory; |
28 import de.intevation.artifacts.CallContext; | 27 import de.intevation.artifacts.CallContext; |
29 import de.intevation.gnv.artifacts.context.GNVArtifactContext; | 28 import de.intevation.gnv.artifacts.context.GNVArtifactContext; |
30 import de.intevation.gnv.utils.ArtifactXMLUtilities; | 29 import de.intevation.gnv.utils.ArtifactXMLUtilities; |
129 log.error(e,e); | 128 log.error(e,e); |
130 } | 129 } |
131 } | 130 } |
132 } | 131 } |
133 | 132 |
133 public void testVerticalProfileArtifact(){ | |
134 log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); | |
135 String artefactName = "fis_marnet"; | |
136 ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); | |
137 assertNotNull(artifactFactory); | |
138 log.debug("VerticalProfile-ArtifactFactory is available"); | |
139 Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); | |
140 assertNotNull(artifact); | |
141 log.debug("VerticalProfile-Artifact is available"); | |
142 | |
143 | |
144 CallContext cc = new TestCallContext(bootstrap.getContext()); | |
145 | |
146 // Erster Schritt | |
147 Document outputData = artifact.describe(null); | |
148 this.writeDocument2Log(outputData); | |
149 artifact.feed(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_01_feed.xml"), cc); | |
150 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_01_advance.xml"), cc); | |
151 this.writeDocument2Log(outputData); | |
152 | |
153 // Zweiter Schritt | |
154 outputData = artifact.describe(null); | |
155 this.writeDocument2Log(outputData); | |
156 artifact.feed(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_02_feed.xml"), cc); | |
157 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"), cc); | |
158 this.writeDocument2Log(outputData); | |
159 | |
160 // Dritter Schritt | |
161 outputData = artifact.describe(null); | |
162 this.writeDocument2Log(outputData); | |
163 artifact.feed(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_03_feed.xml"), cc); | |
164 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_03_advance.xml"), cc); | |
165 this.writeDocument2Log(outputData); | |
166 | |
167 | |
168 // Vierter Schritt | |
169 outputData = artifact.describe(null); | |
170 FileOutputStream fos = null; | |
171 FileOutputStream fos2 = null; | |
172 FileOutputStream fos3 = null; | |
173 try{ | |
174 fos = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".png"); | |
175 fos2 = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".xml"); | |
176 fos3 = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".csv"); | |
177 artifact.feed(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_feed.xml"), cc); | |
178 artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_statistics.xml"),fos2, cc); | |
179 artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_chart.xml"),fos, cc); | |
180 artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_csv.xml"),fos3, cc); | |
181 } catch (Exception e){ | |
182 log.error(e,e); | |
183 fail(); | |
184 }finally{ | |
185 try { | |
186 fos.flush(); | |
187 fos.close(); | |
188 fos2.flush(); | |
189 fos2.close(); | |
190 fos3.flush(); | |
191 fos3.close(); | |
192 } catch (Exception e) { | |
193 log.error(e,e); | |
194 } | |
195 } | |
196 } | |
197 | |
198 public void testVerticalProfileInstantaneousPointArtifact(){ | |
199 log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); | |
200 String artefactName = "fis_instantaneouspoint"; | |
201 ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); | |
202 assertNotNull(artifactFactory); | |
203 log.debug("VerticalProfile-ArtifactFactory is available"); | |
204 Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); | |
205 assertNotNull(artifact); | |
206 log.debug("VerticalProfile-Artifact is available"); | |
207 | |
208 | |
209 CallContext cc = new TestCallContext(bootstrap.getContext()); | |
210 | |
211 // Erster Schritt | |
212 Document outputData = artifact.describe(null); | |
213 this.writeDocument2Log(outputData); | |
214 artifact.feed(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_feed.xml"), cc); | |
215 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_advance.xml"), cc); | |
216 this.writeDocument2Log(outputData); | |
217 | |
218 // Zweiter Schritt | |
219 outputData = artifact.describe(null); | |
220 this.writeDocument2Log(outputData); | |
221 artifact.feed(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_feed.xml"), cc); | |
222 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_advance.xml"), cc); | |
223 this.writeDocument2Log(outputData); | |
224 | |
225 // Dritter Schritt | |
226 outputData = artifact.describe(null); | |
227 this.writeDocument2Log(outputData); | |
228 artifact.feed(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_feed.xml"), cc); | |
229 outputData = artifact.advance(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_advance.xml"), cc); | |
230 this.writeDocument2Log(outputData); | |
231 | |
232 | |
233 // Vierter Schritt | |
234 outputData = artifact.describe(null); | |
235 FileOutputStream fos = null; | |
236 FileOutputStream fos2 = null; | |
237 FileOutputStream fos3 = null; | |
238 try{ | |
239 fos = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".png"); | |
240 fos2 = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".xml"); | |
241 fos3 = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".csv"); | |
242 artifact.feed(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_feed.xml"), cc); | |
243 artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_statistics.xml"),fos2, cc); | |
244 artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_chart.xml"),fos, cc); | |
245 artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_csv.xml"),fos3, cc); | |
246 } catch (Exception e){ | |
247 log.error(e,e); | |
248 fail(); | |
249 }finally{ | |
250 try { | |
251 fos.flush(); | |
252 fos.close(); | |
253 fos2.flush(); | |
254 fos2.close(); | |
255 fos3.flush(); | |
256 fos3.close(); | |
257 } catch (Exception e) { | |
258 log.error(e,e); | |
259 } | |
260 } | |
261 } | |
262 | |
134 protected void createFile(byte[] content, String fileName){ | 263 protected void createFile(byte[] content, String fileName){ |
135 try { | 264 try { |
136 FileOutputStream fos = new FileOutputStream(new File(fileName)); | 265 FileOutputStream fos = new FileOutputStream(new File(fileName)); |
137 ByteArrayInputStream bis = new ByteArrayInputStream(content); | 266 ByteArrayInputStream bis = new ByteArrayInputStream(content); |
138 byte[] buf = new byte[4096]; | 267 byte[] buf = new byte[4096]; |