james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r906202 - in /james/mime4j/trunk/core/src: main/java/org/apache/james/mime4j/message/ main/java/org/apache/james/mime4j/parser/ main/java/org/apache/james/mime4j/stream/ test/java/org/apache/james/mime4j/parser/ test/java/org/apache/james/m...
Date Wed, 03 Feb 2010 19:37:58 GMT
Author: olegk
Date: Wed Feb  3 19:37:57 2010
New Revision: 906202

URL: http://svn.apache.org/viewvc?rev=906202&view=rev
Log:
´╗┐MIME4J-129, MIME4J-157: The patch eliminates a direct dependency on MaximalBodyDescriptor
in all parser classes and replaces it with the MutableBodyDescriptorFactory interface

Added:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
  (with props)
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
  (with props)
Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
Wed Feb  3 19:37:57 2010
@@ -48,7 +48,7 @@
 
     private final Entity entity;
     private final BodyFactory bodyFactory;
-    private Stack<Object> stack = new Stack<Object>();
+    private final Stack<Object> stack;
     private final DecodeMonitor monitor;
     
     public MessageBuilder(Entity entity) {
@@ -62,6 +62,7 @@
     public MessageBuilder(Entity entity, StorageProvider storageProvider, DecodeMonitor monitor)
{
         this.entity = entity;
         this.bodyFactory = new BodyFactory(storageProvider);
+        this.stack = new Stack<Object>();
         this.monitor = monitor != null ? monitor : LoggingMonitor.MONITOR;
     }
     

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageImpl.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
Wed Feb  3 19:37:57 2010
@@ -54,6 +54,7 @@
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**
@@ -145,16 +146,21 @@
      * @param storageProvider
      *            {@link StorageProvider} to use for storing text and binary
      *            message bodies.
+     * @param bodyDescFactory
+     *            {@link MutableBodyDescriptorFactory} to use for creating body descriptors.
      * @throws IOException
      *             on I/O errors.
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public MessageImpl(InputStream is, MimeEntityConfig config,
-            StorageProvider storageProvider, DecodeMonitor monitor) throws IOException,
-            MimeIOException {
+    public MessageImpl(
+            final InputStream is, 
+            final MimeEntityConfig config,
+            final StorageProvider storageProvider, 
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) throws IOException, MimeIOException
{
         try {
-            MimeStreamParser parser = new MimeStreamParser(config, monitor);
+            MimeStreamParser parser = new MimeStreamParser(config, monitor, bodyDescFactory);
             parser.setContentDecoding(true);
             this.monitor = monitor != null ? monitor : LoggingMonitor.MONITOR;
             parser.setContentHandler(new MessageBuilder(this, storageProvider, this.monitor));
@@ -164,9 +170,19 @@
         }
     }
 
-    public MessageImpl(InputStream is, MimeEntityConfig config,
-            StorageProvider storageProvider) throws IOException, MimeIOException {
-        this(is, config, storageProvider, LoggingMonitor.MONITOR);
+    public MessageImpl(
+            final InputStream is, 
+            final MimeEntityConfig config,
+            final StorageProvider storageProvider,
+            final MutableBodyDescriptorFactory bodyDescFactory) throws IOException, MimeIOException
{
+        this(is, config, storageProvider, LoggingMonitor.MONITOR, bodyDescFactory);
+    }
+
+    public MessageImpl(
+            final InputStream is, 
+            final MimeEntityConfig config,
+            final StorageProvider storageProvider) throws IOException, MimeIOException {
+        this(is, config, storageProvider, LoggingMonitor.MONITOR, null);
     }
 
     /**

Added: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java?rev=906202&view=auto
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
(added)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
Wed Feb  3 19:37:57 2010
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.parser;
+
+import org.apache.james.mime4j.stream.MutableBodyDescriptor;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
+
+public class MaximalBodyDescriptorFactory implements MutableBodyDescriptorFactory {
+
+    public MutableBodyDescriptor newInstance() {
+        return new MaximalBodyDescriptor(null);
+    }
+    
+} 

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Wed Feb  3 19:37:57 2010
@@ -29,6 +29,7 @@
 import org.apache.james.mime4j.stream.BodyDescriptor;
 import org.apache.james.mime4j.stream.ContentHandler;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
 /**
  * <p>
@@ -59,24 +60,32 @@
         this.contentDecoding = false;
     }
 
-    public MimeStreamParser(final MimeEntityConfig config, DecodeMonitor monitor, boolean
clone) {
-        this(new MimeTokenStream(clone ? config.clone() : config, monitor));
+    public MimeStreamParser(
+            final MimeEntityConfig config, 
+            boolean clone,
+            final DecodeMonitor monitor, 
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        this(new MimeTokenStream(clone ? config.clone() : config, monitor, bodyDescFactory));
     }
 
     public MimeStreamParser(final MimeEntityConfig config, boolean clone) {
-        this(new MimeTokenStream(clone ? config.clone() : config, null));
+        this(new MimeTokenStream(clone ? config.clone() : config, null, null));
     }
 
-    public MimeStreamParser(final MimeEntityConfig config, DecodeMonitor monitor) {
-        this(config != null ? config : new MimeEntityConfig(), monitor, config != null);
+    public MimeStreamParser(
+            final MimeEntityConfig config, 
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        this(config != null ? config : new MimeEntityConfig(), config != null, 
+                monitor, bodyDescFactory);
     }
 
     public MimeStreamParser(final MimeEntityConfig config) {
-        this(config, null);
+        this(config, null, null);
     }
 
     public MimeStreamParser() {
-        this(new MimeEntityConfig(), false);
+        this(new MimeEntityConfig(), false, null, null);
     }
     
     /**

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
Wed Feb  3 19:37:57 2010
@@ -23,10 +23,8 @@
 
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.stream.BasicMimeTokenStream;
-import org.apache.james.mime4j.stream.BodyDescriptor;
-import org.apache.james.mime4j.stream.DefaultBodyDescriptor;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
-import org.apache.james.mime4j.stream.MutableBodyDescriptor;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
 /**
  * <p>
@@ -67,60 +65,26 @@
  * one instance per thread.</p>
  */
 public class MimeTokenStream extends BasicMimeTokenStream {
-    
-    /**
-     * Creates a stream that creates a more detailed body descriptor.
-     * @return <code>MimeTokenStream</code>, not null
-     */
-    public static final MimeTokenStream createMaximalDescriptorStream() {
-        MimeEntityConfig config = new MimeEntityConfig();
-        config.setMaximalBodyDescriptor(true);
-        return new MimeTokenStream(config);
-    }
-    
-    /**
-     * Creates a stream that strictly validates the input.
-     * @return <code>MimeTokenStream</code> which throws a 
-     * <code>MimeException</code> whenever possible issues 
-     * are dedicated in the input
-     */
-    public static final MimeTokenStream createStrictValidationStream() {
-        MimeEntityConfig config = new MimeEntityConfig();
-        config.setStrictParsing(true);
-        return new MimeTokenStream(config);
-    }
-    
-    /**
-     * Constructs a standard (lax) stream.
-     * Optional validation events will be logged only.
-     * Use {@link #createStrictValidationStream()} to create
-     * a stream that strictly validates the input.
-     */
+
     public MimeTokenStream() {
-        this(new MimeEntityConfig());
+        super(new MimeEntityConfig());
     }
-    
+
     public MimeTokenStream(final MimeEntityConfig config) {
-        this(config, null);
+        super(config, null, null);
     }
-    
-    public MimeTokenStream(final MimeEntityConfig config, DecodeMonitor monitor) {
-        super(config, monitor);
+        
+    public MimeTokenStream(
+            final MimeEntityConfig config, 
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        super(config, null, bodyDescFactory);
     }
 
-    /**
-     * Creates a new instance of {@link BodyDescriptor}. Subclasses may override
-     * this in order to create body descriptors, that provide more specific
-     * information.
-     */
-    protected MutableBodyDescriptor newBodyDescriptor() {
-        final MutableBodyDescriptor result;
-        if (getConfig().isMaximalBodyDescriptor()) {
-            result = new MaximalBodyDescriptor(null);
-        } else {
-            result = new DefaultBodyDescriptor(null);
-        }
-        return result;
+    public MimeTokenStream(
+            final MimeEntityConfig config, 
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        super(config, monitor, bodyDescFactory);
     }
-
+    
 }

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java
Wed Feb  3 19:37:57 2010
@@ -75,13 +75,14 @@
 public class BasicMimeTokenStream implements EntityStates, RecursionMode {
     
     private final MimeEntityConfig config;
+    private final DecodeMonitor monitor;
+    private final MutableBodyDescriptorFactory bodyDescFactory;
     private final LinkedList<EntityStateMachine> entities = new LinkedList<EntityStateMachine>();
     
     private int state = T_END_OF_STREAM;
     private EntityStateMachine currentStateMachine;
     private int recursionMode = M_RECURSE;
 	private MimeEntity rootentity;
-    private final DecodeMonitor monitor;
     
     /**
      * Constructs a standard (lax) stream.
@@ -94,16 +95,26 @@
     }
 
     public BasicMimeTokenStream(final MimeEntityConfig config) {
-        this(config, null);
+        this(config, null, null);
     }
         
-    public BasicMimeTokenStream(final MimeEntityConfig config, DecodeMonitor monitor) {
+    public BasicMimeTokenStream(
+            final MimeEntityConfig config, 
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        this(config, null, bodyDescFactory);
+    }
+
+    public BasicMimeTokenStream(
+            final MimeEntityConfig config, 
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
         super();
         this.config = config;
-        this.monitor = monitor != null ? monitor : (config.isStrictParsing() ? DecodeMonitor.STRICT
: DecodeMonitor.SILENT);
+        this.monitor = monitor != null ? monitor : 
+            (config.isStrictParsing() ? DecodeMonitor.STRICT : DecodeMonitor.SILENT);
+        this.bodyDescFactory = bodyDescFactory;
     }
 
-
     /** Instructs the {@code MimeTokenStream} to parse the given streams contents.
      * If the {@code MimeTokenStream} has already been in use, resets the streams
      * internal state.
@@ -138,9 +149,20 @@
         doParse(stream, newBodyDescriptor, start);
     }
 
+    /**
+     * Creates a new instance of {@link BodyDescriptor}. Subclasses may override
+     * this in order to create body descriptors, that provide more specific
+     * information.
+     */
     protected MutableBodyDescriptor newBodyDescriptor() {
-		return new DefaultBodyDescriptor(null);
-	}
+        final MutableBodyDescriptor result;
+        if (bodyDescFactory != null) {
+            result = bodyDescFactory.newInstance();
+        } else {
+            result = new DefaultBodyDescriptor(null);
+        }
+        return result;
+    }
 
 	public void doParse(InputStream stream,
             MutableBodyDescriptor newBodyDescriptor, int start) {

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
Wed Feb  3 19:37:57 2010
@@ -20,16 +20,12 @@
 package org.apache.james.mime4j.stream;
 
 import org.apache.james.mime4j.MimeException;
-import org.apache.james.mime4j.parser.MaximalBodyDescriptor;
-import org.apache.james.mime4j.parser.MimeStreamParser;
-import org.apache.james.mime4j.parser.MimeTokenStream;
 
 /**
  * MIME entity configuration
  */
 public final class MimeEntityConfig implements Cloneable {
 
-    private boolean maximalBodyDescriptor;
     private boolean strictParsing;
     private int maxLineLen;
     private int maxHeaderCount;
@@ -40,7 +36,6 @@
     private boolean malformedHeaderStartsBody;
     
 	public MimeEntityConfig() {
-        this.maximalBodyDescriptor = false;
         this.strictParsing = false;
         this.maxLineLen = 1000;
         this.maxHeaderCount = 1000;
@@ -75,36 +70,6 @@
 	}
 
     /**
-     * Returns <code>true</code> if the maximum body descriptor should be
-     * used, <code>false</code> for the default body descriptor.
-     *
-     * @see #setMaximalBodyDescriptor(boolean)
-     *
-     * @return value of maximum body descriptor.
-     */
-    public boolean isMaximalBodyDescriptor() {
-        return this.maximalBodyDescriptor;
-    }
-
-    /**
-     * Specified whether the parser should use an instance of
-     * {@link MaximalBodyDescriptor} instead of {@link DefaultBodyDescriptor} to
-     * encapsulate the values of MIME-specific header fields.
-     * <p>
-     * The body descriptor can be retrieved by calling
-     * {@link MimeTokenStream#getBodyDescriptor()}.
-     * <p>
-     * Default value: <code>false</code>
-     *
-     * @param maximalBodyDescriptor <code>true</code> to use an instance of
-     *            {@link MaximalBodyDescriptor}, <code>false</code> for an
-     *            instance of {@link DefaultBodyDescriptor}.
-     */
-    public void setMaximalBodyDescriptor(boolean maximalBodyDescriptor) {
-        this.maximalBodyDescriptor = maximalBodyDescriptor;
-    }
-    
-    /**
      * Returns the value of the strict parsing mode
      * @see #setStrictParsing(boolean)
      * 
@@ -290,8 +255,7 @@
     
     @Override
     public String toString() {
-        return "[max body descriptor: " + maximalBodyDescriptor
-                + ", strict parsing: " + strictParsing + ", max line length: "
+        return "[strict parsing: " + strictParsing + ", max line length: "
                 + maxLineLen + ", max header count: " + maxHeaderCount
                 + ", max content length: " + maxContentLen
                 + ", count line numbers: " + countLineNumbers + "]";

Added: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java?rev=906202&view=auto
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
(added)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
Wed Feb  3 19:37:57 2010
@@ -0,0 +1,29 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.stream;
+
+/**
+ * {@link MutableBodyDescriptor} factory.
+ */
+public interface MutableBodyDescriptorFactory {
+
+    MutableBodyDescriptor newInstance();
+
+}

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptorFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java
Wed Feb  3 19:37:57 2010
@@ -27,6 +27,7 @@
 import org.apache.james.mime4j.parser.MimeTokenStream;
 import org.apache.james.mime4j.stream.BaseTestForBodyDescriptors;
 import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MutableBodyDescriptor;
 
 public class MaximalBodyDescriptorTest extends BaseTestForBodyDescriptors {
@@ -36,7 +37,9 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        parser = MimeTokenStream.createMaximalDescriptorStream();
+        MimeEntityConfig config = new MimeEntityConfig();
+        config.setStrictParsing(true);
+        parser = new MimeTokenStream(config, new MaximalBodyDescriptorFactory());
     }
 
     @Override

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java?rev=906202&r1=906201&r2=906202&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
Wed Feb  3 19:37:57 2010
@@ -34,8 +34,9 @@
     
     public void testUnexpectedEndOfHeaders() throws Exception {
         
-        MimeTokenStream parser = MimeTokenStream.createStrictValidationStream();
-        
+        MimeEntityConfig config = new MimeEntityConfig();
+        config.setStrictParsing(true);
+        MimeTokenStream parser = new MimeTokenStream(config);
         parser.parse(new ByteArrayInputStream(HEADER_ONLY.getBytes()));
         
         assertEquals("Headers start", MimeTokenStream.T_START_HEADER, parser.next());
@@ -50,7 +51,9 @@
     
     public void testCorrectEndOfHeaders() throws Exception {
         
-        MimeTokenStream parser = MimeTokenStream.createStrictValidationStream();
+        MimeEntityConfig config = new MimeEntityConfig();
+        config.setStrictParsing(true);
+        MimeTokenStream parser = new MimeTokenStream();
         
         parser.parse(new ByteArrayInputStream(CORRECT_HEADERS.getBytes()));
         



Mime
View raw message