From: <ls...@us...> - 2009-03-31 20:12:57
|
Revision: 5199 http://jnode.svn.sourceforge.net/jnode/?rev=5199&view=rev Author: lsantha Date: 2009-03-31 19:57:24 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Integrated patch by Stefan Anzinger: "Changes done: 1. Removed usage JFuncSuite for defining TestSuites this blocks Eclipse JUnit testrunner to execute tests (i don't know why but it doesn't work). Now it is also feasible to run FSTestSuite in Eclipse with "Run-As -> Junit Test". 2. Added report generation in the fs/build.xml to generate HTML-report of testrun in fs/build/report/" Modified Paths: -------------- trunk/fs/build.xml trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java Modified: trunk/fs/build.xml =================================================================== --- trunk/fs/build.xml 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/build.xml 2009-03-31 19:57:24 UTC (rev 5199) @@ -6,6 +6,7 @@ <property name="my-classes.dir" value="${my-build.dir}/classes"/> <property name="my-src.dir" value="${basedir}/src"/> <property name="my.jar" value="${jnode-fs.jar}"/> + <property name="my-report.dir" value="${my-build.dir}/report"/> <!-- Subproject specific classpath --> <path id="my-cp"> @@ -71,12 +72,19 @@ <!-- tests FileSystems --> <target name="tests" depends="compile" description="Run FS tests with JUnit"> + <mkdir dir="${my-report.dir}"/> <junit fork="yes" haltonerror="false" haltonfailure="false" printsummary="on" includeantruntime="true"> <classpath refid="cp-jnode" /> - - <formatter type="plain" usefile="false" /> - <test name="org.jnode.test.fs.filesystem.FSTestSuite" /> + <formatter type="xml" /> + <test name="org.jnode.test.fs.filesystem.FSTestSuite" outfile="${my-report.dir}/TEST-fs"/> </junit> + <junitreport todir="${my-report.dir}"> + <fileset dir="${my-report.dir}"> + <include name="TEST*.xml"/> + </fileset> + <report todir="${my-report.dir}" format="frames"/> + </junitreport> + <echo message="HTML report: ${my-report.dir}/index.html" /> </target> </project> Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -26,8 +26,11 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; + import javax.naming.NameNotFoundException; -import junit.extensions.jfunc.JFuncTestCase; + +import junit.framework.TestCase; + import org.apache.log4j.Logger; import org.jnode.driver.Device; import org.jnode.fs.FSDirectory; @@ -41,18 +44,19 @@ /** * @author Fabien DUMINY */ -public abstract class AbstractFSTest extends JFuncTestCase { +public abstract class AbstractFSTest extends TestCase { protected final Logger log = Logger.getLogger(getClass()); //public static final int FILE_SIZE_IN_WORDS = 256 * 1024; // 512 Ko = 256 K Words public static final int FILE_SIZE_IN_WORDS = 128; // 512 Ko = 128 K Words private FileSystem fs; - private FSTestConfig config; + protected FSTestConfig config; private Device device; - public AbstractFSTest() { + public AbstractFSTest(FSTestConfig config) { super(); + this.config = config; } /** @@ -62,10 +66,9 @@ super(name); } - protected final void setUp(FSTestConfig config) throws NameNotFoundException, FileSystemException, IOException, + public final void setUp() throws NameNotFoundException, FileSystemException, IOException, InstantiationException, IllegalAccessException, Exception { super.setUp(); - this.config = config; this.device = config.getDeviceParam().createDevice(); this.fs = config.getFileSystem().format(this.device); this.fs = config.getFileSystem().mount(this.device); @@ -141,9 +144,9 @@ // return (FSContext) ContextManager.getInstance().getContext(); // } - protected void assertFalse(String message, boolean condition) { - assertTrue(message, !condition); - } +// protected void assertFalse(String message, boolean condition) { +// assertTrue(message, !condition); +// } protected void assertContainsOnly(String errorMessage, Iterator<? extends FSEntry> it, String[] requiredNames) { boolean ok = true; Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -20,8 +20,12 @@ package org.jnode.test.fs.filesystem; +import javax.naming.NamingException; + import junit.extensions.jfunc.JFuncSuite; import junit.extensions.jfunc.textui.JFuncRunner; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.jnode.emu.naming.BasicNameSpace; import org.jnode.emu.plugin.model.DummyConfigurationElement; @@ -38,7 +42,6 @@ import org.jnode.test.fs.filesystem.tests.FileFSTest; import org.jnode.test.fs.filesystem.tests.TreeFSTest; import org.jnode.util.OsUtils; -import javax.naming.NamingException; /** * This class runs a suite of functional tests on the JNode file system @@ -84,36 +87,40 @@ setup = true; } - public static JFuncSuite suite() throws Throwable { + public static TestSuite suite() throws Throwable { setUp(); - JFuncSuite suite = new JFuncSuite(); - + TestSuite allTestsSuite = new TestSuite("All FS Tests"); + for (FSTestConfig config : new FSConfigurations()) { - BasicFSTest basicTest = (BasicFSTest) suite.getTestProxy(new BasicFSTest()); - basicTest.testAddDirectory(config); - basicTest.testAddFile(config); - basicTest.testAddFileThenRemountFSAndGetFile(config); - basicTest.testGetRootEntry(config); - basicTest.testListRootEntries(config); - basicTest.testRemoveThenRemountFSAndGetEntry(config); + TestSuite tests = new TestSuite(); + tests.setName(config.getFileSystem().toString()); + addTest(tests, new BasicFSTest(config), "testAddDirectory"); + addTest(tests, new BasicFSTest(config), "testAddFile"); + addTest(tests, new BasicFSTest(config), "testAddFileThenRemountFSAndGetFile"); + addTest(tests, new BasicFSTest(config), "testGetRootEntry"); + addTest(tests, new BasicFSTest(config), "testListRootEntries"); + addTest(tests, new BasicFSTest(config), "testRemoveThenRemountFSAndGetEntry"); - FileFSTest fileTest = (FileFSTest) suite.getTestProxy(new FileFSTest()); - fileTest.testSetLength(config); - fileTest.testWriteFileInReadOnlyMode(config); - fileTest.testWriteFileThenRemountFSAndRead(config); + addTest(tests, new FileFSTest(config), "testSetLength"); + addTest(tests, new FileFSTest(config), "testWriteFileInReadOnlyMode"); + addTest(tests, new FileFSTest(config), "testWriteFileThenRemountFSAndRead"); + + addTest(tests, new TreeFSTest(config), "testFSTree"); + addTest(tests, new TreeFSTest(config), "testFSTreeWithRemountAndLongName"); + addTest(tests, new TreeFSTest(config), "testFSTreeWithRemountAndShortName"); - TreeFSTest treeTest = (TreeFSTest) suite.getTestProxy(new TreeFSTest()); - treeTest.testFSTree(config); - treeTest.testFSTreeWithRemountAndLongName(config); - treeTest.testFSTreeWithRemountAndShortName(config); + addTest(tests, new ConcurrentAccessFSTest(config), "testRead"); + addTest(tests, new ConcurrentAccessFSTest(config), "testWrite"); + addTest(tests, new ConcurrentAccessFSTest(config), "testReadWrite"); - ConcurrentAccessFSTest threadTest = (ConcurrentAccessFSTest) - suite.getTestProxy(new ConcurrentAccessFSTest()); - threadTest.testRead(config); - threadTest.testWrite(config); - threadTest.testReadWrite(config); + allTestsSuite.addTest(tests); } - - return suite; + + return allTestsSuite; } + + private static void addTest(TestSuite suite, TestCase test, String name) { + test.setName(name); + suite.addTest(test); + } } Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -20,8 +20,8 @@ package org.jnode.test.fs.filesystem.tests; -import java.io.IOException; import java.util.Iterator; + import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; import org.jnode.fs.ReadOnlyFileSystemException; @@ -34,30 +34,30 @@ * @author Fabien DUMINY */ public class BasicFSTest extends AbstractFSTest { - public BasicFSTest() { - super(); + public BasicFSTest(FSTestConfig config) { + super(config); } public BasicFSTest(String name) { super(name); } - - public void testGetRootEntry(FSTestConfig config) throws Exception { - setUp(config); + + public void testGetRootEntry() throws Exception { + setUp(); FSEntry rootEntry = getFs().getRootEntry(); log.debug(FSUtils.toString(rootEntry, false)); } - public void testListRootEntries(FSTestConfig config) throws Exception { - setUp(config); + public void testListRootEntries() throws Exception { + setUp(); Iterator<? extends FSEntry> iterator = getFs().getRootEntry().getDirectory().iterator(); TestUtils.listEntries(iterator); } - public void testAddDirectory(FSTestConfig config) throws Exception { - setUp(config); + public void testAddDirectory() throws Exception { + setUp(); FSDirectory rootDir = getFs().getRootEntry().getDirectory(); String dirName = "A new directory.text"; @@ -89,8 +89,8 @@ TestUtils.listEntries(rootDir.iterator()); } - public void testAddFile(FSTestConfig config) throws Exception { - setUp(config); + public void testAddFile() throws Exception { + setUp(); FSDirectory rootDir = getFs().getRootEntry().getDirectory(); String fileName = "A new file.text"; @@ -124,9 +124,9 @@ TestUtils.listEntries(rootDir.iterator()); } - public void testAddFileThenRemountFSAndGetFile(FSTestConfig config) throws IOException, Exception { + public void testAddFileThenRemountFSAndGetFile() throws Exception { if (!config.isReadOnly()) { - setUp(config); + setUp(); String filename = "a file to test.text"; FSDirectory rootDir = getFs().getRootEntry().getDirectory(); @@ -149,10 +149,10 @@ } } - public void testRemoveThenRemountFSAndGetEntry(FSTestConfig config) throws Exception { + public void testRemoveThenRemountFSAndGetEntry() throws Exception { if (!config.isReadOnly()) { - setUp(config); + setUp(); String filename = "a file to test.text"; FSDirectory rootDir = getFs().getRootEntry().getDirectory(); Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -41,16 +41,16 @@ protected static final int NB_WRITERS = 10; - public ConcurrentAccessFSTest() { - super(); + public ConcurrentAccessFSTest(FSTestConfig config) { + super(config); } public ConcurrentAccessFSTest(String name) { super(name); } - public void testRead(FSTestConfig config) throws Throwable { - setUp(config); + public void testRead() throws Throwable { + setUp(); FSFile file = prepareFile(config); @@ -61,9 +61,9 @@ monitor.waitAll(); } - public void testWrite(FSTestConfig config) throws Throwable { + public void testWrite() throws Throwable { if (!config.isReadOnly()) { - setUp(config); + setUp(); FSFile file = prepareFile(config); Monitor monitor = new Monitor("testWrite"); @@ -73,8 +73,8 @@ } } - public void testReadWrite(FSTestConfig config) throws Throwable { - setUp(config); + public void testReadWrite() throws Throwable { + setUp(); FSFile file = prepareFile(config); Monitor monitor = new Monitor("testReadWrite"); Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -33,16 +33,16 @@ * @author Fabien DUMINY */ public class FileFSTest extends AbstractFSTest { - public FileFSTest() { - super(); + public FileFSTest(FSTestConfig config) { + super(config); } public FileFSTest(String name) { super(name); } - public void testWriteFileThenRemountFSAndRead(FSTestConfig config) throws Exception { - setUp(config); + public void testWriteFileThenRemountFSAndRead() throws Exception { + setUp(); final String fileName = "RWTest"; @@ -82,9 +82,9 @@ } } - public void testWriteFileInReadOnlyMode(FSTestConfig config) throws Exception { + public void testWriteFileInReadOnlyMode() throws Exception { if (config.isReadOnly()) { - setUp(config); + setUp(); final String fileName = "RWTest"; @@ -104,8 +104,8 @@ } } - public void testSetLength(FSTestConfig config) throws Exception { - setUp(config); + public void testSetLength() throws Exception { + setUp(); final int newSize = 128; final String fileName = "RWTest"; Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java 2009-03-31 19:02:47 UTC (rev 5198) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java 2009-03-31 19:57:24 UTC (rev 5199) @@ -31,17 +31,17 @@ * @author Fabien DUMINY */ public class TreeFSTest extends AbstractFSTest { - public TreeFSTest() { - super(); + public TreeFSTest(FSTestConfig config) { + super(config); } public TreeFSTest(String name) { super(name); } - public void testFSTree(FSTestConfig config) throws IOException, Exception { + public void testFSTree() throws IOException, Exception { if (!config.isReadOnly()) { - setUp(config); + setUp(); FSDirectory rootDir = getFs().getRootEntry().getDirectory(); FSEntry dir1 = rootDir.addDirectory("dir1"); @@ -62,17 +62,17 @@ } } - public void testFSTreeWithRemountAndShortName(FSTestConfig config) throws Exception { + public void testFSTreeWithRemountAndShortName() throws Exception { doTestFSTreeWithRemount(config, "dir1"); } - public void testFSTreeWithRemountAndLongName(FSTestConfig config) throws Exception { + public void testFSTreeWithRemountAndLongName() throws Exception { doTestFSTreeWithRemount(config, "This is a Long FileName.extension"); } private void doTestFSTreeWithRemount(FSTestConfig config, String fileName) throws Exception { if (!config.isReadOnly()) { - setUp(config); + setUp(); FSDirectory rootDir = getFs().getRootEntry().getDirectory(); log.debug("### testFSTreeWithRemount: rootDir=\n" + FSUtils.toString(rootDir, true)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |