annotate gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java @ 72:1fece4da4f2f

TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet gnv-artifacts/trunk@63 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 10 Sep 2009 13:14:03 +0000
parents f24c825144bc
children 504570de21fd
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
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
12 import javax.xml.parsers.DocumentBuilder;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import javax.xml.parsers.DocumentBuilderFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import javax.xml.parsers.ParserConfigurationException;
72
1fece4da4f2f TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet
Tim Englich <tim.englich@intevation.de>
parents: 69
diff changeset
15
1fece4da4f2f TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet
Tim Englich <tim.englich@intevation.de>
parents: 69
diff changeset
16 import junit.framework.TestCase;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.BasicConfigurator;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import org.w3c.dom.Document;
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
21 import org.xml.sax.SAXException;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.artifactdatabase.Config;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import de.intevation.artifactdatabase.FactoryBootstrap;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.Artifact;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import de.intevation.artifacts.ArtifactFactory;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
72
1fece4da4f2f TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet
Tim Englich <tim.englich@intevation.de>
parents: 69
diff changeset
28 import de.intevation.gnv.utils.ArtifactXMLUtilities;
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 * @author Tim Englich <tim.englich@intevation.de>
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 *
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 public class GNVArtifactsTestCase extends 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 * 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
38 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 private static Logger log = null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 static {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 BasicConfigurator.configure();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 log = Logger.getLogger(GNVArtifactContext.class);
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
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
46 private String configurationDir = "src/test/ressources/";
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 private FactoryBootstrap bootstrap = null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 * Constructor
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 * @param name
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 public GNVArtifactsTestCase(String name) {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 super(name);
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
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 * @see junit.framework.TestCase#setUp()
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 */
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 protected void setUp() throws Exception {
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 log.debug("GNVArtifactsTestCase.setUp");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 super.setUp();
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
63 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
64 System.setProperty(Config.CONFIG_DIR, configurationDir);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 log.info("Bootstrap wird initialisiert.");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 bootstrap = new FactoryBootstrap();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 bootstrap.boot();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 public void testTimeSeriesArtifact(){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 log.debug("GNVArtifactsTestCase.testTimeSeriesArtifact");
72
1fece4da4f2f TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet
Tim Englich <tim.englich@intevation.de>
parents: 69
diff changeset
72 String artefactName = "fis_marnet";
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 assertNotNull(artifactFactory);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 log.debug("TimeSeries-ArtifactFactory is available");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext());
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 assertNotNull(artifact);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 log.debug("TimeSeries-Artifact is available");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
80 // Erster Schritt
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
81 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
82 this.writeDocument2Log(outputData);
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
83 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
84 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
85 this.writeDocument2Log(outputData);
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
86
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
87 // Zweiter Schritt
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
88 outputData = artifact.describe(bootstrap.getContext());
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
89 this.writeDocument2Log(outputData);
60
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
90 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
91 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
92 this.writeDocument2Log(outputData);
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
93
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
94 // Dritter Schritt
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
95 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
96 this.writeDocument2Log(outputData);
eed1baaeb481 TestCase implemented until Choosing the TimeInetval of an TimeSeries
Tim Englich <tim.englich@intevation.de>
parents: 58
diff changeset
97 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
98 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
99 this.writeDocument2Log(outputData);
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101
62
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
102 // Vierter Schritt
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
103 outputData = artifact.describe(bootstrap.getContext());
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
104 this.writeDocument2Log(outputData);
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
105 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
106 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
107 this.writeDocument2Log(outputData);
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
108
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
109 // F�nfter Schritt
9f57053d0384 Testcases Modified
Tim Englich <tim.englich@intevation.de>
parents: 60
diff changeset
110 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
111 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
112 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
113 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
114 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
116 protected void createFile(byte[] content, String fileName){
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 try {
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
118 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
119 ByteArrayInputStream bis = new ByteArrayInputStream(content);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
120 byte[] buf = new byte[4096];
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
121 while (bis.read(buf) > 0){
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
122 fos.write(buf);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
123 }
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
124 fos.flush();
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
125 fos.close();
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
126 } catch (FileNotFoundException e) {
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
127 log.error(e,e);
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
128 } catch (IOException e) {
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 log.error(e,e);
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131 }
69
f24c825144bc TestCase Refactored to the new Folder-Based Configuration.
Tim Englich <tim.englich@intevation.de>
parents: 62
diff changeset
132
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 /**
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 * @param artefactName
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 private ArtifactFactory getArtifactFactory(String artefactName){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 log.debug("GNVArtifactsTestCase.getArtifactFactory");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139 ArtifactFactory[] artifactFactories = bootstrap.getArtifactFactories();
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 for (int i = 0; i < artifactFactories.length; i++){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 if (artifactFactories[i].getName().equals(artefactName)){
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 log.debug("ArtifactFactory wurde gefunden.");
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 return artifactFactories[i];
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 }
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 return null;
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 }
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
148
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
149 protected void writeDocument2Log(Document document){
72
1fece4da4f2f TestCase moved from TimeSeriesArtifact to FISArtifact. Used FIS: Marnet
Tim Englich <tim.englich@intevation.de>
parents: 69
diff changeset
150 log.debug(new ArtifactXMLUtilities().writeDocument2String(document));
54
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
151 }
09b4bf848c7b 2009-09-08 Tim Englich <tim.englich@intevation.de>
Tim Englich <tim.englich@intevation.de>
parents: 52
diff changeset
152
58
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
153
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
154 protected Document readDocument(String fileName){
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
155 Document returnValue = null;
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
156 try {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
157 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
158 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
159 returnValue = docBuilder.parse (new File(fileName));
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
160 } catch (ParserConfigurationException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
161 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
162 } catch (SAXException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
163 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
164 } catch (IOException e) {
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
165 log.error(e,e);
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
166 }
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
167 return returnValue;
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
168 }
f31343d80d53 Artifact.advance initial implementiert
Tim Englich <tim.englich@intevation.de>
parents: 54
diff changeset
169
52
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170
4d6a82b96059 First Implementation of the GNV-Artifacts
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 }

http://dive4elements.wald.intevation.org