changeset 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 d117fd4b82e5
children 0035862b0295
files gnv-artifacts/Changelog gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java gnv-artifacts/src/test/ressources/GNVArtifactsTestCase_Configuration.xml gnv-artifacts/src/test/ressources/conf.xml gnv-artifacts/src/test/ressources/queries.properties gnv-artifacts/src/test/ressources/timeseries/timeseries_step_03_feed.xml gnv-artifacts/src/test/ressources/timeseries/timeseries_step_04_feed.xml gnv-artifacts/src/test/ressources/timeseries/timeseries_step_05_feed.xml gnv-artifacts/src/test/ressources/timeseries/timeseries_step_05_out.xml
diffstat 9 files changed, 156 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/Changelog	Wed Sep 09 15:28:18 2009 +0000
+++ b/gnv-artifacts/Changelog	Thu Sep 10 07:57:30 2009 +0000
@@ -1,3 +1,24 @@
+2009-09-10  Tim Englich  <tim.englich@intevation.de>
+
+    * src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Edited:
+      src/test/ressources/conf.xml Renamed: 
+      Project Structure changed in artifact-database. So we have to rename
+      the Testconfigurationfile in conf.xml. 
+   
+    * src/test/ressources/results Added:
+      Integrated Folder for temporal storing Resultfiles of the TestCases
+       
+    * src/test/ressources/queries.properties Edited:
+      Further Queries for Testcases integrated
+    * src/test/ressources/timeseries/timeseries_step_05_out.xml Added,  
+      src/test/ressources/timeseries/timeseries_step_05_feed.xml Added:
+      Integrated the last step of the TimeSeries-Workflow.
+      Now the TestCase is able to render Charts.
+       
+    * src/test/ressources/timeseries/timeseries_step_04_feed.xml Edited, 
+      src/test/ressources/timeseries/timeseries_step_03_feed.xml Edited:
+      Names of the feed-Parametes changed to the Syntax of BSH-Spelling
+      
 2009-09-09  Tim Englich  <tim.englich@intevation.de>
 
     * src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java: 
--- 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
--- a/gnv-artifacts/src/test/ressources/GNVArtifactsTestCase_Configuration.xml	Wed Sep 09 15:28:18 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<artifact-database>
-    <factories>
-        <context-factory>de.intevation.gnv.artifacts.context.GNVArtifactContextFactory</context-factory>
-        <artifact-factories>
-            <artifact-factory
-             name="timeSeries" description="Artiefactfactory for instantiating TimeSeriesArtifacts"  ttl="60000"
-             artifact="de.intevation.gnv.timeseries.TimeSeriesArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
-        </artifact-factories>
-    </factories>
-    <artifacts>
-        <artifact name="timeSeries">
-            <transitions>
-                
-                <transition id="timeseries_timeseriespoint" description="timeseries_timeseriespoint" transition="de.intevation.gnv.transition.DefaultTransition">
-                    <queryID>timeseries_timeseriespoint</queryID>
-                    <reachableTransitions>
-                        <transition>timeseries_parameter</transition>
-                    </reachableTransitions>
-                    <inputvalues>
-                        <inputvalue name="sourceid" type="Integer"/>
-                    </inputvalues>
-                </transition>
-                
-                <transition id="timeseries_parameter" description="timeseries_parameter" transition="de.intevation.gnv.transition.DefaultTransition">
-                    <queryID>timeseries_parameter</queryID>
-                    <reachableTransitions>
-                        <transition>timeseries_depth_height</transition>
-                    </reachableTransitions>
-                    <inputvalues>
-                        <inputvalue name="featureid" type="Integer"/>
-                    </inputvalues>
-                </transition>
-                
-                 <transition id="timeseries_depth_height" description="timeseries_depth_height" transition="de.intevation.gnv.transition.DefaultTransition">
-                    <queryID>timeseries_depth_height</queryID>
-                    <reachableTransitions>
-                         <transition>timeseries_interval</transition>
-                    </reachableTransitions>
-                    <inputvalues>
-                        <inputvalue name="featureid" type="Integer"/>
-                        <inputvalue name="messurement_parameter" type="Integer"/>
-                    </inputvalues>
-                </transition>
-                
-                <transition id="timeseries_interval" description="timeseries_interval" transition="de.intevation.gnv.transition.MinMaxTransition">
-                    <queryID>timeseries_interval</queryID>
-                    <reachableTransitions>
-                        <transition>timeseries_calculate_results</transition>
-                    </reachableTransitions>
-                    <inputvalues>
-                        <inputvalue name="messurement_parameter" type="Integer"/>
-                        <inputvalue name="depthid" type="Integer"/>
-                    </inputvalues>
-                </transition>
-                
-                <transition id="timeseries_calculate_results" description="timeseries_interval" transition="de.intevation.gnv.transition.MinMaxTransition">
-                    <queryID>timeseries_calculate_resulst</queryID>
-                    <reachableTransitions>
-                    </reachableTransitions>
-                    <inputvalues>
-                        <inputvalue name="minvalue" type="Integer"/>
-                        <inputvalue name="maxvalue" type="Integer"/>
-                    </inputvalues>
-                </transition>
-                
-            </transitions>
-        </artifact>
-    </artifacts>
-    <geo-backend>
-        <backend-configuration>../geo-backend/src/test/ressources/ArcSDEConnectionPoolTestCase.properties</backend-configuration>
-        <query-configuration>src/test/ressources/queries.properties</query-configuration>
-    </geo-backend>
-    <database>
-        <user></user>
-        <password></password>
-        <!-- <url>jdbc:h2:artifacts.db</url> -->
-        <!-- <driver>org.h2.Driver</driver> -->
-        <!-- <sql></sql> -->
-    </database>
-</artifact-database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/test/ressources/conf.xml	Thu Sep 10 07:57:30 2009 +0000
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<artifact-database>
+    <factories>
+        <context-factory>de.intevation.gnv.artifacts.context.GNVArtifactContextFactory</context-factory>
+        <artifact-factories>
+            <artifact-factory
+             name="timeSeries" description="Artiefactfactory for instantiating TimeSeriesArtifacts"  ttl="60000"
+             artifact="de.intevation.gnv.timeseries.TimeSeriesArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+        </artifact-factories>
+    </factories>
+    <artifacts>
+        <artifact name="timeSeries">
+            <transitions>
+                
+                <transition id="timeseries_timeseriespoint" description="timeseries_timeseriespoint" transition="de.intevation.gnv.transition.DefaultTransition">
+                    <queryID>timeseries_timeseriespoint</queryID>
+                    <reachableTransitions>
+                        <transition>timeseries_parameter</transition>
+                    </reachableTransitions>
+                    <inputvalues>
+                        <inputvalue name="sourceid" type="Integer"/>
+                    </inputvalues>
+                </transition>
+                
+                <transition id="timeseries_parameter" description="timeseries_parameter" transition="de.intevation.gnv.transition.DefaultTransition">
+                    <queryID>timeseries_parameter</queryID>
+                    <reachableTransitions>
+                        <transition>timeseries_depth_height</transition>
+                    </reachableTransitions>
+                    <inputvalues>
+                        <inputvalue name="featureid" type="Integer"/>
+                    </inputvalues>
+                </transition>
+                
+                 <transition id="timeseries_depth_height" description="timeseries_depth_height" transition="de.intevation.gnv.transition.DefaultTransition">
+                    <queryID>timeseries_depth_height</queryID>
+                    <reachableTransitions>
+                         <transition>timeseries_interval</transition>
+                    </reachableTransitions>
+                    <inputvalues>
+                        <inputvalue name="featureid" type="Integer"/>
+                        <inputvalue name="parameterid" type="Integer"/>
+                    </inputvalues>
+                </transition>
+                
+                <transition id="timeseries_interval" description="timeseries_interval" transition="de.intevation.gnv.transition.MinMaxTransition">
+                    <queryID>timeseries_interval</queryID>
+                    <reachableTransitions>
+                        <transition>timeseries_calculate_results</transition>
+                    </reachableTransitions>
+                    <inputvalues>
+                        <inputvalue name="parameterid" type="Integer"/>
+                        <inputvalue name="measurementid" type="Integer"/>
+                    </inputvalues>
+                </transition>
+                
+                <transition id="timeseries_calculate_results" description="timeseries_interval" transition="de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition">
+                    <queryID>timeseries_chart_data</queryID>
+                    <inputvalues>
+                        <inputvalue name="parameterid" type="Integer"/>
+                        <inputvalue name="measurementid" type="Integer"/>
+                        <inputvalue name="minvalue" type="Integer"/>
+                        <inputvalue name="maxvalue" type="Integer"/>
+                    </inputvalues>
+                    <outputsModes>
+                        <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/>
+                        <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/>
+                        <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/>
+                    </outputsModes>
+                </transition>
+                
+            </transitions>
+        </artifact>
+    </artifacts>
+    <geo-backend>
+        <backend-configuration>../geo-backend/src/test/ressources/ArcSDEConnectionPoolTestCase.properties</backend-configuration>
+        <query-configuration>src/test/ressources/queries.properties</query-configuration>
+    </geo-backend>
+    <database>
+        <user></user>
+        <password></password>
+        <!-- <url>jdbc:h2:artifacts.db</url> -->
+        <!-- <driver>org.h2.Driver</driver> -->
+        <!-- <sql></sql> -->
+    </database>
+</artifact-database>
--- a/gnv-artifacts/src/test/ressources/queries.properties	Wed Sep 09 15:28:18 2009 +0000
+++ b/gnv-artifacts/src/test/ressources/queries.properties	Thu Sep 10 07:57:30 2009 +0000
@@ -1,4 +1,5 @@
 timeseries_timeseriespoint=SELECT DISTINCT tsp.FEATUREID KEY, tsp.NAME VALUE FROM MEDIAN.TIMESERIESPOINT tsp, MEDIAN.MEASUREMENT mmt WHERE tsp.FEATUREID =  mmt.FEATUREID AND mmt.SOURCEID = ? order by tsp.name
 timeseries_parameter=SELECT DISTINCT p.PARAMETERID KEY, p.GERMANNAME VALUE from MEDIAN.PARAMETER p where p.PARAMETERID in (select distinct ts.PARAMETERID from MEDIAN.TIMESERIES ts where ts.TIMESERIESID in (select distinct tsv.TIMESERIESID from MEDIAN.TIMESERIESVALUE tsv where tsv.MEASUREMENTID in (select m.MEASUREMENTID from MEDIAN.MEASUREMENT m, MEDIAN.TIMESERIESPOINT tsp where m.FEATUREID = tsp.FEATUREID and tsp.FEATUREID IN ( ? )))) ORDER BY p.GERMANNAME
 timeseries_depth_height=SELECT DISTINCT m.MEASUREMENTID KEY, m.ZLOCATION VALUE from MEDIAN.MEASUREMENT m where m.MEASUREMENTID in (SELECT DISTINCT  t_v.MEASUREMENTID from MEDIAN.TIMESERIESVALUE t_v where t_v.TIMESERIESID in (SELECT DISTINCT  t.TIMESERIESID from MEDIAN.TIMESERIES t where t.PARAMETERID in (SELECT DISTINCT  p.PARAMETERID from MEDIAN.PARAMETER p where m.FEATUREID IN ( ? ) and p.PARAMETERID IN (?))))ORDER BY m.ZLOCATION DESC
-timeseries_interval=select min(tv.TIMEVALUE) MIN, max(tv.TIMEVALUE) MAX from MEDIAN.TIMESERIES t , MEDIAN.TIMESERIESVALUE tv where tv.TIMESERIESID = t.TIMESERIESID AND t.PARAMETERID IN ( ? ) AND tv.MEASUREMENTID IN ( ? )
\ No newline at end of file
+timeseries_interval=select min(tv.TIMEVALUE) MIN, max(tv.TIMEVALUE) MAX from MEDIAN.TIMESERIES t , MEDIAN.TIMESERIESVALUE tv where tv.TIMESERIESID = t.TIMESERIESID AND t.PARAMETERID IN ( ? ) AND tv.MEASUREMENTID IN ( ? )
+timeseries_chart_data=SELECT tv.TIMEVALUE, tv.DATAVALUE, t.PARAMETERID, tv.MEASUREMENTID, tv.TIMESERIESID FROM MEDIAN.TIMESERIESVALUE tv, MEDIAN.TIMESERIES t WHERE tv.TIMESERIESID = t.TIMESERIESID AND t.PARAMETERID IN ( ? ) AND tv.MEASUREMENTID IN ( ? ) AND tv.TIMEVALUE > TO_DATE ('?', 'YYYY.MM.DD HH24:MI:SS') AND tv.TIMEVALUE < TO_DATE ('?', 'YYYY.MM.DD HH24:MI:SS') ORDER BY tv.MEASUREMENTID ,tv.TIMESERIESID ,t.PARAMETERID ,tv.TIMEVALUE
--- a/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_03_feed.xml	Wed Sep 09 15:28:18 2009 +0000
+++ b/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_03_feed.xml	Thu Sep 10 07:57:30 2009 +0000
@@ -5,6 +5,6 @@
      <art:uuid value="dd87ce50-9bbe-11de-8a39-0800200c9a66"/>
      <art:hash value="8392d409b5518044465ac8e9b7daf5ef"/>
      <art:data>
-        <art:input name="messurement_parameter" value="54"/>
+        <art:input name="parameterid" value="54"/>
      </art:data>
 </art:action>
\ No newline at end of file
--- a/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_04_feed.xml	Wed Sep 09 15:28:18 2009 +0000
+++ b/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_04_feed.xml	Thu Sep 10 07:57:30 2009 +0000
@@ -5,6 +5,6 @@
      <art:uuid value="dd87ce50-9bbe-11de-8a39-0800200c9a66"/>
      <art:hash value="8392d409b5518044465ac8e9b7daf5ef"/>
      <art:data>
-        <art:input name="depthid" value="500042"/>
+        <art:input name="measurementid" value="500042"/>
      </art:data>
 </art:action>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_05_feed.xml	Thu Sep 10 07:57:30 2009 +0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<art:action
+     xmlns:art="http://www.intevation.de/2009/artifacts">
+     <art:type name="feed"/>
+     <art:uuid value="dd87ce50-9bbe-11de-8a39-0800200c9a66"/>
+     <art:hash value="8392d409b5518044465ac8e9b7daf5ef"/>
+     <art:data>
+        <art:input name="minvalue" value="2001.03.16 16:29:00"/>
+        <art:input name="maxvalue" value="2008.12.31 23:29:00"/>
+     </art:data>
+</art:action>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/test/ressources/timeseries/timeseries_step_05_out.xml	Thu Sep 10 07:57:30 2009 +0000
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<art:action xmlns:art="http://www.intevation.de/2009/artifacts">
+     <art:type name="out"/>
+     <art:uuid value="dd87ce50-9bbe-11de-8a39-0800200c9a66"/>
+     <art:hash value="8392d409b5518044465ac8e9b7daf5ef"/>
+     <art:out name="chart">
+        <art:params>
+            <!-- out params copied from describe -->
+        </art:params>
+     </art:out>
+</art:action>
+

http://dive4elements.wald.intevation.org