1   /*
2       StatCvs - CVS statistics generation 
3       Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4       http://statcvs.sf.net/
5       
6       This library is free software; you can redistribute it and/or
7       modify it under the terms of the GNU Lesser General Public
8       License as published by the Free Software Foundation; either
9       version 2.1 of the License, or (at your option) any later version.
10  
11      This library is distributed in the hope that it will be useful,
12      but WITHOUT ANY WARRANTY; without even the implied warranty of
13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14      Lesser General Public License for more details.
15  
16      You should have received a copy of the GNU Lesser General Public
17      License along with this library; if not, write to the Free Software
18      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19      
20  	$Name:  $ 
21  	Created on $Date: 2008/04/02 11:22:15 $ 
22  */
23  package net.sf.statcvs.util;
24  
25  import junit.framework.TestCase;
26  
27  /**
28   * Test cases for {@link net.sf.statcvs.util.FileUtils}
29   *
30   * @author Richard Cyganiak
31   * @version $Id: FileUtilsTest.java,v 1.3 2008/04/02 11:22:15 benoitx Exp $
32   */
33  public class FileUtilsTest extends TestCase {
34  
35      /**
36       * Constructor for OutputUtilsTest.
37       * @param arg0 input 
38       */
39      public FileUtilsTest(final String arg0) {
40          super(arg0);
41      }
42  
43      /**
44       * Tests {@link FileUtils#getDirectoryName}
45       */
46      public void testGetDirectoryName() {
47          assertEquals("statcvs", FileUtils.getDirectoryName("net/sf/statcvs/"));
48          assertEquals("sf", FileUtils.getDirectoryName("net/sf/"));
49          assertEquals("net", FileUtils.getDirectoryName("net/"));
50          try {
51              FileUtils.getDirectoryName("");
52              fail("can't get directory name for root");
53          } catch (final IllegalArgumentException expected) {
54              // expected
55          }
56      }
57  
58      /**
59       * Tests {@link FileUtils#getDirectoryName}
60       */
61      public void testGetParentDirectoryPath() {
62          assertEquals("net/sf/", FileUtils.getParentDirectoryPath("net/sf/statcvs/"));
63          assertEquals("net/", FileUtils.getParentDirectoryPath("net/sf/"));
64          assertEquals("", FileUtils.getParentDirectoryPath("net/"));
65          try {
66              FileUtils.getParentDirectoryPath("");
67              fail("can't get parent directory for root");
68          } catch (final IllegalArgumentException expected) {
69              // expected
70          }
71      }
72  }