01: /*
02: * ZipOutputFactoryTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.util;
13:
14: import java.io.File;
15: import java.io.PrintWriter;
16: import workbench.TestUtil;
17: import workbench.TestUtil;
18: import workbench.util.ZipOutputFactory;
19:
20: /**
21: *
22: * @author support@sql-workbench.net
23: */
24: public class ZipOutputFactoryTest extends junit.framework.TestCase {
25:
26: public ZipOutputFactoryTest(String testName) {
27: super (testName);
28: }
29:
30: public void testOuputFactory() {
31: try {
32: TestUtil util = new TestUtil("outputFactoryTest");
33: File importFile = new File(util.getBaseDir(),
34: "datafile.txt");
35:
36: File archive = new File(util.getBaseDir(), "archive.zip");
37: ZipOutputFactory zout = new ZipOutputFactory(archive);
38: PrintWriter out = new PrintWriter(zout.createWriter(
39: importFile, "UTF-8"));
40:
41: out.println("nr\tfirstname\tlastname");
42: out.print(Integer.toString(1));
43: out.print('\t');
44: out.println("First\t\"Last");
45: out.println("name\"");
46: out.close();
47:
48: zout.done();
49:
50: if (!archive.delete()) {
51: fail("Could not delete archive");
52: }
53: } catch (Exception e) {
54: e.printStackTrace();
55: fail(e.getMessage());
56: }
57: }
58: }
|