changeset 485:4939236c2dc9

Fixed Compilation and Runtimeerrors in Unittests. gnv-artifacts/trunk@560 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 18 Jan 2010 11:26:51 +0000
parents 823e4f808418
children 67f6346fb300
files gnv-artifacts/ChangeLog gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCaseBase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointHorizontalProfileTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointVerticalProfileTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalCrossSectionTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalProfileTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshTimeSeriesTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalCrossSectionTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalProfileTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestArtifactDatabase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestCallContext.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointTimeSeriesTestCase.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointVerticalProfileTestCase.java
diffstat 13 files changed, 142 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Jan 18 11:26:51 2010 +0000
@@ -1,3 +1,26 @@
+2010-01-18  Tim Englich  <tim.englich@intevation.de>
+
+    * src/test/java/de/intevation/gnv/artifacts/TestArtifactDatabase.java (TestArtifactDatabase): 
+      New: Added an Testimplementation of the ArtifactDatabase to the Tests to uses it inside the
+      TestCallcontext to prevent NPEs during the Testzenarios.
+      
+    * src/test/java/de/intevation/gnv/artifacts/TestCallContext.java (TestCallContext): 
+      Added Artifactfactory to the Methodsignature of the Context to use it inside the Context.
+      Added the Method getDatabase to resolve Compilationerrors.
+      
+    * src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointVerticalProfileTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointTimeSeriesTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/MeshVerticalProfileTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/MeshVerticalCrossSectionTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/MeshTimeSeriesTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/MeshHorizontalProfileTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/MeshHorizontalCrossSectionTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/InstantaneousPointVerticalProfileTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/InstantaneousPointHorizontalProfileTestCase.java (testArtifact),
+      src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCaseBase.java (createCallContext): 
+      Changed Methodsignature of createCallContext. Add the Artifactfactory to use it for creating
+      the CallContext.
+      
 2010-01-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java:
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCaseBase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCaseBase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -9,6 +9,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 
+import javax.smartcardio.ATR;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -113,11 +114,11 @@
     /**
      * @return
      */
-    protected CallContext createCallContext() {
+    protected CallContext createCallContext(ArtifactFactory artifactFactory) {
         CallMeta callMeta = new DefaultCallMeta(
                 new PreferredLocale[] { new DefaultPreferredLocale("de_DE",
                         1.0f) });
-        CallContext cc = new TestCallContext(bootstrap.getContext(), callMeta);
+        CallContext cc = new TestCallContext(bootstrap.getContext(), callMeta,artifactFactory);
         return cc;
     }
 
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointHorizontalProfileTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointHorizontalProfileTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -53,7 +53,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_describe.xml");
             
             int steps = 9;
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointVerticalProfileTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/InstantaneousPointVerticalProfileTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -52,7 +52,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_describe.xml");
             
            int steps = 5;
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalCrossSectionTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalCrossSectionTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -52,7 +52,7 @@
             assertNotNull(artifact);
             log.debug("HorizontalCrossSectionMesh-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/horizontalcrosssection_mesh/horizontalcrosssection_describe.xml");
             int steps = 7;
             
@@ -70,30 +70,21 @@
             Document outputData = artifact.describe(describeDocument,cc);
             FileOutputStream fos = null;
             FileOutputStream fos2 = null;
-            FileOutputStream fos3 = null;
             try {
                 fos = new FileOutputStream(
                         "src/test/results/horizontalcrosssection_mesh"
-                                + System.currentTimeMillis() + ".png");
-                
+                                + System.currentTimeMillis() + ".zip");
                 fos2 = new FileOutputStream(
                         "src/test/results/horizontalcrosssection_mesh"
-                                + System.currentTimeMillis() + ".csv");
-                fos3 = new FileOutputStream(
-                        "src/test/results/horizontalcrosssection_mesh"
-                                + System.currentTimeMillis() + ".odv");
+                                + System.currentTimeMillis() + ".txt");
                 artifact.out(this.readDocument("src/test/ressources/" +
                                                "horizontalcrosssection_mesh/" +
-                                               "horizontalcrosssection_step_07_out_chart.xml"),
+                                               "horizontalcrosssection_step_07_out_zip.xml"),
                               fos, cc);
                 artifact.out(this.readDocument("src/test/ressources/" +
                                                "horizontalcrosssection_mesh/" +
-                                               "horizontalcrosssection_step_07_out_csv.xml"),
+                                               "horizontalcrosssection_step_07_out_wms.xml"),
                              fos2,cc);
-                artifact.out(this.readDocument("src/test/ressources/" +
-                                               "horizontalcrosssection_mesh/" +
-                                               "horizontalcrosssection_step_07_out_odv.xml"),
-                              fos3,cc);
             } catch (Exception e) {
                 log.error(e, e);
                 fail();
@@ -103,8 +94,6 @@
                     fos.close();
                     fos2.flush();
                     fos2.close();
-                    fos3.flush();
-                    fos3.close();
                 } catch (Exception e) {
                     log.error(e, e);
                 }
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalProfileTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshHorizontalProfileTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -52,7 +52,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_describe.xml");
             
             int steps = 10;
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshTimeSeriesTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshTimeSeriesTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -51,7 +51,7 @@
             assertNotNull(artifact);
             log.debug("TimeSeriesMesh-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
 
             Document describeDocument = this.readDocument("src/test/ressources/timeseries_mesh/timeseries_describe.xml");
             
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalCrossSectionTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalCrossSectionTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -52,7 +52,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/verticalcrosssection_mesh/verticalcrosssection_describe.xml");
             
             int steps = 6;
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalProfileTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshVerticalProfileTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -51,7 +51,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
             Document describeDocument = this.readDocument("src/test/ressources/" +
                                                           "verticalprofile_mesh/" +
                                                           "verticalprofile_describe.xml");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestArtifactDatabase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifacts;
+
+import org.w3c.dom.Document;
+
+import de.intevation.artifacts.ArtifactDatabase;
+import de.intevation.artifacts.ArtifactDatabaseException;
+import de.intevation.artifacts.ArtifactFactory;
+import de.intevation.artifacts.CallMeta;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class TestArtifactDatabase implements ArtifactDatabase {
+
+    private ArtifactFactory artifactFactory = null;
+    /**
+     * Constructor
+     */
+    public TestArtifactDatabase(ArtifactFactory artifactFactory) {
+        this.artifactFactory = artifactFactory;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#advance(java.lang.String, org.w3c.dom.Document, de.intevation.artifacts.CallMeta)
+     */
+    public Document advance(String artifact, Document target, CallMeta callMeta)
+                                                                                throws ArtifactDatabaseException {
+
+        return null;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#artifactFactoryNamesAndDescriptions()
+     */
+    public String[][] artifactFactoryNamesAndDescriptions() {
+
+        return null;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#createArtifactWithFactory(java.lang.String, de.intevation.artifacts.CallMeta)
+     */
+    public Document createArtifactWithFactory(String factory, CallMeta callMeta)
+                                                                                throws ArtifactDatabaseException {
+
+        return null;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#describe(java.lang.String, org.w3c.dom.Document, de.intevation.artifacts.CallMeta)
+     */
+    public Document describe(String artifact, Document data, CallMeta callMeta)
+                                                                               throws ArtifactDatabaseException {
+
+        return null;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#feed(java.lang.String, org.w3c.dom.Document, de.intevation.artifacts.CallMeta)
+     */
+    public Document feed(String artifact, Document data, CallMeta callMeta)
+                                                                           throws ArtifactDatabaseException {
+
+        return null;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#getInternalArtifactFactory(java.lang.String)
+     */
+    public ArtifactFactory getInternalArtifactFactory(String factoryName) {
+        return this.artifactFactory;
+    }
+
+    /**
+     * @see de.intevation.artifacts.ArtifactDatabase#out(java.lang.String, org.w3c.dom.Document, de.intevation.artifacts.CallMeta)
+     */
+    public DeferredOutput out(String artifact, Document format,
+                              CallMeta callMeta)
+                                                throws ArtifactDatabaseException {
+
+        return null;
+    }
+
+}
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestCallContext.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestCallContext.java	Mon Jan 18 11:26:51 2010 +0000
@@ -3,6 +3,8 @@
  */
 package de.intevation.gnv.artifacts;
 
+import de.intevation.artifacts.ArtifactDatabase;
+import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 
@@ -12,15 +14,21 @@
  */
 public class TestCallContext implements CallContext {
 
+
+
     private Object globalContext = null;
     private CallMeta callMeta = null;
-
+    private ArtifactFactory artifactFactory = null;
+    private ArtifactDatabase artifactDatabase = null;
     /**
      * Constructor
      */
-    public TestCallContext(Object globalContext, CallMeta callMeta) {
+    public TestCallContext(Object globalContext, 
+                           CallMeta callMeta, 
+                           ArtifactFactory artifactFactory) {
         this.globalContext = globalContext;
         this.callMeta = callMeta;
+        this.artifactDatabase  = new TestArtifactDatabase(artifactFactory);
     }
 
     /**
@@ -47,13 +55,14 @@
     }
 
     public Object getContextValue(Object key) {
-        
-        		return null;
+        return null;
     }
 
     public Object putContextValue(Object key, Object value) {
-        
-        		return null;
+        return null;
     }
 
+    public ArtifactDatabase getDatabase() {
+        return this.artifactDatabase;
+    }
 }
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointTimeSeriesTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointTimeSeriesTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -55,7 +55,7 @@
             assertNotNull(artifact);
             log.debug("TimeSeries-Artifact is available");
     
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
     
             // Erster Schritt
     
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointVerticalProfileTestCase.java	Mon Jan 18 11:25:52 2010 +0000
+++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TimeSeriesPointVerticalProfileTestCase.java	Mon Jan 18 11:26:51 2010 +0000
@@ -52,7 +52,7 @@
             assertNotNull(artifact);
             log.debug("VerticalProfile-Artifact is available");
 
-            CallContext cc = createCallContext();
+            CallContext cc = createCallContext(artifactFactory);
 
             Document describeDocument = this.readDocument("src/test/ressources/verticalprofile/verticalprofile_describe.xml");
             int steps = 7;

http://dive4elements.wald.intevation.org