1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/tests/test/org/dbforms/xmldb/TestFileSplitter.java,v 1.8 2004/08/18 12:26:12 hkollmann Exp $
3    * $Revision: 1.8 $
4    * $Date: 2004/08/18 12:26:12 $
5    *
6    * DbForms - a Rapid Application Development Framework
7    * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8    *
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2.1 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
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  }