1 64 package com.jcorporate.expresso.core.misc.tests; 65 66 import com.jcorporate.expresso.core.misc.FileUtil; 67 import com.jcorporate.expresso.services.test.ExpressoTestCase; 68 import junit.framework.TestSuite; 69 70 79 80 public class FileUtilTests extends ExpressoTestCase { 81 82 83 public FileUtilTests(String name) throws Exception { 84 super(name); 85 } 86 87 88 public static void main(String [] args) 89 throws Exception { 90 91 junit.textui.TestRunner.run(suite()); 93 } 94 95 98 public static junit.framework.Test suite() { 99 return new TestSuite(FileUtilTests.class); 100 } 101 102 106 public void testFileExtensions() { 107 String result = FileUtil.getExtension("abc"); 108 assertTrue("".equals(result)); 109 110 result = FileUtil.getExtension("abc.d"); 111 assertTrue("d".equals(result)); 112 113 result = FileUtil.getExtension("abc.d.efg"); 114 assertTrue("efg".equals(result)); 115 116 } 117 118 121 public void testGetPath() { 122 String test = "/tmp/usr/abcd/abcdefg.jkh"; 123 String result = FileUtil.getPath(test); 124 assertTrue("/tmp/usr/abcd".equals(result)); 125 126 test = "c:\\windows\\test\\krnl386.exe"; 127 result = FileUtil.getPath(test); 128 assertTrue("c:\\windows\\test".equals(result)); 129 130 } 131 132 135 public void testGetBase() { 136 String test = "/tmp/usr/abcd/abcdefg.jkh"; 137 String result = FileUtil.getBase(test); 138 assertTrue("abcdefg".equals(result)); 139 140 test = "c:\\windows\\test\\krnl386.exe"; 141 result = FileUtil.getBase(test); 142 assertTrue("krnl386".equals(result)); 143 144 145 } 146 147 148 } | Popular Tags |