annotate gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/util/ShapeFileWriterTestCase.java @ 1060:cc4ec127d666

Remove the elements of an outdated state from cache if its endOfLife method is called. gnv-artifacts/trunk@1143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 01 Jun 2010 16:54:21 +0000
parents c4156275c1e1
children f953c9a559d8
rev   line source
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.artifacts.util;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
3 import com.vividsolutions.jts.geom.MultiLineString;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
4
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
5 import com.vividsolutions.jts.io.WKTReader;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
6
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
7 import de.intevation.gnv.utils.Pair;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
8 import de.intevation.gnv.utils.ShapeFileWriter;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
9
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import java.io.File;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import java.io.FileReader;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
12
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import java.util.ArrayList;
509
e17621ccf06c Fixed Compiler-Error in JUnit-Test for ShapefileExport after changes in the Method-Signature.
Tim Englich <tim.englich@intevation.de>
parents: 474
diff changeset
14 import java.util.Date;
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import junit.framework.TestCase;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.BasicConfigurator;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 /**
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
22 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 *
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 */
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 public class ShapeFileWriterTestCase extends TestCase {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 /**
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 * the logger, used to log exceptions and additonaly information
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 */
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 private static Logger log = null;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 static {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 BasicConfigurator.configure();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 log = Logger.getLogger(ShapeFileWriterTestCase.class);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
36
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 /**
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 * Constructor
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * @param name
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 */
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 public ShapeFileWriterTestCase(String name) {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 super(name);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
44
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
45
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 public void testMultiLineStringWriter(){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
47
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 try {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 String wkt = "MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))";
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 String wkt1 = "MULTILINESTRING ((10 5, 20 20),(15 15, 30 15))";
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 String wkt2 = "MULTILINESTRING ((10 10, 8 20),(15 15, 30 15))";
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 String wkt3 = "MULTILINESTRING ((8 10, 20 20),(15 15, 30 15))";
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 File isolineFile = new File("src/test/ressources/isolines.wkt");
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 MultiLineString multiLineString = (MultiLineString)new WKTReader().read(new FileReader(isolineFile));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 MultiLineString multiLineString1 = (MultiLineString)new WKTReader().read(wkt1);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 MultiLineString multiLineString2 = (MultiLineString)new WKTReader().read(wkt2);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 MultiLineString multiLineString3 = (MultiLineString)new WKTReader().read(wkt3);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 ArrayList<Pair<Object, MultiLineString>> multiLineStrings =
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 new ArrayList<Pair<Object, MultiLineString>>();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 1.2,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 multiLineString));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 1.3,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 multiLineString1));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 1.4,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 multiLineString2));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 1.5,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 multiLineString3));
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
76
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
77 java.io.File shapeFile = new java.io.File("/tmp/test"+System.currentTimeMillis()+".shp");
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
78
509
e17621ccf06c Fixed Compiler-Error in JUnit-Test for ShapefileExport after changes in the Method-Signature.
Tim Englich <tim.englich@intevation.de>
parents: 474
diff changeset
79 ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, 1, 1, new Date(), multiLineStrings);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 509
diff changeset
80
468
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 } catch (Exception e) {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 log.error(e,e);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 fail();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 }
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 }
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 }

http://dive4elements.wald.intevation.org