01: package org.geotools.data.gml;
02:
03: import java.io.File;
04: import java.io.FileOutputStream;
05: import java.io.IOException;
06: import java.io.InputStream;
07: import java.io.OutputStream;
08: import java.net.URL;
09:
10: import org.geotools.TestData;
11:
12: import junit.framework.TestCase;
13:
14: public class AbstractGMLTestCase extends TestCase {
15:
16: protected File gmlFile;
17:
18: protected void setUp() throws Exception {
19: super .setUp();
20: synchronized (this ) {
21: URL resource = getClass().getResource(
22: "test-data/placeholder");
23: String path = resource.getFile();
24: File f = new File(path);
25: gmlFile = new File(f.getParent() + "/Streams.gml");
26: gmlFile.createNewFile();
27: gmlFile.deleteOnExit();
28: copy(TestData.url("xml/gml/Streams.gml"), gmlFile);
29: }
30:
31: }
32:
33: protected void tearDown() throws Exception {
34: synchronized (this ) {
35: gmlFile.delete();
36: }
37: }
38:
39: void copy(URL src, File dst) throws IOException {
40: InputStream in = null;
41: OutputStream out = null;
42:
43: try {
44: in = src.openStream();
45: out = new FileOutputStream(dst);
46:
47: // Transfer bytes from in to out
48: byte[] buf = new byte[1024];
49: int len;
50:
51: while ((len = in.read(buf)) > 0) {
52: out.write(buf, 0, len);
53: }
54: } finally {
55: if (in != null) {
56: in.close();
57: }
58:
59: if (out != null) {
60: out.close();
61: }
62: }
63: }
64:
65: }
|