tim@52: /** tim@52: * tim@52: */ tim@52: package de.intevation.gnv.artifacts; tim@52: tim@69: import java.io.ByteArrayInputStream; tim@58: import java.io.File; tim@69: import java.io.FileNotFoundException; tim@69: import java.io.FileOutputStream; tim@58: import java.io.IOException; tim@54: tim@58: import javax.xml.parsers.DocumentBuilder; tim@52: import javax.xml.parsers.DocumentBuilderFactory; tim@52: import javax.xml.parsers.ParserConfigurationException; tim@72: tim@72: import junit.framework.TestCase; tim@52: tim@52: import org.apache.log4j.BasicConfigurator; tim@52: import org.apache.log4j.Logger; tim@52: import org.w3c.dom.Document; tim@58: import org.xml.sax.SAXException; tim@52: tim@52: import de.intevation.artifactdatabase.Config; tim@117: import de.intevation.artifactdatabase.DefaultCallMeta; tim@117: import de.intevation.artifactdatabase.DefaultPreferredLocale; tim@52: import de.intevation.artifactdatabase.FactoryBootstrap; tim@52: import de.intevation.artifacts.Artifact; tim@52: import de.intevation.artifacts.ArtifactFactory; tim@102: import de.intevation.artifacts.CallContext; tim@117: import de.intevation.artifacts.CallMeta; tim@117: import de.intevation.artifacts.PreferredLocale; tim@52: import de.intevation.gnv.artifacts.context.GNVArtifactContext; tim@72: import de.intevation.gnv.utils.ArtifactXMLUtilities; tim@52: tim@52: /** tim@52: * @author Tim Englich tim@171: * tim@52: */ tim@52: public class GNVArtifactsTestCase extends TestCase { tim@52: tim@52: /** tim@52: * the logger, used to log exceptions and additonaly information tim@52: */ tim@52: private static Logger log = null; tim@171: tim@52: static { tim@52: BasicConfigurator.configure(); tim@52: log = Logger.getLogger(GNVArtifactContext.class); tim@52: } tim@171: tim@69: private String configurationDir = "src/test/ressources/"; tim@171: tim@52: private FactoryBootstrap bootstrap = null; tim@171: tim@52: /** tim@52: * Constructor tim@171: * tim@52: * @param name tim@52: */ tim@52: public GNVArtifactsTestCase(String name) { tim@52: super(name); tim@52: } tim@52: tim@52: /** tim@52: * @see junit.framework.TestCase#setUp() tim@52: */ tim@52: protected void setUp() throws Exception { tim@52: log.debug("GNVArtifactsTestCase.setUp"); tim@52: super.setUp(); tim@171: log.info(Config.CONFIG_DIR + " ==> " + configurationDir); tim@69: System.setProperty(Config.CONFIG_DIR, configurationDir); tim@52: log.info("Bootstrap wird initialisiert."); tim@52: bootstrap = new FactoryBootstrap(); tim@52: bootstrap.boot(); tim@52: } tim@171: tim@171: public void testTimeSeriesArtifact() { tim@106: try { tim@106: log.debug("GNVArtifactsTestCase.testTimeSeriesArtifact"); tim@171: String artefactName = "fis_marnet"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@106: assertNotNull(artifactFactory); tim@106: log.debug("TimeSeries-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@106: assertNotNull(artifact); tim@106: log.debug("TimeSeries-Artifact is available"); tim@171: tim@117: CallContext cc = createCallContext(); tim@171: tim@106: // Erster Schritt tim@171: tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries/timeseries_step_01_feed.xml", tim@171: "src/test/ressources/timeseries/timeseries_step_01_advance.xml"); tim@171: tim@106: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries/timeseries_step_02_feed.xml", tim@171: "src/test/ressources/timeseries/timeseries_step_02_advance.xml"); tim@171: tim@106: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries/timeseries_step_03_feed.xml", tim@171: "src/test/ressources/timeseries/timeseries_step_03_advance.xml"); tim@171: tim@106: // Vierter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries/timeseries_step_04_feed.xml", tim@171: "src/test/ressources/timeseries/timeseries_step_04_advance.xml"); tim@171: tim@109: Document outputData; tim@106: // Fünfter Schritt tim@117: outputData = artifact.describe(cc); tim@106: FileOutputStream fos = null; tim@171: try { tim@171: fos = new FileOutputStream( tim@171: "src/test/results/timeseriesdiagramm" tim@171: + System.currentTimeMillis() + ".png"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"), tim@171: fos, cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@106: fail(); tim@171: } finally { tim@106: try { tim@106: fos.flush(); tim@106: fos.close(); tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@106: } tim@106: } tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@73: fail(); tim@73: } tim@52: } tim@109: tim@109: /** tim@117: * @return tim@117: */ tim@117: private CallContext createCallContext() { tim@171: CallMeta callMeta = new DefaultCallMeta( tim@171: new PreferredLocale[] { new DefaultPreferredLocale("de_DE", tim@171: 1.0f) }); tim@171: CallContext cc = new TestCallContext(bootstrap.getContext(), callMeta); tim@117: return cc; tim@117: } tim@117: tim@117: /** tim@109: * @param artifact tim@109: * @param cc tim@109: * @throws Exception tim@109: */ tim@171: private void doNextStep(Artifact artifact, CallContext cc, tim@171: String feedDocument, String advanceDocument) tim@171: throws Exception { tim@117: Document outputData = artifact.describe(cc); tim@109: this.writeDocument2Log(outputData); tim@111: outputData = artifact.feed(this.readDocument(feedDocument), cc); tim@111: this.check4ExceptionReport(outputData); tim@109: outputData = artifact.advance(this.readDocument(advanceDocument), cc); tim@109: this.writeDocument2Log(outputData); tim@109: this.check4ExceptionReport(outputData); tim@171: tim@109: } tim@171: tim@171: public void testTimeSeriesMeshArtifact() { tim@107: try { tim@107: log.debug("GNVArtifactsTestCase.testTimeSeriesMeshArtifact"); tim@171: String artefactName = "fis_modeldata"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@107: assertNotNull(artifactFactory); tim@107: log.debug("TimeSeriesMesh-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@107: assertNotNull(artifact); tim@107: log.debug("TimeSeriesMesh-Artifact is available"); tim@171: tim@117: CallContext cc = createCallContext(); tim@171: tim@107: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_01_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_01_advance.xml"); tim@171: tim@107: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_02_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_02_advance.xml"); tim@171: tim@107: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_03_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_03_advance.xml"); tim@171: tim@107: // Vierter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_04_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_04_advance.xml"); tim@171: tim@107: // Fünfter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_05_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_05_advance.xml"); tim@171: tim@107: // Sechster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_06_feed.xml", tim@171: "src/test/ressources/timeseries_mesh/timeseries_step_06_advance.xml"); tim@171: tim@107: // Siebter Schritt tim@117: Document outputData = artifact.describe(cc); tim@107: FileOutputStream fos = null; tim@107: FileOutputStream fos2 = null; tim@107: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream("src/test/results/timeseries_mesh" tim@171: + System.currentTimeMillis() tim@171: + ".png"); tim@171: fos2 = new FileOutputStream("src/test/results/timeseries_mesh" tim@171: + System.currentTimeMillis() tim@171: + ".xml"); tim@171: fos3 = new FileOutputStream("src/test/results/timeseries_mesh" tim@171: + System.currentTimeMillis() tim@171: + ".csv"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_statistics.xml"), tim@171: fos2, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_chart.xml"), tim@171: fos, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_csv.xml"), tim@171: fos3, cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@107: fail(); tim@171: } finally { tim@106: try { tim@106: fos.flush(); tim@106: fos.close(); tim@106: fos2.flush(); tim@106: fos2.close(); tim@106: fos3.flush(); tim@106: fos3.close(); tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@106: } tim@106: } tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@103: fail(); tim@103: } tim@103: } tim@171: tim@171: public void testVerticalProfileArtifact() { tim@106: try { tim@106: log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); tim@171: String artefactName = "fis_marnet"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@106: assertNotNull(artifactFactory); tim@106: log.debug("VerticalProfile-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@106: assertNotNull(artifact); tim@106: log.debug("VerticalProfile-Artifact is available"); tim@171: tim@117: CallContext cc = createCallContext(); tim@171: tim@106: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_01_feed.xml", tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); tim@171: tim@106: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_02_feed.xml", tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); tim@171: tim@106: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_03_feed.xml", tim@171: "src/test/ressources/verticalprofile/verticalprofile_step_03_advance.xml"); tim@171: tim@107: // Vierter Schritt tim@117: Document outputData = artifact.describe(cc); tim@106: FileOutputStream fos = null; tim@106: FileOutputStream fos2 = null; tim@106: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream("src/test/results/verticalprofile" tim@171: + System.currentTimeMillis() tim@171: + ".png"); tim@171: fos2 = new FileOutputStream("src/test/results/verticalprofile" tim@171: + System.currentTimeMillis() tim@171: + ".xml"); tim@171: fos3 = new FileOutputStream("src/test/results/verticalprofile" tim@171: + System.currentTimeMillis() tim@171: + ".csv"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_statistics.xml"), tim@171: fos2, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_chart.xml"), tim@171: fos, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_csv.xml"), tim@171: fos3, cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@106: fail(); tim@171: } finally { tim@106: try { tim@106: fos.flush(); tim@106: fos.close(); tim@106: fos2.flush(); tim@106: fos2.close(); tim@106: fos3.flush(); tim@106: fos3.close(); tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@106: } tim@106: } tim@106: } catch (Exception e) { tim@171: log.error(e, e); tim@103: fail(); tim@103: } tim@103: } tim@171: tim@171: public void testVerticalProfileMeshArtifact() { tim@114: try { tim@171: log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); tim@171: String artefactName = "fis_modeldata"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@114: assertNotNull(artifactFactory); tim@114: log.debug("VerticalProfile-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@114: assertNotNull(artifact); tim@114: log.debug("VerticalProfile-Artifact is available"); tim@171: tim@117: CallContext cc = createCallContext(); tim@171: tim@114: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_feed.xml", tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_advance.xml"); tim@171: tim@114: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_feed.xml", tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_advance.xml"); tim@171: tim@114: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_feed.xml", tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_advance.xml"); tim@171: tim@114: // Vierter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_feed.xml", tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_advance.xml"); tim@171: tim@171: // Fünfter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_feed.xml", tim@171: "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_advance.xml"); tim@171: tim@171: // Sechster Schritt tim@117: Document outputData = artifact.describe(cc); tim@114: FileOutputStream fos = null; tim@114: FileOutputStream fos2 = null; tim@114: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream( tim@171: "src/test/results/verticalprofile_mesh" tim@171: + System.currentTimeMillis() + ".png"); tim@171: fos2 = new FileOutputStream( tim@171: "src/test/results/verticalprofile_mesh" tim@171: + System.currentTimeMillis() + ".xml"); tim@171: fos3 = new FileOutputStream( tim@171: "src/test/results/verticalprofile_mesh" tim@171: + System.currentTimeMillis() + ".csv"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_statistics.xml"), tim@171: fos2, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_chart.xml"), tim@171: fos, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_csv.xml"), tim@171: fos3, cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@114: fail(); tim@171: } finally { tim@114: try { tim@114: fos.flush(); tim@114: fos.close(); tim@114: fos2.flush(); tim@114: fos2.close(); tim@114: fos3.flush(); tim@114: fos3.close(); tim@114: } catch (Exception e) { tim@171: log.error(e, e); tim@114: } tim@114: } tim@114: } catch (Exception e) { tim@171: log.error(e, e); tim@114: fail(); tim@114: } tim@114: } tim@171: tim@171: public void testVerticalProfileInstantaneousPointArtifact() { tim@116: try { tim@171: log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); tim@171: String artefactName = "fis_bsh_ctd"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@116: assertNotNull(artifactFactory); tim@116: log.debug("VerticalProfile-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@116: assertNotNull(artifact); tim@116: log.debug("VerticalProfile-Artifact is available"); tim@171: tim@117: CallContext cc = createCallContext(); tim@171: tim@116: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_feed.xml", tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_advance.xml"); tim@171: tim@116: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_feed.xml", tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_advance.xml"); tim@171: tim@116: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_feed.xml", tim@171: "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_advance.xml"); tim@171: tim@116: // Vierter Schritt tim@117: Document outputData = artifact.describe(cc); tim@116: FileOutputStream fos = null; tim@116: FileOutputStream fos2 = null; tim@116: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream( tim@171: "src/test/results/verticalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".png"); tim@171: fos2 = new FileOutputStream( tim@171: "src/test/results/verticalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".xml"); tim@171: fos3 = new FileOutputStream( tim@171: "src/test/results/verticalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".csv"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_statistics.xml"), tim@171: fos2, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_chart.xml"), tim@171: fos, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_csv.xml"), tim@171: fos3, cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@116: fail(); tim@171: } finally { tim@116: try { tim@116: fos.flush(); tim@116: fos.close(); tim@116: fos2.flush(); tim@116: fos2.close(); tim@116: fos3.flush(); tim@116: fos3.close(); tim@116: } catch (Exception e) { tim@171: log.error(e, e); tim@116: } tim@116: } tim@116: } catch (Exception e) { tim@171: log.error(e, e); tim@116: fail(); tim@116: } tim@116: } tim@171: tim@171: public void testHorizontalProfileInstantaneousPointArtifact() { tim@171: try { tim@171: log tim@171: .debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); tim@171: String artefactName = "fis_delphin"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@171: assertNotNull(artifactFactory); tim@171: log.debug("VerticalProfile-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@171: assertNotNull(artifact); tim@171: log.debug("VerticalProfile-Artifact is available"); tim@171: tim@171: CallContext cc = createCallContext(); tim@171: tim@171: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_advance.xml"); tim@171: tim@171: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_advance.xml"); tim@171: tim@171: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_advance.xml"); tim@171: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_advance.xml"); tim@171: // Vierter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_advance.xml"); tim@171: // Fünfter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_feed.xml", tim@171: "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_advance.xml"); tim@171: tim@171: Document outputData = artifact.describe(cc); tim@171: FileOutputStream fos = null; tim@171: FileOutputStream fos2 = null; tim@171: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream( tim@171: "src/test/results/horizontalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".png"); tim@171: fos2 = new FileOutputStream( tim@171: "src/test/results/horizontalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".xml"); tim@171: fos3 = new FileOutputStream( tim@171: "src/test/results/horizontalprofile_instantaneouspoint" tim@171: + System.currentTimeMillis() + ".csv"); tim@171: artifact tim@171: .feed( tim@177: this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_feed.xml"), tim@171: cc); tim@177: artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_statistics.xml"), tim@177: fos2, tim@177: cc); tim@177: artifact.out( tim@177: this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_chart.xml"), tim@177: fos, tim@177: cc); tim@177: artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_csv.xml"), tim@177: fos3, tim@177: cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: fail(); tim@171: } finally { tim@171: try { tim@171: fos.flush(); tim@171: fos.close(); tim@171: fos2.flush(); tim@171: fos2.close(); tim@171: fos3.flush(); tim@171: fos3.close(); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: } tim@171: } tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: fail(); tim@171: } tim@171: } tim@171: tim@171: public void testHorizontalProfileMeshPointArtifact() { tim@171: try { tim@171: log tim@171: .debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); tim@171: String artefactName = "fis_modeldata"; tim@171: ArtifactFactory artifactFactory = this tim@171: .getArtifactFactory(artefactName); tim@171: assertNotNull(artifactFactory); tim@171: log.debug("VerticalProfile-ArtifactFactory is available"); tim@171: Artifact artifact = artifactFactory.createArtifact( tim@171: "" + System.currentTimeMillis(), bootstrap.getContext()); tim@171: assertNotNull(artifact); tim@171: log.debug("VerticalProfile-Artifact is available"); tim@171: tim@171: CallContext cc = createCallContext(); tim@171: tim@171: // Erster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_advance.xml"); tim@171: tim@171: // Zweiter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_advance.xml"); tim@171: // Dritter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_advance.xml"); tim@171: // Vierter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_advance.xml"); tim@171: // Fünfter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_advance.xml"); tim@171: tim@171: // Sechster Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_advance.xml"); tim@171: tim@171: // Siebter Schritt tim@171: this tim@171: .doNextStep( tim@171: artifact, tim@171: cc, tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_feed.xml", tim@171: "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_advance.xml"); tim@171: tim@171: Document outputData = artifact.describe(cc); tim@171: FileOutputStream fos = null; tim@171: FileOutputStream fos2 = null; tim@171: FileOutputStream fos3 = null; tim@171: try { tim@171: fos = new FileOutputStream( tim@171: "src/test/results/horizontalProfile_mesh" tim@171: + System.currentTimeMillis() + ".png"); tim@171: fos2 = new FileOutputStream( tim@171: "src/test/results/horizontalProfile_mesh" tim@171: + System.currentTimeMillis() + ".xml"); tim@171: fos3 = new FileOutputStream( tim@171: "src/test/results/horizontalProfile_mesh" tim@171: + System.currentTimeMillis() + ".csv"); tim@171: artifact tim@171: .feed( tim@171: this tim@171: .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_feed.xml"), tim@171: cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_statistics.xml"), tim@171: fos2, cc); tim@171: artifact tim@171: .out( tim@171: this tim@171: .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_chart.xml"), tim@171: fos, cc); tim@177: artifact.out(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_csv.xml"), tim@177: fos3, tim@177: cc); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: fail(); tim@171: } finally { tim@171: try { tim@171: fos.flush(); tim@171: fos.close(); tim@171: fos2.flush(); tim@171: fos2.close(); tim@171: fos3.flush(); tim@171: fos3.close(); tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: } tim@171: } tim@171: } catch (Exception e) { tim@171: log.error(e, e); tim@171: fail(); tim@171: } tim@171: } tim@171: tim@171: protected void createFile(byte[] content, String fileName) { tim@52: try { tim@69: FileOutputStream fos = new FileOutputStream(new File(fileName)); tim@69: ByteArrayInputStream bis = new ByteArrayInputStream(content); tim@69: byte[] buf = new byte[4096]; tim@171: while (bis.read(buf) > 0) { tim@171: fos.write(buf); tim@69: } tim@69: fos.flush(); tim@69: fos.close(); tim@69: } catch (FileNotFoundException e) { tim@171: log.error(e, e); tim@69: } catch (IOException e) { tim@171: log.error(e, e); tim@52: } tim@52: } tim@52: tim@52: /** tim@52: * @param artefactName tim@52: */ tim@171: private ArtifactFactory getArtifactFactory(String artefactName) { tim@52: log.debug("GNVArtifactsTestCase.getArtifactFactory"); tim@52: ArtifactFactory[] artifactFactories = bootstrap.getArtifactFactories(); tim@171: for (int i = 0; i < artifactFactories.length; i++) { tim@171: if (artifactFactories[i].getName().equals(artefactName)) { tim@52: log.debug("ArtifactFactory wurde gefunden."); tim@52: return artifactFactories[i]; tim@52: } tim@52: } tim@52: return null; tim@52: } tim@171: tim@171: protected void writeDocument2Log(Document document) { tim@72: log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); tim@54: } tim@171: tim@171: protected Document readDocument(String fileName) { tim@58: Document returnValue = null; tim@58: try { tim@171: DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory tim@171: .newInstance(); tim@58: DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); tim@171: returnValue = docBuilder.parse(new File(fileName)); tim@58: } catch (ParserConfigurationException e) { tim@171: log.error(e, e); tim@58: } catch (SAXException e) { tim@171: log.error(e, e); tim@58: } catch (IOException e) { tim@171: log.error(e, e); tim@58: } tim@58: return returnValue; tim@58: } tim@52: tim@171: private void check4ExceptionReport(Document document) throws Exception { tim@106: document = new ArtifactXMLUtilities().reInitDocument(document); tim@171: String message = Config.getStringXPath(document, tim@171: "/exceptionreport/exception"); tim@171: if (message != null) { tim@106: throw new Exception(message); tim@106: } tim@106: } tim@52: }