1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.xmldb;
25
26 import junit.framework.*;
27
28 import org.dbforms.util.Util;
29
30 import java.io.*;
31
32
33
34 /***
35 * Description of the Class
36 *
37 * @author epugh
38 * @created May 3, 2002
39 */
40 public class TestFileSplitter extends TestCase {
41 /***
42 * DOCUMENT ME!
43 *
44 * @throws Exception DOCUMENT ME!
45 */
46 public void testConstructorWithStrings() throws Exception {
47 String srcFile = TestFileSplitter.class.getResource("fileA.txt")
48 .getPath();
49 assertTrue(!Util.isNull(srcFile));
50 }
51
52
53 /***
54 * DOCUMENT ME!
55 *
56 * @throws Exception DOCUMENT ME!
57 */
58 public void testSplitFile() throws Exception {
59 File srcFile = new File(FileSplitter.class.getResource("fileA.txt").getPath());
60 File destDir = srcFile.getParentFile();
61
62 assertTrue("File Must Exist:" + srcFile, srcFile.exists());
63 assertTrue("File Must be readable:" + srcFile, srcFile.canRead());
64 assertTrue("Dir must Exist and write",
65 destDir.exists() && destDir.canWrite());
66
67 FileSplitter fp = new FileSplitter(srcFile, destDir);
68 fp.splitFile();
69
70 File fileSplitterResultA = new File(destDir, "FileSplitterResultA.txt");
71 assertTrue("File Must Exist:" + fileSplitterResultA,
72 fileSplitterResultA.exists());
73
74 File fileSplitterResultB = new File(destDir, "FileSplitterResultB.txt");
75 assertTrue("File Must Exist:" + fileSplitterResultB,
76 fileSplitterResultB.exists());
77 }
78 }