diff --git a/.classpath b/.classpath index 18ed19663..2ed9bb6ee 100644 --- a/.classpath +++ b/.classpath @@ -1,15 +1,19 @@ - + + - - - - + + + + + + + diff --git a/build-common.xml b/build-common.xml index dd1a59c5a..6d9487f8e 100644 --- a/build-common.xml +++ b/build-common.xml @@ -1,8 +1,10 @@ - - + + + + @@ -11,18 +13,22 @@ + + + - + - - + - + + diff --git a/build.xml b/build.xml index e1daec61b..e20d86a82 100644 --- a/build.xml +++ b/build.xml @@ -1,3 +1,3 @@ - + diff --git a/dependencies.xml b/dependencies.xml index f6b2af378..1755a17fe 100644 --- a/dependencies.xml +++ b/dependencies.xml @@ -1,25 +1,23 @@ - - + - - - + + + + - - + depends='depend-clean.components, depend-clean.ui'/> @@ -29,6 +27,11 @@ + + + - diff --git a/lib/test/hamcrest-core-1.1.jar b/lib/test/hamcrest-core-1.1.jar new file mode 100644 index 000000000..5f1d5ce0c Binary files /dev/null and b/lib/test/hamcrest-core-1.1.jar differ diff --git a/lib/test/hamcrest-library-1.1.jar b/lib/test/hamcrest-library-1.1.jar new file mode 100644 index 000000000..40610c9b4 Binary files /dev/null and b/lib/test/hamcrest-library-1.1.jar differ diff --git a/lib/test/jmock-2.5.1.jar b/lib/test/jmock-2.5.1.jar new file mode 100644 index 000000000..4415dfbc9 Binary files /dev/null and b/lib/test/jmock-2.5.1.jar differ diff --git a/lib/test/junit-4.9b2.jar b/lib/test/junit-4.9b2.jar new file mode 100644 index 000000000..aec30a07f Binary files /dev/null and b/lib/test/junit-4.9b2.jar differ diff --git a/test/build.xml b/test/build.xml new file mode 100644 index 000000000..5869dbdfc --- /dev/null +++ b/test/build.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/test/net/sf/briar/util/FileUtilsTest.java b/test/net/sf/briar/util/FileUtilsTest.java new file mode 100644 index 000000000..c30ac0a65 --- /dev/null +++ b/test/net/sf/briar/util/FileUtilsTest.java @@ -0,0 +1,59 @@ +package net.sf.briar.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.Scanner; + +import junit.framework.TestCase; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class FileUtilsTest extends TestCase { + + private final File testDir = new File("test.tmp"); + + @Before + public void setUp() { + testDir.mkdirs(); + } + + @Test + public void testCopy() throws IOException { + File src = new File(testDir, "src"); + File dest = new File(testDir, "dest"); + + PrintStream out = new PrintStream(new FileOutputStream(src)); + out.print("Foo bar\r\nBar foo\r\n"); + out.flush(); + out.close(); + long length = src.length(); + + FileUtils.copy(src, dest); + + assertEquals(length, dest.length()); + Scanner in = new Scanner(dest); + assertTrue(in.hasNextLine()); + assertEquals("Foo bar", in.nextLine()); + assertTrue(in.hasNextLine()); + assertEquals("Bar foo", in.nextLine()); + assertFalse(in.hasNext()); + in.close(); + + src.delete(); + dest.delete(); + } + + @After + public void tearDown() throws IOException { + delete(testDir); + } + + private static void delete(File f) throws IOException { + if(f.isDirectory()) for(File child : f.listFiles()) delete(child); + f.delete(); + } +}