Author: bago
Date: Fri Apr 27 07:02:46 2007
New Revision: 533102

URL: http://svn.apache.org/viewvc?view=rev&rev=533102
Log:
Changed the mime parser test so that when an expected file cannot be found it 
will create a new .mime4j.xml file with the obtained result.
This file should be reviewed and the ".mime4j" should be removed so to make it 
an effective test.

Modified:
    
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeStreamParserTest.java

Modified: 
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeStreamParserTest.java
URL: 
http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeStreamParserTest.java?view=diff&rev=533102&r1=533101&r2=533102
==============================================================================
--- 
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeStreamParserTest.java
 (original)
+++ 
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeStreamParserTest.java
 Fri Apr 27 07:02:46 2007
@@ -19,22 +19,20 @@
 
 package org.apache.james.mime4j;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.BasicConfigurator;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.LinkedList;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.AbstractContentHandler;
-import org.apache.james.mime4j.BodyDescriptor;
-import org.apache.james.mime4j.ContentHandler;
-import org.apache.james.mime4j.MimeStreamParser;
-import org.apache.log4j.BasicConfigurator;
-
 
 
 /**
@@ -436,9 +434,19 @@
                 
                 String result = handler.sb.toString();
                 String xmlFile = f.getAbsolutePath().substring(0, 
f.getAbsolutePath().lastIndexOf('.')) + ".xml";
-                String expected = IOUtils.toString(new 
FileInputStream(xmlFile), "ISO8859-1");
+                String xmlFileMime4j = f.getAbsolutePath().substring(0, 
f.getAbsolutePath().lastIndexOf('.')) + ".mime4j.xml";
                 
-                assertEquals("Error parsing " + f.getName(), expected, result);
+                try {
+                    String expected = IOUtils.toString(new 
FileInputStream(xmlFile), "ISO8859-1");
+                    
+                    assertEquals("Error parsing " + f.getName(), expected, 
result);
+                } catch (FileNotFoundException e) {
+                    FileOutputStream fos = new FileOutputStream(xmlFileMime4j);
+                    fos.write(result.getBytes());
+                    fos.flush();
+                    fos.close();
+                    fail("XML file not found: generated a file with the 
expected result!");
+                }
             }
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to