You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2007/10/13 00:26:27 UTC

svn commit: r584302 - in /commons/proper/io/trunk/src: java/org/apache/commons/io/filefilter/RegexFilter.java test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Author: niallp
Date: Fri Oct 12 15:26:24 2007
New Revision: 584302

URL: http://svn.apache.org/viewvc?rev=584302&view=rev
Log:
Add messages to IllegalArgumentExceptions, add tests for thrown expections

Modified:
    commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/RegexFilter.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/RegexFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/RegexFilter.java?rev=584302&r1=584301&r2=584302&view=diff
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/RegexFilter.java (original)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/RegexFilter.java Fri Oct 12 15:26:24 2007
@@ -54,7 +54,7 @@
      */
     public RegexFilter(String pattern) {
         if (pattern == null) {
-            throw new java.lang.IllegalArgumentException();
+            throw new IllegalArgumentException("Pattern is missing");
         }
 
         this.pattern = Pattern.compile(pattern);
@@ -69,7 +69,7 @@
      */
     public RegexFilter(String pattern, IOCase caseSensitivity) {
         if (pattern == null) {
-            throw new java.lang.IllegalArgumentException();
+            throw new IllegalArgumentException("Pattern is missing");
         }
         int flags = 0;
         if (caseSensitivity != null && !caseSensitivity.isCaseSensitive()) {
@@ -87,7 +87,7 @@
      */
     public RegexFilter(String pattern, int flags) {
         if (pattern == null) {
-            throw new java.lang.IllegalArgumentException();
+            throw new IllegalArgumentException("Pattern is missing");
         }
         this.pattern = Pattern.compile(pattern, flags);
     }
@@ -100,7 +100,7 @@
      */
     public RegexFilter(Pattern pattern) {
         if (pattern == null) {
-            throw new java.lang.IllegalArgumentException();
+            throw new IllegalArgumentException("Pattern is missing");
         }
 
         this.pattern = pattern;

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=584302&r1=584301&r2=584302&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java Fri Oct 12 15:26:24 2007
@@ -847,6 +847,34 @@
         assertFiltering(filter, new File("Test.java"), true);
         assertFiltering(filter, new File("test.java"), true);
         assertFiltering(filter, new File("tEST.java"), true);
+
+        try {
+            FileFilterUtils.regex((String)null);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            FileFilterUtils.regex((String)null, Pattern.CASE_INSENSITIVE);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            FileFilterUtils.regex((String)null, IOCase.INSENSITIVE);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            new RegexFilter((java.util.regex.Pattern)null);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
     }
 
     //-----------------------------------------------------------------------