Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java @ 69:f24c825144bc
TestCase Refactored to the new Folder-Based Configuration.
Also added further steps to the Testcase.
gnv-artifacts/trunk@56 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 10 Sep 2009 07:57:30 +0000 |
parents | 9f57053d0384 |
children | 1fece4da4f2f |
line wrap: on
line diff
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Wed Sep 09 15:28:18 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Thu Sep 10 07:57:30 2009 +0000 @@ -3,7 +3,10 @@ */ package de.intevation.gnv.artifacts; +import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.StringWriter; @@ -28,7 +31,6 @@ import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; import de.intevation.gnv.artifacts.context.GNVArtifactContext; -import de.intevation.gnv.artifacts.context.GNVArtifactContextFactory; import junit.framework.TestCase; /** @@ -47,7 +49,7 @@ log = Logger.getLogger(GNVArtifactContext.class); } - private String configurationFile = "src/test/ressources/GNVArtifactsTestCase_Configuration.xml"; + private String configurationDir = "src/test/ressources/"; private FactoryBootstrap bootstrap = null; /** @@ -64,8 +66,8 @@ protected void setUp() throws Exception { log.debug("GNVArtifactsTestCase.setUp"); super.setUp(); - log.info(Config.CONFIG_PROPERTY + " ==> "+configurationFile); - System.setProperty(Config.CONFIG_PROPERTY, configurationFile); + log.info(Config.CONFIG_DIR + " ==> "+configurationDir); + System.setProperty(Config.CONFIG_DIR, configurationDir); log.info("Bootstrap wird initialisiert."); bootstrap = new FactoryBootstrap(); bootstrap.boot(); @@ -112,25 +114,28 @@ // Fünfter Schritt outputData = artifact.describe(bootstrap.getContext()); - this.writeDocument2Log(outputData); - - } - private Document getDocument(){ - return this.createOutputDocument(); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), bootstrap.getContext()); + byte[] result = artifact.out(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"), bootstrap.getContext()); + this.createFile(result, "src/test/results/timeseriesdiagramm"+System.currentTimeMillis()+".png"); } - private Document createOutputDocument(){ + protected void createFile(byte[] content, String fileName){ try { - return DocumentBuilderFactory - .newInstance() - .newDocumentBuilder() - .newDocument(); - } - catch (ParserConfigurationException e) { + FileOutputStream fos = new FileOutputStream(new File(fileName)); + ByteArrayInputStream bis = new ByteArrayInputStream(content); + byte[] buf = new byte[4096]; + while (bis.read(buf) > 0){ + fos.write(buf); + } + fos.flush(); + fos.close(); + } catch (FileNotFoundException e) { + log.error(e,e); + } catch (IOException e) { log.error(e,e); } - return null; } + /** * @param artefactName