1 package test.util;
2
3 import java.io.File;
4 import java.net.URL;
5 import java.net.URLDecoder;
6
7 import com.isenshi.util.ResourceUtils;
8
9 import junit.framework.TestCase;
10
11 /***
12 * @author someda
13 */
14 public class ResourceUtilsTest extends TestCase {
15
16 private static final String DATADIR_PATH = "test/util/resource";
17 private static final String FILESEP = System.getProperty("file.separator");
18
19 private static File prefix;
20
21 public void setUp() throws Exception{
22 URL url = Thread.currentThread().getContextClassLoader().getResource(DATADIR_PATH);
23 prefix = new File(url.getFile());
24 }
25
26
27 public void testReadContent() throws Exception{
28
29 String filepath = URLDecoder.decode(prefix.getAbsolutePath(),"JISAutoDetect") + FILESEP + "util.txt";
30 File file = new File(filepath);
31 String content = ResourceUtils.readContent(file);
32 int length = content.getBytes().length;
33 int winlength = content.getBytes("Windows-31J").length;
34 System.out.println("Platform Default Charset content length : " + length);
35 System.out.println("Windows-31J content length : " + winlength);
36 assertEquals(length,42);
37 }
38
39
40 }