You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/01/23 18:15:48 UTC

svn commit: r1560762 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Author: britter
Date: Thu Jan 23 17:15:48 2014
New Revision: 1560762

URL: http://svn.apache.org/r1560762
Log:
Keep tests for Levenshtein Distance together

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1560762&r1=1560761&r2=1560762&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java Thu Jan 23 17:15:48 2014
@@ -1901,20 +1901,18 @@ public class StringUtilsTest {
         assertEquals(8, StringUtils.getLevenshteinDistance("hippo", "zzzzzzzz") );
         assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo") );
         assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo") );
-        try {
-            StringUtils.getLevenshteinDistance("a", null);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
-        try {
-            StringUtils.getLevenshteinDistance(null, "a");
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
     }
-    
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetLevenshteinDistance_NullString() throws Exception {
+        StringUtils.getLevenshteinDistance("a", null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetLevenshteinDistance_StringNull() throws Exception {
+        StringUtils.getLevenshteinDistance(null, "a");
+    }
+
     @Test
     public void testGetLevenshteinDistance_StringStringInt() {
         // empty strings
@@ -1976,33 +1974,26 @@ public class StringUtilsTest {
         assertEquals(7, StringUtils.getLevenshteinDistance("hippo", "elephant", Integer.MAX_VALUE) );
         assertEquals(8, StringUtils.getLevenshteinDistance("hippo", "zzzzzzzz", Integer.MAX_VALUE) );
         assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo", Integer.MAX_VALUE) );
-        assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo", Integer.MAX_VALUE) );
+        assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo", Integer.MAX_VALUE));
+    }
 
-        // exceptions
-        try {
-            StringUtils.getLevenshteinDistance("a", null, 0);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
-        try {
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetLevenshteinDistance_NullStringInt() throws Exception {
             StringUtils.getLevenshteinDistance(null, "a", 0);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
+    }
 
-        try {
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetLevenshteinDistance_StringNullInt() throws Exception {
+            StringUtils.getLevenshteinDistance("a", null, 0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetLevenshteinDistance_StringStringNegativeInt() throws Exception {
             StringUtils.getLevenshteinDistance("a", "a", -1);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
     }
 
     @Test
     public void testGetJaroWinklerDistance_StringString() {
-
         assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog", "fog"), 0.0d);
         assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly", "ant"), 0.0d);
         assertEquals(0.44d, StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
@@ -2010,26 +2001,21 @@ public class StringUtilsTest {
         assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
         assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
         assertEquals(0.9d, StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
-        // exceptions
-        try {
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetJaroWinklerDistance_NullNull() throws Exception {
             StringUtils.getJaroWinklerDistance(null, null);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
+    }
 
-        try {
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetJaroWinklerDistance_StringNull() throws Exception {
             StringUtils.getJaroWinklerDistance(" ", null);
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
-        try {
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetJaroWinklerDistance_NullString() throws Exception {
             StringUtils.getJaroWinklerDistance(null, "clear");
-            fail("expecting IllegalArgumentException");
-        } catch (final IllegalArgumentException ex) {
-            // empty
-        }
     }
 
     /**



Re: svn commit: r1560762 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Posted by Benedikt Ritter <be...@gmail.com>.
Figured, it out myself.

Thanks :)

Send from my mobile device

> Am 25.01.2014 um 18:26 schrieb Henri Yandell <fl...@gmail.com>:
> 
> In case you didn't get an answer here:
> 
> http://stackoverflow.com/questions/304383/how-do-i-edit-a-log-message-that-i-already-committed-in-subversion
> 
> $svn propedit -r N --revprop svn:log URL
> $svn propset -r N --revprop svn:log "new log message" URL
> 
> 
> 
>> On Thu, Jan 23, 2014 at 9:17 AM, Benedikt Ritter <br...@apache.org> wrote:
>> 
>> Sorry, I messed that one up. I wanted to call mvn clean test but instead
>> committed with the some message as one before. Should be "Use annotation
>> based testing for failure cases". Is there any way to modify the commit
>> log?
>> 
>> Benedikt
>> 
>> 
>> 2014/1/23 <br...@apache.org>
>> 
>>> Author: britter
>>> Date: Thu Jan 23 17:15:48 2014
>>> New Revision: 1560762
>>> 
>>> URL: http://svn.apache.org/r1560762
>>> Log:
>>> Keep tests for Levenshtein Distance together
>>> 
>>> Modified:
>> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
>>> 
>>> Modified:
>> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
>>> URL:
>> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1560762&r1=1560761&r2=1560762&view=diff
>> ==============================================================================
>>> ---
>> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
>>> (original)
>>> +++
>> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
>>> Thu Jan 23 17:15:48 2014
>>> @@ -1901,20 +1901,18 @@ public class StringUtilsTest {
>>>         assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
>>> "zzzzzzzz") );
>>>         assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
>>> "hippo") );
>>>         assertEquals(1, StringUtils.getLevenshteinDistance("hello",
>>> "hallo") );
>>> -        try {
>>> -            StringUtils.getLevenshteinDistance("a", null);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>> -        try {
>>> -            StringUtils.getLevenshteinDistance(null, "a");
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>>     }
>>> -
>>> +
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetLevenshteinDistance_NullString() throws
>> Exception {
>>> +        StringUtils.getLevenshteinDistance("a", null);
>>> +    }
>>> +
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetLevenshteinDistance_StringNull() throws
>> Exception {
>>> +        StringUtils.getLevenshteinDistance(null, "a");
>>> +    }
>>> +
>>>     @Test
>>>     public void testGetLevenshteinDistance_StringStringInt() {
>>>         // empty strings
>>> @@ -1976,33 +1974,26 @@ public class StringUtilsTest {
>>>         assertEquals(7, StringUtils.getLevenshteinDistance("hippo",
>>> "elephant", Integer.MAX_VALUE) );
>>>         assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
>>> "zzzzzzzz", Integer.MAX_VALUE) );
>>>         assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
>>> "hippo", Integer.MAX_VALUE) );
>>> -        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
>>> "hallo", Integer.MAX_VALUE) );
>>> +        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
>>> "hallo", Integer.MAX_VALUE));
>>> +    }
>>> 
>>> -        // exceptions
>>> -        try {
>>> -            StringUtils.getLevenshteinDistance("a", null, 0);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>> -        try {
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetLevenshteinDistance_NullStringInt() throws
>>> Exception {
>>>             StringUtils.getLevenshteinDistance(null, "a", 0);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>> +    }
>>> 
>>> -        try {
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetLevenshteinDistance_StringNullInt() throws
>>> Exception {
>>> +            StringUtils.getLevenshteinDistance("a", null, 0);
>>> +    }
>>> +
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetLevenshteinDistance_StringStringNegativeInt()
>>> throws Exception {
>>>             StringUtils.getLevenshteinDistance("a", "a", -1);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>>     }
>>> 
>>>     @Test
>>>     public void testGetJaroWinklerDistance_StringString() {
>>> -
>>>         assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog",
>>> "fog"), 0.0d);
>>>         assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly",
>>> "ant"), 0.0d);
>>>         assertEquals(0.44d,
>>> StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
>>> @@ -2010,26 +2001,21 @@ public class StringUtilsTest {
>>>         assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H
>>> Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
>>>         assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym
>>> Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
>>>         assertEquals(0.9d,
>>> StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"),
>> 0.0d);
>>> -        // exceptions
>>> -        try {
>>> +    }
>>> +
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetJaroWinklerDistance_NullNull() throws Exception {
>>>             StringUtils.getJaroWinklerDistance(null, null);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>> +    }
>>> 
>>> -        try {
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetJaroWinklerDistance_StringNull() throws
>> Exception {
>>>             StringUtils.getJaroWinklerDistance(" ", null);
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>> -        try {
>>> +    }
>>> +
>>> +    @Test(expected = IllegalArgumentException.class)
>>> +    public void testGetJaroWinklerDistance_NullString() throws
>> Exception {
>>>             StringUtils.getJaroWinklerDistance(null, "clear");
>>> -            fail("expecting IllegalArgumentException");
>>> -        } catch (final IllegalArgumentException ex) {
>>> -            // empty
>>> -        }
>>>     }
>>> 
>>>     /**
>> 
>> 
>> --
>> http://people.apache.org/~britter/
>> http://www.systemoutprintln.de/
>> http://twitter.com/BenediktRitter
>> http://github.com/britter
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1560762 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Posted by Henri Yandell <fl...@gmail.com>.
In case you didn't get an answer here:

http://stackoverflow.com/questions/304383/how-do-i-edit-a-log-message-that-i-already-committed-in-subversion

$svn propedit -r N --revprop svn:log URL
$svn propset -r N --revprop svn:log "new log message" URL



On Thu, Jan 23, 2014 at 9:17 AM, Benedikt Ritter <br...@apache.org> wrote:

> Sorry, I messed that one up. I wanted to call mvn clean test but instead
> committed with the some message as one before. Should be "Use annotation
> based testing for failure cases". Is there any way to modify the commit
> log?
>
> Benedikt
>
>
> 2014/1/23 <br...@apache.org>
>
> > Author: britter
> > Date: Thu Jan 23 17:15:48 2014
> > New Revision: 1560762
> >
> > URL: http://svn.apache.org/r1560762
> > Log:
> > Keep tests for Levenshtein Distance together
> >
> > Modified:
> >
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> >
> > Modified:
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1560762&r1=1560761&r2=1560762&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> > (original)
> > +++
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> > Thu Jan 23 17:15:48 2014
> > @@ -1901,20 +1901,18 @@ public class StringUtilsTest {
> >          assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
> > "zzzzzzzz") );
> >          assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
> > "hippo") );
> >          assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> > "hallo") );
> > -        try {
> > -            StringUtils.getLevenshteinDistance("a", null);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> > -        try {
> > -            StringUtils.getLevenshteinDistance(null, "a");
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> >      }
> > -
> > +
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetLevenshteinDistance_NullString() throws
> Exception {
> > +        StringUtils.getLevenshteinDistance("a", null);
> > +    }
> > +
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetLevenshteinDistance_StringNull() throws
> Exception {
> > +        StringUtils.getLevenshteinDistance(null, "a");
> > +    }
> > +
> >      @Test
> >      public void testGetLevenshteinDistance_StringStringInt() {
> >          // empty strings
> > @@ -1976,33 +1974,26 @@ public class StringUtilsTest {
> >          assertEquals(7, StringUtils.getLevenshteinDistance("hippo",
> > "elephant", Integer.MAX_VALUE) );
> >          assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
> > "zzzzzzzz", Integer.MAX_VALUE) );
> >          assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
> > "hippo", Integer.MAX_VALUE) );
> > -        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> > "hallo", Integer.MAX_VALUE) );
> > +        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> > "hallo", Integer.MAX_VALUE));
> > +    }
> >
> > -        // exceptions
> > -        try {
> > -            StringUtils.getLevenshteinDistance("a", null, 0);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> > -        try {
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetLevenshteinDistance_NullStringInt() throws
> > Exception {
> >              StringUtils.getLevenshteinDistance(null, "a", 0);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> > +    }
> >
> > -        try {
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetLevenshteinDistance_StringNullInt() throws
> > Exception {
> > +            StringUtils.getLevenshteinDistance("a", null, 0);
> > +    }
> > +
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetLevenshteinDistance_StringStringNegativeInt()
> > throws Exception {
> >              StringUtils.getLevenshteinDistance("a", "a", -1);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> >      }
> >
> >      @Test
> >      public void testGetJaroWinklerDistance_StringString() {
> > -
> >          assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog",
> > "fog"), 0.0d);
> >          assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly",
> > "ant"), 0.0d);
> >          assertEquals(0.44d,
> > StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
> > @@ -2010,26 +2001,21 @@ public class StringUtilsTest {
> >          assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H
> > Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
> >          assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym
> > Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
> >          assertEquals(0.9d,
> > StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"),
> 0.0d);
> > -        // exceptions
> > -        try {
> > +    }
> > +
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetJaroWinklerDistance_NullNull() throws Exception {
> >              StringUtils.getJaroWinklerDistance(null, null);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> > +    }
> >
> > -        try {
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetJaroWinklerDistance_StringNull() throws
> Exception {
> >              StringUtils.getJaroWinklerDistance(" ", null);
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> > -        try {
> > +    }
> > +
> > +    @Test(expected = IllegalArgumentException.class)
> > +    public void testGetJaroWinklerDistance_NullString() throws
> Exception {
> >              StringUtils.getJaroWinklerDistance(null, "clear");
> > -            fail("expecting IllegalArgumentException");
> > -        } catch (final IllegalArgumentException ex) {
> > -            // empty
> > -        }
> >      }
> >
> >      /**
> >
> >
> >
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>

Re: svn commit: r1560762 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Posted by Benedikt Ritter <br...@apache.org>.
Sorry, I messed that one up. I wanted to call mvn clean test but instead
committed with the some message as one before. Should be "Use annotation
based testing for failure cases". Is there any way to modify the commit log?

Benedikt


2014/1/23 <br...@apache.org>

> Author: britter
> Date: Thu Jan 23 17:15:48 2014
> New Revision: 1560762
>
> URL: http://svn.apache.org/r1560762
> Log:
> Keep tests for Levenshtein Distance together
>
> Modified:
>
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
>
> Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1560762&r1=1560761&r2=1560762&view=diff
>
> ==============================================================================
> ---
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> (original)
> +++
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
> Thu Jan 23 17:15:48 2014
> @@ -1901,20 +1901,18 @@ public class StringUtilsTest {
>          assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
> "zzzzzzzz") );
>          assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
> "hippo") );
>          assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> "hallo") );
> -        try {
> -            StringUtils.getLevenshteinDistance("a", null);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
> -        try {
> -            StringUtils.getLevenshteinDistance(null, "a");
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
>      }
> -
> +
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetLevenshteinDistance_NullString() throws Exception {
> +        StringUtils.getLevenshteinDistance("a", null);
> +    }
> +
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetLevenshteinDistance_StringNull() throws Exception {
> +        StringUtils.getLevenshteinDistance(null, "a");
> +    }
> +
>      @Test
>      public void testGetLevenshteinDistance_StringStringInt() {
>          // empty strings
> @@ -1976,33 +1974,26 @@ public class StringUtilsTest {
>          assertEquals(7, StringUtils.getLevenshteinDistance("hippo",
> "elephant", Integer.MAX_VALUE) );
>          assertEquals(8, StringUtils.getLevenshteinDistance("hippo",
> "zzzzzzzz", Integer.MAX_VALUE) );
>          assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz",
> "hippo", Integer.MAX_VALUE) );
> -        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> "hallo", Integer.MAX_VALUE) );
> +        assertEquals(1, StringUtils.getLevenshteinDistance("hello",
> "hallo", Integer.MAX_VALUE));
> +    }
>
> -        // exceptions
> -        try {
> -            StringUtils.getLevenshteinDistance("a", null, 0);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
> -        try {
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetLevenshteinDistance_NullStringInt() throws
> Exception {
>              StringUtils.getLevenshteinDistance(null, "a", 0);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
> +    }
>
> -        try {
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetLevenshteinDistance_StringNullInt() throws
> Exception {
> +            StringUtils.getLevenshteinDistance("a", null, 0);
> +    }
> +
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetLevenshteinDistance_StringStringNegativeInt()
> throws Exception {
>              StringUtils.getLevenshteinDistance("a", "a", -1);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
>      }
>
>      @Test
>      public void testGetJaroWinklerDistance_StringString() {
> -
>          assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog",
> "fog"), 0.0d);
>          assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly",
> "ant"), 0.0d);
>          assertEquals(0.44d,
> StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
> @@ -2010,26 +2001,21 @@ public class StringUtilsTest {
>          assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H
> Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
>          assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym
> Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
>          assertEquals(0.9d,
> StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
> -        // exceptions
> -        try {
> +    }
> +
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetJaroWinklerDistance_NullNull() throws Exception {
>              StringUtils.getJaroWinklerDistance(null, null);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
> +    }
>
> -        try {
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetJaroWinklerDistance_StringNull() throws Exception {
>              StringUtils.getJaroWinklerDistance(" ", null);
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
> -        try {
> +    }
> +
> +    @Test(expected = IllegalArgumentException.class)
> +    public void testGetJaroWinklerDistance_NullString() throws Exception {
>              StringUtils.getJaroWinklerDistance(null, "clear");
> -            fail("expecting IllegalArgumentException");
> -        } catch (final IllegalArgumentException ex) {
> -            // empty
> -        }
>      }
>
>      /**
>
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter