annotate gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java @ 71:e4ecf3188bdf

Integrated FIS-Artifact gnv-artifacts/trunk@62 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 10 Sep 2009 13:11:24 +0000
parents f24c825144bc
children 1fece4da4f2f
rev   line source
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.artifacts;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
6 import java.io.ByteArrayInputStream;
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
7 import java.io.File;
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
8 import java.io.FileNotFoundException;
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
9 import java.io.FileOutputStream;
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
10 import java.io.IOException;
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
11 import java.io.StringWriter;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
12
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
13 import javax.xml.parsers.DocumentBuilder;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import javax.xml.parsers.DocumentBuilderFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import javax.xml.parsers.ParserConfigurationException;
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
16 import javax.xml.transform.Transformer;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
17 import javax.xml.transform.TransformerConfigurationException;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
18 import javax.xml.transform.TransformerException;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
19 import javax.xml.transform.TransformerFactory;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
20 import javax.xml.transform.TransformerFactoryConfigurationError;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
21 import javax.xml.transform.dom.DOMSource;
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
22 import javax.xml.transform.stream.StreamResult;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import org.apache.log4j.BasicConfigurator;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import org.apache.log4j.Logger;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import org.w3c.dom.Document;
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
27 import org.xml.sax.SAXException;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import de.intevation.artifactdatabase.Config;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import de.intevation.artifactdatabase.FactoryBootstrap;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import de.intevation.artifacts.Artifact;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import de.intevation.artifacts.ArtifactFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import junit.framework.TestCase;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 * @author Tim Englich <tim.englich@intevation.de>
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 *
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 public class GNVArtifactsTestCase extends TestCase {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 * the logger, used to log exceptions and additonaly information
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 private static Logger log = null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 static {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 BasicConfigurator.configure();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 log = Logger.getLogger(GNVArtifactContext.class);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
52 private String configurationDir = "src/test/ressources/";
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 private FactoryBootstrap bootstrap = null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 * Constructor
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 * @param name
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 public GNVArtifactsTestCase(String name) {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 super(name);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 * @see junit.framework.TestCase#setUp()
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 protected void setUp() throws Exception {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 log.debug("GNVArtifactsTestCase.setUp");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 super.setUp();
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
69 log.info(Config.CONFIG_DIR + " ==> "+configurationDir);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
70 System.setProperty(Config.CONFIG_DIR, configurationDir);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 log.info("Bootstrap wird initialisiert.");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 bootstrap = new FactoryBootstrap();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 bootstrap.boot();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 public void testTimeSeriesArtifact(){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 log.debug("GNVArtifactsTestCase.testTimeSeriesArtifact");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 String artefactName = "timeSeries";
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 assertNotNull(artifactFactory);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 log.debug("TimeSeries-ArtifactFactory is available");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext());
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 assertNotNull(artifact);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 log.debug("TimeSeries-Artifact is available");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
86 // Erster Schritt
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
87 Document outputData = artifact.describe(bootstrap.getContext());
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
88 this.writeDocument2Log(outputData);
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
89 artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_feed.xml"), bootstrap.getContext());
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
90 outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_advance.xml"), bootstrap.getContext());
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
91 this.writeDocument2Log(outputData);
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
92
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
93 // Zweiter Schritt
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
94 outputData = artifact.describe(bootstrap.getContext());
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
95 this.writeDocument2Log(outputData);
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
96 artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_feed.xml"), bootstrap.getContext());
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
97 outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_advance.xml"), bootstrap.getContext());
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
98 this.writeDocument2Log(outputData);
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
99
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
100 // Dritter Schritt
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
101 outputData = artifact.describe(bootstrap.getContext());
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
102 this.writeDocument2Log(outputData);
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
103 artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_feed.xml"), bootstrap.getContext());
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
104 outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_advance.xml"), bootstrap.getContext());
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
105 this.writeDocument2Log(outputData);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107
62
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
108 // Vierter Schritt
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
109 outputData = artifact.describe(bootstrap.getContext());
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
110 this.writeDocument2Log(outputData);
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
111 artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_feed.xml"), bootstrap.getContext());
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
112 outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_advance.xml"), bootstrap.getContext());
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
113 this.writeDocument2Log(outputData);
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
114
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
115 // F�nfter Schritt
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
116 outputData = artifact.describe(bootstrap.getContext());
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
117 artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), bootstrap.getContext());
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
118 byte[] result = artifact.out(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"), bootstrap.getContext());
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
119 this.createFile(result, "src/test/results/timeseriesdiagramm"+System.currentTimeMillis()+".png");
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
122 protected void createFile(byte[] content, String fileName){
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 try {
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
124 FileOutputStream fos = new FileOutputStream(new File(fileName));
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
125 ByteArrayInputStream bis = new ByteArrayInputStream(content);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
126 byte[] buf = new byte[4096];
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
127 while (bis.read(buf) > 0){
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
128 fos.write(buf);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
129 }
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
130 fos.flush();
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
131 fos.close();
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
132 } catch (FileNotFoundException e) {
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
133 log.error(e,e);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
134 } catch (IOException e) {
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 log.error(e,e);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 }
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
138
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 * @param artefactName
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 private ArtifactFactory getArtifactFactory(String artefactName){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 log.debug("GNVArtifactsTestCase.getArtifactFactory");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 ArtifactFactory[] artifactFactories = bootstrap.getArtifactFactories();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 for (int i = 0; i < artifactFactories.length; i++){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 if (artifactFactories[i].getName().equals(artefactName)){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 log.debug("ArtifactFactory wurde gefunden.");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 return artifactFactories[i];
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 return null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 }
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
154
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
155 protected void writeDocument2Log(Document document){
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
156 try {
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
157 TransformerFactory transformerFactory = TransformerFactory.newInstance();
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
158 Transformer transformer = transformerFactory.newTransformer();
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
159 DOMSource source = new DOMSource(document);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
160 StringWriter sw = new StringWriter();
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
161 StreamResult result = new StreamResult(sw);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
162 transformer.transform(source, result);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
163 log.debug(sw.getBuffer().toString());
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
164 } catch (TransformerConfigurationException e) {
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
165 log.error(e,e);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
166 } catch (TransformerFactoryConfigurationError e) {
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
167 log.error(e,e);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
168 } catch (TransformerException e) {
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
169 log.error(e,e);
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
170 }
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
171 }
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
172
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
173
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
174 protected Document readDocument(String fileName){
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
175 Document returnValue = null;
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
176 try {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
177 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
178 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
179 returnValue = docBuilder.parse (new File(fileName));
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
180 } catch (ParserConfigurationException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
181 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
182 } catch (SAXException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
183 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
184 } catch (IOException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
185 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
186 }
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
187 return returnValue;
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
188 }
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
189
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 }

http://dive4elements.wald.intevation.org