Return-Path: Delivered-To: apmail-james-mime4j-dev-archive@minotaur.apache.org Received: (qmail 21779 invoked from network); 27 Dec 2009 18:50:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Dec 2009 18:50:37 -0000 Received: (qmail 65689 invoked by uid 500); 27 Dec 2009 18:50:37 -0000 Delivered-To: apmail-james-mime4j-dev-archive@james.apache.org Received: (qmail 65654 invoked by uid 500); 27 Dec 2009 18:50:37 -0000 Mailing-List: contact mime4j-dev-help@james.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mime4j-dev@james.apache.org Delivered-To: mailing list mime4j-dev@james.apache.org Received: (qmail 65644 invoked by uid 99); 27 Dec 2009 18:50:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Dec 2009 18:50:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Dec 2009 18:50:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ECCE12388962; Sun, 27 Dec 2009 18:50:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r894094 - in /james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j: message/ExampleMessagesRoundtripTest.java message/MessageParserTest.java parser/MimeStreamParserExampleMessagesTest.java Date: Sun, 27 Dec 2009 18:50:13 -0000 To: mime4j-dev@james.apache.org From: bago@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091227185013.ECCE12388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bago Date: Sun Dec 27 18:50:13 2009 New Revision: 894094 URL: http://svn.apache.org/viewvc?rev=894094&view=rev Log: Alter the multi-file testsuite to use classpath lookup instead of source reference. This make tests work out of the box in a maven imported eclipse (multiple module in single project) while keeping the behaviour in standard maven. Also this is much better as it does not references the source location for files while refers it using the final test-classes package name. Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java?rev=894094&r1=894093&r2=894094&view=diff ============================================================================== --- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java (original) +++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java Sun Dec 27 18:50:13 2009 @@ -19,21 +19,22 @@ package org.apache.james.mime4j.message; -import org.apache.james.mime4j.codec.CodecUtil; -import org.apache.james.mime4j.parser.MimeEntityConfig; -import org.apache.log4j.BasicConfigurator; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.net.URISyntaxException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.apache.james.mime4j.codec.CodecUtil; +import org.apache.james.mime4j.parser.MimeEntityConfig; +import org.apache.log4j.BasicConfigurator; + /** * Creates a TestSuite running the test for each .msg file in the test resouce folder. * Allow running of a single test from Unit testing GUIs @@ -43,7 +44,7 @@ private File file; - public ExampleMessagesRoundtripTest(String testName) { + public ExampleMessagesRoundtripTest(String testName) throws URISyntaxException { this(testName, ExampleMessagesRountripTestSuite.getFile(testName)); } @@ -82,18 +83,18 @@ } } - public static Test suite() throws IOException { + public static Test suite() throws IOException, URISyntaxException { return new ExampleMessagesRountripTestSuite(); } static class ExampleMessagesRountripTestSuite extends TestSuite { - private static final File TESTS_FOLDER = new File("src/test/resources/testmsgs"); + private static final String TESTS_FOLDER = "/testmsgs"; - public ExampleMessagesRountripTestSuite() throws IOException { + public ExampleMessagesRountripTestSuite() throws IOException, URISyntaxException { super(); - File dir = TESTS_FOLDER; + File dir = new File(ExampleMessagesRountripTestSuite.class.getResource(TESTS_FOLDER).toURI()); File[] files = dir.listFiles(); for (File f : files) { @@ -103,8 +104,8 @@ } } - public static File getFile(String name) { - return new File(TESTS_FOLDER.getAbsolutePath()+File.separator+name+".msg"); + public static File getFile(String name) throws URISyntaxException { + return new File(ExampleMessagesRountripTestSuite.class.getResource(TESTS_FOLDER+File.separator+name+".msg").toURI()); } } Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java?rev=894094&r1=894093&r2=894094&view=diff ============================================================================== --- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java (original) +++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java Sun Dec 27 18:50:13 2009 @@ -35,6 +35,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; import java.util.List; import junit.framework.Test; @@ -44,7 +45,7 @@ public class MessageParserTest extends TestCase { private File file = null; - public MessageParserTest(String name) { + public MessageParserTest(String name) throws URISyntaxException { this(name, MessageParserTestSuite.getFile(name)); } @@ -59,16 +60,16 @@ BasicConfigurator.configure(); } - public static Test suite() { + public static Test suite() throws URISyntaxException { return new MessageParserTestSuite(); } static class MessageParserTestSuite extends TestSuite { - private static final File TESTS_FOLDER = new File("src/test/resources/testmsgs"); + private static final String TESTS_FOLDER = "/testmsgs"; - public MessageParserTestSuite() { - File dir = TESTS_FOLDER; + public MessageParserTestSuite() throws URISyntaxException { + File dir = new File(MessageParserTestSuite.class.getResource(TESTS_FOLDER).toURI()); File[] files = dir.listFiles(); for (int i = 0; i < files.length && i < 5000; i++) { @@ -79,8 +80,8 @@ } } - public static File getFile(String name) { - return new File(TESTS_FOLDER.getAbsolutePath()+File.separator+name+".msg"); + public static File getFile(String name) throws URISyntaxException { + return new File(MessageParserTestSuite.class.getResource(TESTS_FOLDER+File.separator+name+".msg").toURI()); } } Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java?rev=894094&r1=894093&r2=894094&view=diff ============================================================================== --- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java (original) +++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java Sun Dec 27 18:50:13 2009 @@ -19,20 +19,20 @@ package org.apache.james.mime4j.parser; -import org.apache.commons.io.IOUtils; -import org.apache.james.mime4j.parser.MimeStreamParser; -import org.apache.log4j.BasicConfigurator; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.net.URISyntaxException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.apache.commons.io.IOUtils; +import org.apache.log4j.BasicConfigurator; + /** * Creates a TestSuite running the test for each .msg file in the test resouce folder. * Allow running of a single test from Unit testing GUIs @@ -42,7 +42,7 @@ private File file; - public MimeStreamParserExampleMessagesTest(String testName) { + public MimeStreamParserExampleMessagesTest(String testName) throws URISyntaxException { this(testName, MimeStreamParserExampleMessagesTestSuite.getFile(testName)); } @@ -86,18 +86,18 @@ } } - public static Test suite() throws IOException { + public static Test suite() throws IOException, URISyntaxException { return new MimeStreamParserExampleMessagesTestSuite(); } static class MimeStreamParserExampleMessagesTestSuite extends TestSuite { - private static final File TESTS_FOLDER = new File("src/test/resources/testmsgs"); + private static final String TESTS_FOLDER = "/testmsgs"; - public MimeStreamParserExampleMessagesTestSuite() throws IOException { + public MimeStreamParserExampleMessagesTestSuite() throws IOException, URISyntaxException { super(); - File dir = TESTS_FOLDER; + File dir = new File(MimeStreamParserExampleMessagesTestSuite.class.getResource(TESTS_FOLDER).toURI()); File[] files = dir.listFiles(); for (File f : files) { @@ -107,8 +107,8 @@ } } - public static File getFile(String name) { - return new File(TESTS_FOLDER.getAbsolutePath()+File.separator+name+".msg"); + public static File getFile(String name) throws URISyntaxException { + return new File(MimeStreamParserExampleMessagesTestSuite.class.getResource(TESTS_FOLDER+File.separator+name+".msg").toURI()); } }