FileUtilTest.java 1.6 KB
Newer Older
Kim Gyeongeun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
package jp.agentec.sinaburocast.common.io;

import java.io.IOException;

import junit.framework.TestCase;
import junit.framework.TestSuite;

public class FileUtilTest extends TestCase {

	public FileUtilTest(String string) {
		super(string);
	}

	public static TestSuite suite() {
		TestSuite suite = new TestSuite("FileUtilTest");

//		suite.addTest(new FileUtilTest("testMove"));
		suite.addTest(new FileUtilTest("testDeleteDirectory"));
		return suite;
	}


	/**
	 * @throws java.lang.Exception
	 */
	@Override
	public void setUp() throws Exception {
//        include("app.dicon");
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Override
	public void tearDown() throws Exception {
	}

	public void testMove() throws IOException {
		assertTrue(FileUtil.move("/usr/local/tomcat/logs/velocity.log", "/usr/hoge/boke/aaa.log"));
	}

	public void testDeleteDirectory() throws IOException {

		FileUtil.createFile("/mnt/nas1/wmvdl/0000/001/001/0000_0000001001_0000000006_ORG.flvv", "aaa");
		if(true)return;
		FileUtil.createFile("/mnt/nas1/S0001/C0000/ORG/0000/001/001/0000_0000001001_0000000006_ORG.wmv", "aaa");

		String dir = "/tmp/hoge/";
		String file = "/tmp/hoge/test.txt";
		assertTrue(FileUtil.mkdir(dir));
		FileUtil.createFile(file, "aaa");
		assertTrue(FileUtil.exists(file));
		FileUtil.deleteDirectory(dir, false);
		assertTrue(FileUtil.exists(dir));
		assertTrue(FileUtil.delete(file));
		FileUtil.deleteDirectory(dir, false);
		assertFalse(FileUtil.exists(dir));

		assertTrue(FileUtil.mkdir(dir));
		FileUtil.createFile(file, "aaa");
		FileUtil.deleteDirectory(dir, true);
		assertFalse(FileUtil.exists(dir));

	}


}