commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r606340 - in /commons/proper/io/trunk/src: java/org/apache/commons/io/CausedIOException.java test/org/apache/commons/io/CausedIOExceptionTestCase.java test/org/apache/commons/io/PackageTestSuite.java
Date Fri, 21 Dec 2007 22:49:56 GMT
Author: ggregory
Date: Fri Dec 21 14:49:55 2007
New Revision: 606340

URL: http://svn.apache.org/viewvc?rev=606340&view=rev
Log:
A first cut on [IO-148] IOException with constructors which take a cause. Only one constructor
implemented. Class name up for discussion.

Added:
    commons/proper/io/trunk/src/java/org/apache/commons/io/CausedIOException.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/CausedIOExceptionTestCase.java
Modified:
    commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java

Added: commons/proper/io/trunk/src/java/org/apache/commons/io/CausedIOException.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/CausedIOException.java?rev=606340&view=auto
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/CausedIOException.java (added)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/CausedIOException.java Fri Dec
21 14:49:55 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.commons.io;
+
+import java.io.IOException;
+
+/**
+ * Subclasses IOException with the {@link Throwable} constructor was missing before Java
6.
+ * 
+ * @see <a href="mailto:commons-user@jakarta.apache.org">Apache Commons Users List</a>
+ * @author <a href="http://commons.apache.org/io/">Apache Commons IO</a>
+ * @version $Id: $
+ */
+public class CausedIOException extends IOException {
+
+    /**
+     * Default serial version UID.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Creates an instance with the given message and cause.
+     * <p>
+     * This constructor was not added in the underlying {@link IOException} class until Java
6. This is a convenience
+     * method which uses the {@link #initCause(Throwable)} method to set the root cause.
+     * 
+     * @param message
+     *            exception message
+     * @param cause
+     *            root cause
+     */
+    public CausedIOException(String message, Throwable cause) {
+        super(message);
+        this.initCause(cause);
+    }
+
+}

Added: commons/proper/io/trunk/src/test/org/apache/commons/io/CausedIOExceptionTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/CausedIOExceptionTestCase.java?rev=606340&view=auto
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/CausedIOExceptionTestCase.java
(added)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/CausedIOExceptionTestCase.java
Fri Dec 21 14:49:55 2007
@@ -0,0 +1,40 @@
+/*
+ * 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.commons.io;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests CausedIOException
+ * 
+ * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
+ * @version $Id: $
+ */
+public class CausedIOExceptionTestCase extends TestCase {
+
+    /**
+     * Tests the {@link CausedIOException#CausedIOException(String,Throwable)} constructor.
+     */
+    public void testIOExceptionStringThrowable() {
+        Throwable cause = new IllegalArgumentException("cause");
+        CausedIOException exception = new CausedIOException("message", cause);
+        assertEquals("message", exception.getMessage());
+        assertEquals(cause, exception.getCause());
+        assertSame(cause, exception.getCause());
+    }
+}

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java?rev=606340&r1=606339&r2=606340&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java Fri Dec 21
14:49:55 2007
@@ -35,6 +35,7 @@
 
     public static Test suite() {
         TestSuite suite = new TestSuite("IO Utilities");
+        suite.addTest(new TestSuite(CausedIOExceptionTestCase.class));
         suite.addTest(new TestSuite(CopyUtilsTest.class));
         suite.addTest(new TestSuite(DemuxTestCase.class));
         suite.addTest(new TestSuite(DirectoryWalkerTestCase.class));



Mime
View raw message