view gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/MeshTimeSeriesTestCase.java @ 557:05fcb3c553fd 0.4

merged geo-backend/0.4
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:50 +0200
parents 4939236c2dc9
children e0d7b8a0bc42
line wrap: on
line source
/**
 *
 */
package de.intevation.gnv.artifacts;

import java.io.FileOutputStream;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;

import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.ArtifactFactory;
import de.intevation.artifacts.CallContext;

/**
 * @author Tim Englich <tim.englich@intevation.de>
 *
 */
public class MeshTimeSeriesTestCase extends GNVArtifactsTestCaseBase {

    private static Logger log = Logger.getLogger(MeshTimeSeriesTestCase.class);
    
    /**
     * Constructor
     */
    public MeshTimeSeriesTestCase() {
    }

    /**
     * Constructor
     * @param name
     */
    public MeshTimeSeriesTestCase(String name) {
        super(name);
    }

    /**
     * @see de.intevation.gnv.artifacts.GNVArtifactsTestCaseBase#testArtifact()
     */
    @Override
    public void testArtifact() {
        try {
            log.debug("GNVArtifactsTestCase.testTimeSeriesMeshArtifact");
            String artefactName = "fis_modeldata";
            ArtifactFactory artifactFactory = this
                    .getArtifactFactory(artefactName);
            assertNotNull(artifactFactory);
            log.debug("TimeSeriesMesh-ArtifactFactory is available");
            Artifact artifact = artifactFactory.createArtifact(
                    "" + System.currentTimeMillis(), bootstrap.getContext());
            assertNotNull(artifact);
            log.debug("TimeSeriesMesh-Artifact is available");

            CallContext cc = createCallContext(artifactFactory);

            Document describeDocument = this.readDocument("src/test/ressources/timeseries_mesh/timeseries_describe.xml");
            
            int steps = 8;
            
            for (int i = 1; i <= steps; i++){
                this.doNextStep(
                            artifact,
                            cc,
                            "src/test/ressources/timeseries_mesh/" +
                            "timeseries_step_0"+i+"_feed.xml",
                            "src/test/ressources/timeseries_mesh/" +
                            "timeseries_step_0"+i+"_advance.xml", 
                            describeDocument);
            }
            // Achter Schritt
            Document outputData = artifact.describe(describeDocument,cc);
            FileOutputStream fos = null;
            FileOutputStream fos2 = null;
            FileOutputStream fos3 = null;
            FileOutputStream fos4 = null;
            try {
                fos = new FileOutputStream("src/test/results/timeseries_mesh"
                                           + System.currentTimeMillis()
                                           + ".png");
                fos2 = new FileOutputStream("src/test/results/timeseries_mesh"
                                            + System.currentTimeMillis()
                                            + ".xml");
                fos3 = new FileOutputStream("src/test/results/timeseries_mesh"
                                            + System.currentTimeMillis()
                                            + ".csv");
                fos4 = new FileOutputStream("src/test/results/timeseries_mesh"
                        + System.currentTimeMillis()
                        + ".odv");
                artifact
                        .out(
                                this
                                        .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_08_out_statistics.xml"),
                                fos2, cc);
                artifact
                        .out(
                                this
                                        .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_08_out_chart.xml"),
                                fos, cc);
                artifact
                        .out(
                                this
                                        .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_08_out_csv.xml"),
                                fos3, cc);
                artifact
                .out(
                        this
                                .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_08_out_odv.xml"),
                        fos4, cc);
            } catch (Exception e) {
                log.error(e, e);
                fail();
            } finally {
                try {
                    fos.flush();
                    fos.close();
                    fos2.flush();
                    fos2.close();
                    fos3.flush();
                    fos3.close();
                } catch (Exception e) {
                    log.error(e, e);
                }
            }
        } catch (Exception e) {
            log.error(e, e);
            fail();
        }
    }

}

http://dive4elements.wald.intevation.org