mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Added test jars and the first unit test.
This commit is contained in:
14
.classpath
14
.classpath
@@ -1,15 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="ui"/>
|
<classpathentry excluding=".gitignore|build.xml" kind="src" path="api"/>
|
||||||
|
<classpathentry excluding=".gitignore|build.xml" kind="src" path="components"/>
|
||||||
<classpathentry kind="src" path="i18n"/>
|
<classpathentry kind="src" path="i18n"/>
|
||||||
<classpathentry kind="src" path="test"/>
|
|
||||||
<classpathentry kind="src" path="api"/>
|
|
||||||
<classpathentry kind="src" path="components"/>
|
|
||||||
<classpathentry kind="src" path="util"/>
|
|
||||||
<classpathentry kind="src" path="installer"/>
|
<classpathentry kind="src" path="installer"/>
|
||||||
|
<classpathentry kind="src" path="test"/>
|
||||||
|
<classpathentry excluding=".gitignore|build.xml" kind="src" path="ui"/>
|
||||||
|
<classpathentry excluding=".gitignore|build.xml" kind="src" path="util"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||||
<classpathentry kind="lib" path="lib/h2small-1.3.154.jar"/>
|
<classpathentry kind="lib" path="lib/h2small-1.3.154.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/guice-3.0-no_aop.jar"/>
|
<classpathentry kind="lib" path="lib/guice-3.0-no_aop.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/javax.inject-1.jar"/>
|
<classpathentry kind="lib" path="lib/javax.inject-1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/test/junit-4.9b2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/test/hamcrest-core-1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/test/hamcrest-library-1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/test/jmock-2.5.1.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<project name='build-common' default='compile'>
|
<project name='build-common' default='compile'>
|
||||||
<import file='dependencies.xml'/>
|
<import file='dependencies.xml'/>
|
||||||
<property name='build' location='build'/>
|
|
||||||
<dirname property='build-common.root' file='${ant.file.build-common}'/>
|
<dirname property='build-common.root' file='${ant.file.build-common}'/>
|
||||||
<fileset id='third-party-jars' dir='${build-common.root}/lib'>
|
<fileset id='bundled-jars' dir='${build-common.root}/lib'>
|
||||||
|
<include name='*.jar'/>
|
||||||
|
</fileset>
|
||||||
|
<fileset id='test-jars' dir='${build-common.root}/lib/test'>
|
||||||
<include name='*.jar'/>
|
<include name='*.jar'/>
|
||||||
</fileset>
|
</fileset>
|
||||||
<path id='api-classes'>
|
<path id='api-classes'>
|
||||||
@@ -11,18 +13,22 @@
|
|||||||
<path id='component-classes'>
|
<path id='component-classes'>
|
||||||
<pathelement location='${build-common.root}/components/build'/>
|
<pathelement location='${build-common.root}/components/build'/>
|
||||||
</path>
|
</path>
|
||||||
|
<path id='test-classes'>
|
||||||
|
<pathelement location='${build-common.root}/test/build'/>
|
||||||
|
</path>
|
||||||
<path id='util-classes'>
|
<path id='util-classes'>
|
||||||
<pathelement location='${build-common.root}/util/build'/>
|
<pathelement location='${build-common.root}/util/build'/>
|
||||||
</path>
|
</path>
|
||||||
<target name='clean'>
|
<target name='clean'>
|
||||||
<delete dir='${build}'/>
|
<delete dir='build'/>
|
||||||
</target>
|
</target>
|
||||||
<target name='compile'>
|
<target name='compile'>
|
||||||
<mkdir dir='${build}'/>
|
<mkdir dir='build'/>
|
||||||
<javac srcdir='net/sf/briar' destdir='${build}'
|
<javac srcdir='net/sf/briar' destdir='build'
|
||||||
includeantruntime='false'>
|
includeantruntime='false'>
|
||||||
<classpath>
|
<classpath>
|
||||||
<fileset refid='third-party-jars'/>
|
<fileset refid='bundled-jars'/>
|
||||||
|
<fileset refid='test-jars'/>
|
||||||
<path refid='api-classes'/>
|
<path refid='api-classes'/>
|
||||||
<path refid='component-classes'/>
|
<path refid='component-classes'/>
|
||||||
<path refid='util-classes'/>
|
<path refid='util-classes'/>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<project name='all' default='compile'>
|
<project name='all' default='depend'>
|
||||||
<import file='build-common.xml'/>
|
<import file='build-common.xml'/>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
<project name='dependencies' default='depend.all'>
|
<project name='dependencies'>
|
||||||
|
|
||||||
<dirname property='depend.root' file='${ant.file.dependencies}'/>
|
<dirname property='depend.root' file='${ant.file.dependencies}'/>
|
||||||
|
<target name='depend.all' depends='depend.components, depend.ui'/>
|
||||||
<target name='depend.all' depends='depend.components, depend.ui'>
|
|
||||||
</target>
|
|
||||||
<target name='depend.api'>
|
<target name='depend.api'>
|
||||||
<ant dir='${depend.root}/api' inheritAll='false'/>
|
<ant dir='${depend.root}/api' inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
<target name='depend.components' depends='depend.api, depend.util'>
|
<target name='depend.components' depends='depend.api, depend.util'>
|
||||||
<ant dir='${depend.root}/components' inheritAll='false'/>
|
<ant dir='${depend.root}/components' inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
|
<target name='depend.test' depends='depend.components'>
|
||||||
|
<ant dir='${depend.root}/test' inheritAll='false'/>
|
||||||
|
</target>
|
||||||
<target name='depend.ui' depends='depend.api, depend.util'>
|
<target name='depend.ui' depends='depend.api, depend.util'>
|
||||||
<ant dir='${depend.root}/ui' inheritAll='false'/>
|
<ant dir='${depend.root}/ui' inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
<target name='depend.util'>
|
<target name='depend.util'>
|
||||||
<ant dir='${depend.root}/util' inheritAll='false'/>
|
<ant dir='${depend.root}/util' inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name='depend-clean.all'
|
<target name='depend-clean.all'
|
||||||
depends='depend-clean.components, depend-clean.ui'>
|
depends='depend-clean.components, depend-clean.ui'/>
|
||||||
</target>
|
|
||||||
<target name='depend-clean.api'>
|
<target name='depend-clean.api'>
|
||||||
<ant dir='${depend.root}/api' target='clean'
|
<ant dir='${depend.root}/api' target='clean'
|
||||||
inheritAll='false'/>
|
inheritAll='false'/>
|
||||||
@@ -29,6 +27,11 @@
|
|||||||
<ant dir='${depend.root}/components' target='clean'
|
<ant dir='${depend.root}/components' target='clean'
|
||||||
inheritAll='false'/>
|
inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
|
<target name='depend-clean.test'
|
||||||
|
depends='depend-clean.components'>
|
||||||
|
<ant dir='${depend.root}/test' target='clean'
|
||||||
|
inheritAll='false'/>
|
||||||
|
</target>
|
||||||
<target name='depend-clean.ui'
|
<target name='depend-clean.ui'
|
||||||
depends='depend-clean.api, depend-clean.util'>
|
depends='depend-clean.api, depend-clean.util'>
|
||||||
<ant dir='${depend.root}/ui' target='clean'
|
<ant dir='${depend.root}/ui' target='clean'
|
||||||
@@ -38,5 +41,4 @@
|
|||||||
<ant dir='${depend.root}/util' target='clean'
|
<ant dir='${depend.root}/util' target='clean'
|
||||||
inheritAll='false'/>
|
inheritAll='false'/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
BIN
lib/test/hamcrest-core-1.1.jar
Normal file
BIN
lib/test/hamcrest-core-1.1.jar
Normal file
Binary file not shown.
BIN
lib/test/hamcrest-library-1.1.jar
Normal file
BIN
lib/test/hamcrest-library-1.1.jar
Normal file
Binary file not shown.
BIN
lib/test/jmock-2.5.1.jar
Normal file
BIN
lib/test/jmock-2.5.1.jar
Normal file
Binary file not shown.
BIN
lib/test/junit-4.9b2.jar
Normal file
BIN
lib/test/junit-4.9b2.jar
Normal file
Binary file not shown.
16
test/build.xml
Normal file
16
test/build.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<project name='test' default='compile'>
|
||||||
|
<import file='../build-common.xml'/>
|
||||||
|
<target name='test' depends='depend'>
|
||||||
|
<junit haltonfailure='true' printsummary='on' showoutput='true'>
|
||||||
|
<classpath>
|
||||||
|
<fileset refid='bundled-jars'/>
|
||||||
|
<fileset refid='test-jars'/>
|
||||||
|
<path refid='api-classes'/>
|
||||||
|
<path refid='component-classes'/>
|
||||||
|
<path refid='test-classes'/>
|
||||||
|
<path refid='util-classes'/>
|
||||||
|
</classpath>
|
||||||
|
<test name='net.sf.briar.util.FileUtilsTest'/>
|
||||||
|
</junit>
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
59
test/net/sf/briar/util/FileUtilsTest.java
Normal file
59
test/net/sf/briar/util/FileUtilsTest.java
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user