Author: mwiederkehr
Date: Sat Jun 6 20:56:21 2009
New Revision: 782311
URL: http://svn.apache.org/viewvc?rev=782311&view=rev
Log:
fix for MIME4J-135: Minor tweaks to MimeException, MimeIOException and unit
tests for both
Added:
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeExceptionTest.java
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeIOExceptionTest.java
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeException.java
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeIOException.java
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeException.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeException.java?rev=782311&r1=782310&r2=782311&view=diff
==============================================================================
---
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeException.java
(original)
+++
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeException.java
Sat Jun 6 20:56:21 2009
@@ -51,8 +51,7 @@
* @param cause cause of the exception
*/
public MimeException(String message, Throwable cause) {
- super(message);
- initCause(cause);
+ super(message, cause);
}
}
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeIOException.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeIOException.java?rev=782311&r1=782310&r2=782311&view=diff
==============================================================================
---
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeIOException.java
(original)
+++
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/MimeIOException.java
Sat Jun 6 20:56:21 2009
@@ -31,8 +31,7 @@
/**
* Creates a new MimeIOException from the specified detail message.
*
- * @param message
- * detail message.
+ * @param message detail message.
*/
public MimeIOException(String message) {
this(new MimeException(message));
@@ -41,12 +40,11 @@
/**
* Constructs an IO exception based on {...@link MimeException}.
*
- * @param cause
- * the cause.
+ * @param cause the cause.
*/
public MimeIOException(MimeException cause) {
- super(cause.getMessage());
- initCause(cause);
+ super(cause == null ? null : cause.getMessage());
+ initCause(cause);
}
}
Added:
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeExceptionTest.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeExceptionTest.java?rev=782311&view=auto
==============================================================================
---
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeExceptionTest.java
(added)
+++
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeExceptionTest.java
Sat Jun 6 20:56:21 2009
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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;
+
+import junit.framework.TestCase;
+
+public class MimeExceptionTest extends TestCase {
+
+ public void testMimeExceptionString() {
+ MimeException e = new MimeException("message");
+ assertEquals("message", e.getMessage());
+ assertNull(e.getCause());
+ }
+
+ public void testMimeExceptionThrowable() {
+ NullPointerException npe = new NullPointerException("npe");
+ MimeException e = new MimeException(npe);
+ assertSame(npe, e.getCause());
+ assertNotNull(e.getMessage());
+ }
+
+ public void testMimeExceptionStringThrowable() {
+ NullPointerException npe = new NullPointerException("npe");
+ MimeException e = new MimeException("message",npe);
+ assertEquals("message", e.getMessage());
+ assertSame(npe, e.getCause());
+ }
+
+}
Added:
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeIOExceptionTest.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeIOExceptionTest.java?rev=782311&view=auto
==============================================================================
---
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeIOExceptionTest.java
(added)
+++
james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/MimeIOExceptionTest.java
Sat Jun 6 20:56:21 2009
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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;
+
+import junit.framework.TestCase;
+
+public class MimeIOExceptionTest extends TestCase {
+
+ public void testMimeIOExceptionString() {
+ MimeIOException e = new MimeIOException("message");
+ assertEquals("message", e.getMessage());
+ assertNotNull(e.getCause());
+ assertTrue(e.getCause() instanceof MimeException);
+ assertEquals("message", e.getCause().getMessage());
+ }
+
+ public void testMimeIOExceptionMimeException() {
+ MimeException cause = new MimeException("cause");
+ MimeIOException e = new MimeIOException(cause);
+ assertEquals("cause", e.getMessage());
+ assertSame(cause, e.getCause());
+ }
+
+}