comparison gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalProfileTestCase.java @ 345:c16c622ba2f3

Split all Unittestcases in separat Classes. Now it is easier to uses the UnitTests with Maven. gnv-artifacts/trunk@412 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 11 Dec 2009 10:02:10 +0000
parents
children 4939236c2dc9
comparison
equal deleted inserted replaced
344:44adf8918155 345:c16c622ba2f3
1 /**
2 *
3 */
4 package de.intevation.gnv.artifacts;
5
6 import java.io.FileOutputStream;
7
8 import org.apache.log4j.Logger;
9 import org.w3c.dom.Document;
10
11 import de.intevation.artifacts.Artifact;
12 import de.intevation.artifacts.ArtifactFactory;
13 import de.intevation.artifacts.CallContext;
14
15 /**
16 * @author Tim Englich <tim.englich@intevation.de>
17 *
18 */
19 public class MeshVerticalProfileTestCase extends GNVArtifactsTestCaseBase {
20
21 private static Logger log = Logger.getLogger(MeshVerticalProfileTestCase.class);
22
23 /**
24 * Constructor
25 */
26 public MeshVerticalProfileTestCase() {
27 }
28
29 /**
30 * Constructor
31 * @param name
32 */
33 public MeshVerticalProfileTestCase(String name) {
34 super(name);
35 }
36
37 /**
38 * @see de.intevation.gnv.artifacts.GNVArtifactsTestCaseBase#testArtifact()
39 */
40 @Override
41 public void testArtifact() {
42 try {
43 log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact");
44 String artefactName = "fis_modeldata";
45 ArtifactFactory artifactFactory = this
46 .getArtifactFactory(artefactName);
47 assertNotNull(artifactFactory);
48 log.debug("VerticalProfile-ArtifactFactory is available");
49 Artifact artifact = artifactFactory.createArtifact(
50 "" + System.currentTimeMillis(), bootstrap.getContext());
51 assertNotNull(artifact);
52 log.debug("VerticalProfile-Artifact is available");
53
54 CallContext cc = createCallContext();
55 Document describeDocument = this.readDocument("src/test/ressources/" +
56 "verticalprofile_mesh/" +
57 "verticalprofile_describe.xml");
58
59 int steps = 10;
60
61 for (int i = 1; i <= steps; i++){
62 String number = ""+i;
63 if (i < 10){
64 number = "0"+number;
65 }
66 this.doNextStep(
67 artifact,
68 cc,
69 "src/test/ressources/verticalprofile_mesh/" +
70 "verticalprofile_step_"+number+"_feed.xml",
71 "src/test/ressources/verticalprofile_mesh/" +
72 "verticalprofile_step_"+number+"_advance.xml",
73 describeDocument);
74 }
75 // 10. Schritt
76 Document outputData = artifact.describe(describeDocument,cc);
77 FileOutputStream fos = null;
78 FileOutputStream fos2 = null;
79 FileOutputStream fos3 = null;
80 FileOutputStream fos4 = null;
81 try {
82 fos = new FileOutputStream(
83 "src/test/results/verticalprofile_mesh"
84 + System.currentTimeMillis() + ".png");
85 fos2 = new FileOutputStream(
86 "src/test/results/verticalprofile_mesh"
87 + System.currentTimeMillis() + ".xml");
88 fos3 = new FileOutputStream(
89 "src/test/results/verticalprofile_mesh"
90 + System.currentTimeMillis() + ".csv");
91 fos4 = new FileOutputStream(
92 "src/test/results/verticalprofile_mesh"
93 + System.currentTimeMillis() + ".odv");
94 artifact.out(this.readDocument("src/test/ressources/" +
95 "verticalprofile_mesh/" +
96 "verticalprofile_step_10_out_statistics.xml"),
97 fos2, cc);
98 artifact.out(this.readDocument("src/test/ressources/" +
99 "verticalprofile_mesh/" +
100 "verticalprofile_step_10_out_chart.xml"),
101 fos, cc);
102 artifact.out(this.readDocument("src/test/ressources/" +
103 "verticalprofile_mesh/" +
104 "verticalprofile_step_10_out_csv.xml"),
105 fos3, cc);
106 artifact.out(this.readDocument("src/test/ressources/" +
107 "verticalprofile_mesh/" +
108 "verticalprofile_step_10_out_odv.xml"),
109 fos4, cc);
110 } catch (Exception e) {
111 log.error(e, e);
112 fail();
113 } finally {
114 try {
115 fos.flush();
116 fos.close();
117 fos2.flush();
118 fos2.close();
119 fos3.flush();
120 fos3.close();
121 fos4.flush();
122 fos4.close();
123 } catch (Exception e) {
124 log.error(e, e);
125 }
126 }
127 } catch (Exception e) {
128 log.error(e, e);
129 fail();
130 }
131 }
132
133 }

http://dive4elements.wald.intevation.org