You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ie...@apache.org on 2012/03/12 01:32:30 UTC

svn commit: r1299502 - in /james/server/trunk: cli/src/test/java/org/apache/james/cli/type/ util/src/test/java/org/apache/james/util/ util/src/test/java/org/apache/james/util/retry/ util/src/test/java/org/apache/james/util/retry/naming/

Author: ieugen
Date: Mon Mar 12 00:32:30 2012
New Revision: 1299502

URL: http://svn.apache.org/viewvc?rev=1299502&view=rev
Log:
JAMES-1393

- updated tests to juni 4.x style
- added @Override and reformated code
Issue #JAMES-1393 - Upgrate all test suites to junit 4.10

Modified:
    james/server/trunk/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
    james/server/trunk/util/src/test/java/org/apache/james/util/TimeConverterTest.java
    james/server/trunk/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
    james/server/trunk/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
    james/server/trunk/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java

Modified: james/server/trunk/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java?rev=1299502&r1=1299501&r2=1299502&view=diff
==============================================================================
--- james/server/trunk/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java (original)
+++ james/server/trunk/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java Mon Mar 12 00:32:30 2012
@@ -18,72 +18,75 @@
  ****************************************************************/
 package org.apache.james.cli.type;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
 
 /**
  * Test class for the CmdType enum.
  */
-public class CmdTypeTest extends TestCase {
-    
+public class CmdTypeTest {
+
     /**
      * Test the hasCorrectArguments method.
      */
+    @Test
     public void testHasCorrectArguments() {
-        CmdType cmd;
-        boolean result;
+	CmdType cmd;
+	boolean result;
 
-        cmd = CmdType.ADDDOMAIN;
+	cmd = CmdType.ADDDOMAIN;
 
-        // Test bogus number
-        result = cmd.hasCorrectArguments(-1);
-        assertEquals(false, result);
-
-        // Test actual number
-        result = cmd.hasCorrectArguments(cmd.getArguments());
-        assertEquals(true, result);
-
-        // Test known bad number
-        result = cmd.hasCorrectArguments(cmd.getArguments() - 1);
-        assertEquals(false, result);
+	// Test bogus number
+	result = cmd.hasCorrectArguments(-1);
+	assertEquals(false, result);
+
+	// Test actual number
+	result = cmd.hasCorrectArguments(cmd.getArguments());
+	assertEquals(true, result);
+
+	// Test known bad number
+	result = cmd.hasCorrectArguments(cmd.getArguments() - 1);
+	assertEquals(false, result);
     }
 
     /**
      * Test the lookup method.
      */
+    @Test
     public void testLookup() {
-        CmdType result;
+	CmdType result;
+
+	// Test happy path
+	result = CmdType.lookup(CmdType.ADDUSER.getCommand());
+	assertEquals(CmdType.ADDUSER, result);
 
-        // Test happy path
-        result = CmdType.lookup(CmdType.ADDUSER.getCommand());
-        assertEquals(CmdType.ADDUSER, result);
+	result = CmdType.lookup(CmdType.REMOVEUSER.getCommand());
+	assertEquals(CmdType.REMOVEUSER, result);
 
-        result = CmdType.lookup(CmdType.REMOVEUSER.getCommand());
-        assertEquals(CmdType.REMOVEUSER, result);
+	result = CmdType.lookup(CmdType.LISTUSERS.getCommand());
+	assertEquals(CmdType.LISTUSERS, result);
 
-        result = CmdType.lookup(CmdType.LISTUSERS.getCommand());
-        assertEquals(CmdType.LISTUSERS, result);
+	result = CmdType.lookup(CmdType.ADDDOMAIN.getCommand());
+	assertEquals(CmdType.ADDDOMAIN, result);
 
-        result = CmdType.lookup(CmdType.ADDDOMAIN.getCommand());
-        assertEquals(CmdType.ADDDOMAIN, result);
+	result = CmdType.lookup(CmdType.REMOVEDOMAIN.getCommand());
+	assertEquals(CmdType.REMOVEDOMAIN, result);
 
-        result = CmdType.lookup(CmdType.REMOVEDOMAIN.getCommand());
-        assertEquals(CmdType.REMOVEDOMAIN, result);
+	result = CmdType.lookup(CmdType.LISTDOMAINS.getCommand());
+	assertEquals(CmdType.LISTDOMAINS, result);
 
-        result = CmdType.lookup(CmdType.LISTDOMAINS.getCommand());
-        assertEquals(CmdType.LISTDOMAINS, result);
-        
-        result = CmdType.lookup(CmdType.SETPASSWORD.getCommand());
-        assertEquals(CmdType.SETPASSWORD, result);
+	result = CmdType.lookup(CmdType.SETPASSWORD.getCommand());
+	assertEquals(CmdType.SETPASSWORD, result);
 
-        // Test known bad value
-        result = CmdType.lookup("");
-        assertEquals(null, result);
+	// Test known bad value
+	result = CmdType.lookup("");
+	assertEquals(null, result);
 
-        result = CmdType.lookup("error");
-        assertEquals(null, result);
+	result = CmdType.lookup("error");
+	assertEquals(null, result);
 
-        // Test null value
-        result = CmdType.lookup(null);
-        assertEquals(null, result);
+	// Test null value
+	result = CmdType.lookup(null);
+	assertEquals(null, result);
     }
 }
\ No newline at end of file

Modified: james/server/trunk/util/src/test/java/org/apache/james/util/TimeConverterTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/test/java/org/apache/james/util/TimeConverterTest.java?rev=1299502&r1=1299501&r2=1299502&view=diff
==============================================================================
--- james/server/trunk/util/src/test/java/org/apache/james/util/TimeConverterTest.java (original)
+++ james/server/trunk/util/src/test/java/org/apache/james/util/TimeConverterTest.java Mon Mar 12 00:32:30 2012
@@ -16,120 +16,128 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.util;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
 
-public class TimeConverterTest extends TestCase {
+public class TimeConverterTest {
 
     private final long AMOUNT = 2;
 
-    public TimeConverterTest(String arg0) {
-        super(arg0);
-    }
-
+    @Test
     public void testGetMilliSecondsMsec() {
-        long time = 2;
-        String unit = "msec";
+	long time = 2;
+	String unit = "msec";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsMsecs() {
-        long time = 2;
-        String unit = "msecs";
+	long time = 2;
+	String unit = "msecs";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsSec() {
-        long time = 2000;
-        String unit = "sec";
+	long time = 2000;
+	String unit = "sec";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsSecs() {
-        long time = 2000;
-        String unit = "secs";
+	long time = 2000;
+	String unit = "secs";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsMinute() {
-        long time = 120000;
-        String unit = "minute";
+	long time = 120000;
+	String unit = "minute";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsMinutes() {
-        long time = 120000;
-        String unit = "minutes";
+	long time = 120000;
+	String unit = "minutes";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsHour() {
-        long time = 7200000;
-        String unit = "hour";
+	long time = 7200000;
+	String unit = "hour";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsHours() {
-        long time = 7200000;
-        String unit = "hours";
+	long time = 7200000;
+	String unit = "hours";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsDay() {
-        long time = 172800000;
-        String unit = "day";
+	long time = 172800000;
+	String unit = "day";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testGetMilliSecondsDays() {
-        long time = 172800000;
-        String unit = "days";
+	long time = 172800000;
+	String unit = "days";
 
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
-        assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT, unit), time);
+	assertEquals(TimeConverter.getMilliSeconds(AMOUNT + " " + unit), time);
     }
 
+    @Test
     public void testIllegalUnit() {
-        boolean exceptionThrown = false;
-        try {
-            TimeConverter.getMilliSeconds(2, "week");
-            TimeConverter.getMilliSeconds(2 + " week");
-        } catch (NumberFormatException e) {
-            exceptionThrown = true;
-        }
+	boolean exceptionThrown = false;
+	try {
+	    TimeConverter.getMilliSeconds(2, "week");
+	    TimeConverter.getMilliSeconds(2 + " week");
+	} catch (NumberFormatException e) {
+	    exceptionThrown = true;
+	}
 
-        assertTrue(exceptionThrown);
+	assertTrue(exceptionThrown);
     }
 
+    @Test
     public void testIllegalPattern() {
-        boolean exceptionThrown = false;
-        try {
-            TimeConverter.getMilliSeconds("illegal pattern");
-        } catch (NumberFormatException e) {
-            exceptionThrown = true;
-        }
+	boolean exceptionThrown = false;
+	try {
+	    TimeConverter.getMilliSeconds("illegal pattern");
+	} catch (NumberFormatException e) {
+	    exceptionThrown = true;
+	}
 
-        assertTrue(exceptionThrown);
+	assertTrue(exceptionThrown);
     }
-
 }

Modified: james/server/trunk/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java?rev=1299502&r1=1299501&r2=1299502&view=diff
==============================================================================
--- james/server/trunk/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java (original)
+++ james/server/trunk/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java Mon Mar 12 00:32:30 2012
@@ -17,65 +17,66 @@
  *   under the License.
  *
  */
-
 package org.apache.james.util.retry;
 
-
 import org.apache.james.util.retry.api.RetrySchedule;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
 /**
  * <code>DoublingRetryScheduleTest</code>
  */
-public class DoublingRetryScheduleTest extends TestCase {
+public class DoublingRetryScheduleTest {
 
     /**
      * Test method for {@link org.apache.james.user.ldap.DoublingRetrySchedule#DoublingRetrySchedule(long, long)}.
      */
+    @Test
     public final void testDoublingRetrySchedule() {
-        assertTrue(RetrySchedule.class.isAssignableFrom(new DoublingRetrySchedule(0,0).getClass()));
-        assertEquals(0, new DoublingRetrySchedule(0, 0).getInterval(0));
-        assertEquals(0, new DoublingRetrySchedule(-1, -1).getInterval(0));
-        assertEquals(0, new DoublingRetrySchedule(-1, 0).getInterval(0));
-        assertEquals(0, new DoublingRetrySchedule(0, -1).getInterval(0));
+	assertTrue(RetrySchedule.class.isAssignableFrom(new DoublingRetrySchedule(0, 0).getClass()));
+	assertEquals(0, new DoublingRetrySchedule(0, 0).getInterval(0));
+	assertEquals(0, new DoublingRetrySchedule(-1, -1).getInterval(0));
+	assertEquals(0, new DoublingRetrySchedule(-1, 0).getInterval(0));
+	assertEquals(0, new DoublingRetrySchedule(0, -1).getInterval(0));
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.DoublingRetrySchedule#getInterval(int)}.
      */
+    @Test
     public final void testGetInterval() {
-        assertEquals(0, new DoublingRetrySchedule(0, 8).getInterval(0));
-        assertEquals(1, new DoublingRetrySchedule(0, 8).getInterval(1));
-        assertEquals(2, new DoublingRetrySchedule(0, 8).getInterval(2));
-        assertEquals(4, new DoublingRetrySchedule(0, 8).getInterval(3));
-        assertEquals(8, new DoublingRetrySchedule(0, 8).getInterval(4));
-        assertEquals(8, new DoublingRetrySchedule(0, 8).getInterval(5));
-        
-        assertEquals(1, new DoublingRetrySchedule(1, 8).getInterval(0));
-        assertEquals(2, new DoublingRetrySchedule(1, 8).getInterval(1));
-        assertEquals(4, new DoublingRetrySchedule(1, 8).getInterval(2));
-        assertEquals(8, new DoublingRetrySchedule(1, 8).getInterval(3));
-        assertEquals(8, new DoublingRetrySchedule(1, 8).getInterval(4));
-        
-        assertEquals(3, new DoublingRetrySchedule(3, 12).getInterval(0));
-        assertEquals(6, new DoublingRetrySchedule(3, 12).getInterval(1));
-        assertEquals(12, new DoublingRetrySchedule(3, 12).getInterval(2));
-        assertEquals(12, new DoublingRetrySchedule(3, 12).getInterval(3));
-        
-        assertEquals(0, new DoublingRetrySchedule(0, 8, 1000).getInterval(0));
-        assertEquals(1000, new DoublingRetrySchedule(0, 8, 1000).getInterval(1));
-        assertEquals(2000, new DoublingRetrySchedule(0, 8, 1000).getInterval(2));
-        assertEquals(4000, new DoublingRetrySchedule(0, 8, 1000).getInterval(3));
-        assertEquals(8000, new DoublingRetrySchedule(0, 8, 1000).getInterval(4));
-        assertEquals(8000, new DoublingRetrySchedule(0, 8, 1000).getInterval(5));
+	assertEquals(0, new DoublingRetrySchedule(0, 8).getInterval(0));
+	assertEquals(1, new DoublingRetrySchedule(0, 8).getInterval(1));
+	assertEquals(2, new DoublingRetrySchedule(0, 8).getInterval(2));
+	assertEquals(4, new DoublingRetrySchedule(0, 8).getInterval(3));
+	assertEquals(8, new DoublingRetrySchedule(0, 8).getInterval(4));
+	assertEquals(8, new DoublingRetrySchedule(0, 8).getInterval(5));
+
+	assertEquals(1, new DoublingRetrySchedule(1, 8).getInterval(0));
+	assertEquals(2, new DoublingRetrySchedule(1, 8).getInterval(1));
+	assertEquals(4, new DoublingRetrySchedule(1, 8).getInterval(2));
+	assertEquals(8, new DoublingRetrySchedule(1, 8).getInterval(3));
+	assertEquals(8, new DoublingRetrySchedule(1, 8).getInterval(4));
+
+	assertEquals(3, new DoublingRetrySchedule(3, 12).getInterval(0));
+	assertEquals(6, new DoublingRetrySchedule(3, 12).getInterval(1));
+	assertEquals(12, new DoublingRetrySchedule(3, 12).getInterval(2));
+	assertEquals(12, new DoublingRetrySchedule(3, 12).getInterval(3));
+
+	assertEquals(0, new DoublingRetrySchedule(0, 8, 1000).getInterval(0));
+	assertEquals(1000, new DoublingRetrySchedule(0, 8, 1000).getInterval(1));
+	assertEquals(2000, new DoublingRetrySchedule(0, 8, 1000).getInterval(2));
+	assertEquals(4000, new DoublingRetrySchedule(0, 8, 1000).getInterval(3));
+	assertEquals(8000, new DoublingRetrySchedule(0, 8, 1000).getInterval(4));
+	assertEquals(8000, new DoublingRetrySchedule(0, 8, 1000).getInterval(5));
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.DoublingRetrySchedule#toString()}.
      */
+    @Test
     public final void testToString() {
-        assertEquals("DoublingRetrySchedule [startInterval=0, maxInterval=1, multiplier=1]", new DoublingRetrySchedule(0, 1).toString());
+	assertEquals("DoublingRetrySchedule [startInterval=0, maxInterval=1, multiplier=1]", new DoublingRetrySchedule(0,
+		1).toString());
     }
-
 }

Modified: james/server/trunk/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java?rev=1299502&r1=1299501&r2=1299502&view=diff
==============================================================================
--- james/server/trunk/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java (original)
+++ james/server/trunk/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java Mon Mar 12 00:32:30 2012
@@ -17,182 +17,179 @@
  *   under the License.
  *
  */
-
 package org.apache.james.util.retry;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.naming.Context;
-
+import junit.framework.TestCase;
 import org.apache.james.util.retry.api.ExceptionRetryingProxy;
 import org.apache.james.util.retry.api.RetryHandler;
 import org.apache.james.util.retry.api.RetrySchedule;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * <code>ExceptionRetryHandlerTest</code>
  */
-public class ExceptionRetryHandlerTest extends TestCase {
-    
+public class ExceptionRetryHandlerTest {
+
     private Class<?>[] _exceptionClasses = null;
     private ExceptionRetryingProxy _proxy = null;
     private RetrySchedule _schedule = null;
-    
+
     /**
      * @see junit.framework.TestCase#setUp()
      */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        _exceptionClasses = new Class<?>[]{Exception.class};
-        _proxy = new TestRetryingProxy();
-        _schedule = new TestRetrySchedule();
-    }
-    
-    private class TestRetryingProxy implements ExceptionRetryingProxy
-    {
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#getDelegate()
-         */
-        @Override
-        public Context getDelegate() throws Exception {
-            return null;
-        }
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#newDelegate()
-         */
-        @Override
-        public Context newDelegate() throws Exception {
-            return null;
-        }
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#resetDelegate()
-         */
-        @Override
-        public void resetDelegate() throws Exception {
-            
-        }
-        
-    }
-    
-    private class TestRetrySchedule implements RetrySchedule
-    {
-        /**
-         * @see org.apache.james.user.ldap.api.RetrySchedule#getInterval(int)
-         */
-        @Override
-        public long getInterval(int index) {
-            return index;
-        }
-        
+    @Before
+    public void setUp() throws Exception {
+	_exceptionClasses = new Class<?>[]{Exception.class};
+	_proxy = new TestRetryingProxy();
+	_schedule = new TestRetrySchedule();
+    }
+
+    private class TestRetryingProxy implements ExceptionRetryingProxy {
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#getDelegate()
+	 */
+	@Override
+	public Context getDelegate() throws Exception {
+	    return null;
+	}
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#newDelegate()
+	 */
+	@Override
+	public Context newDelegate() throws Exception {
+	    return null;
+	}
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#resetDelegate()
+	 */
+	@Override
+	public void resetDelegate() throws Exception {
+	}
+    }
+
+    private class TestRetrySchedule implements RetrySchedule {
+
+	/**
+	 * @see org.apache.james.user.ldap.api.RetrySchedule#getInterval(int)
+	 */
+	@Override
+	public long getInterval(int index) {
+	    return index;
+	}
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#ExceptionRetryHandler(java.lang.Class<?>[], org.apache.james.user.ldap.api.ExceptionRetryingProxy, org.apache.james.user.ldap.api.RetrySchedule, int)}.
      */
+    @Test
     public final void testExceptionRetryHandler() {
-        assertTrue(RetryHandler.class.isAssignableFrom(new ExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	assertTrue(RetryHandler.class.isAssignableFrom(new ExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws Exception {
-                return null;
-            }
-        }.getClass()));
+	    @Override
+	    public Object operation() throws Exception {
+		return null;
+	    }
+	}.getClass()));
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#perform()}.
      * @throws Exception 
      */
+    @Test
     public final void testPerform() throws Exception {
-        Object result = new ExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	Object result = new ExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws Exception {
-                return "Hi!";
-            }
-        }.perform();
-        assertEquals("Hi!", result);
-
-        try {
-            new ExceptionRetryHandler(
-                    _exceptionClasses, _proxy, _schedule, 0) {
-
-                @Override
-                public Object operation() throws Exception {
-                    throw new Exception();
-                }
-            }.perform();
-        } catch (Exception ex) {
-            // no-op
-        }
-        assertEquals("Hi!", result);
+	    @Override
+	    public Object operation() throws Exception {
+		return "Hi!";
+	    }
+	}.perform();
+	assertEquals("Hi!", result);
+
+	try {
+	    new ExceptionRetryHandler(
+		    _exceptionClasses, _proxy, _schedule, 0) {
+
+		@Override
+		public Object operation() throws Exception {
+		    throw new Exception();
+		}
+	    }.perform();
+	} catch (Exception ex) {
+	    // no-op
+	}
+	assertEquals("Hi!", result);
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#postFailure(java.lang.Exception, int)}.
      */
+    @Test
     public final void testPostFailure() {
-        final List<Exception> results = new ArrayList<Exception>();
-        RetryHandler handler = new ExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 7) {
-
-            @Override
-            public void postFailure(Exception ex, int retryCount) {
-                super.postFailure(ex, retryCount);
-                results.add(ex);
-            }
-
-            @Override
-            public Object operation() throws Exception {
-                throw new Exception();
-            }
-        };
-        try {
-            handler.perform();
-        } catch (Exception ex)
-        {
-            // no-op
-        }
-        assertEquals(7, results.size());
+	final List<Exception> results = new ArrayList<Exception>();
+	RetryHandler handler = new ExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 7) {
+
+	    @Override
+	    public void postFailure(Exception ex, int retryCount) {
+		super.postFailure(ex, retryCount);
+		results.add(ex);
+	    }
+
+	    @Override
+	    public Object operation() throws Exception {
+		throw new Exception();
+	    }
+	};
+	try {
+	    handler.perform();
+	} catch (Exception ex) {
+	    // no-op
+	}
+	assertEquals(7, results.size());
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#operation()}.
      * @throws Exception 
      */
+    @Test
     public final void testOperation() throws Exception {
-        RetryHandler handler = new ExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	RetryHandler handler = new ExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws Exception {
-                return "Hi!";
-            }
-        };
-        assertEquals("Hi!", handler.operation());
+	    @Override
+	    public Object operation() throws Exception {
+		return "Hi!";
+	    }
+	};
+	assertEquals("Hi!", handler.operation());
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#getRetryInterval(int)}.
      */
+    @Test
     public final void testGetRetryInterval() {
-        ExceptionRetryHandler handler = new ExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	ExceptionRetryHandler handler = new ExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws Exception {
-                return null;
-            }
-        };
-        assertEquals(8, handler.getRetryInterval(8));
+	    @Override
+	    public Object operation() throws Exception {
+		return null;
+	    }
+	};
+	assertEquals(8, handler.getRetryInterval(8));
     }
-
 }

Modified: james/server/trunk/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java?rev=1299502&r1=1299501&r2=1299502&view=diff
==============================================================================
--- james/server/trunk/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java (original)
+++ james/server/trunk/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java Mon Mar 12 00:32:30 2012
@@ -17,121 +17,117 @@
  *   under the License.
  *
  */
-
 package org.apache.james.util.retry.naming;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
-
 import org.apache.james.util.retry.api.ExceptionRetryingProxy;
 import org.apache.james.util.retry.api.RetryHandler;
 import org.apache.james.util.retry.api.RetrySchedule;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * <code>ExceptionRetryHandlerTest</code>
  */
-public class NamingExceptionRetryHandlerTest extends TestCase {
-    
+public class NamingExceptionRetryHandlerTest {
+
     private Class<?>[] _exceptionClasses = null;
     private ExceptionRetryingProxy _proxy = null;
     private RetrySchedule _schedule = null;
-    
+
     /**
      * @see junit.framework.TestCase#setUp()
      */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        _exceptionClasses = new Class<?>[]{NamingException.class};
-        _proxy = new TestRetryingProxy();
-        _schedule = new TestRetrySchedule();
+    @Before
+    public void setUp() throws Exception {
+	_exceptionClasses = new Class<?>[]{NamingException.class};
+	_proxy = new TestRetryingProxy();
+	_schedule = new TestRetrySchedule();
     }
-    
-    private class TestRetryingProxy implements ExceptionRetryingProxy
-    {
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#getDelegate()
-         */
-        @Override
-        public Context getDelegate() throws NamingException {
-            return null;
-        }
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#newDelegate()
-         */
-        @Override
-        public Context newDelegate() throws NamingException {
-            return null;
-        }
-
-        /**
-         * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#resetDelegate()
-         */
-        @Override
-        public void resetDelegate() throws NamingException {
-            
-        }
-        
+
+    private class TestRetryingProxy implements ExceptionRetryingProxy {
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#getDelegate()
+	 */
+	@Override
+	public Context getDelegate() throws NamingException {
+	    return null;
+	}
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#newDelegate()
+	 */
+	@Override
+	public Context newDelegate() throws NamingException {
+	    return null;
+	}
+
+	/**
+	 * @see org.apache.james.user.ldap.api.ExceptionRetryingProxy#resetDelegate()
+	 */
+	@Override
+	public void resetDelegate() throws NamingException {
+	}
     }
-    
-    private class TestRetrySchedule implements RetrySchedule
-    {
-        /**
-         * @see org.apache.james.user.ldap.api.RetrySchedule#getInterval(int)
-         */
-        @Override
-        public long getInterval(int index) {
-            return index;
-        }
-        
+
+    private class TestRetrySchedule implements RetrySchedule {
+
+	/**
+	 * @see org.apache.james.user.ldap.api.RetrySchedule#getInterval(int)
+	 */
+	@Override
+	public long getInterval(int index) {
+	    return index;
+	}
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#ExceptionRetryHandler(java.lang.Class<?>[], org.apache.james.user.ldap.api.ExceptionRetryingProxy, org.apache.james.user.ldap.api.RetrySchedule, int)}.
      */
+    @Test
     public final void testExceptionRetryHandler() {
-        assertTrue(RetryHandler.class.isAssignableFrom(new NamingExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	assertTrue(RetryHandler.class.isAssignableFrom(new NamingExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws Exception {
-                return null;
-            }
-        }.getClass()));
+	    @Override
+	    public Object operation() throws Exception {
+		return null;
+	    }
+	}.getClass()));
     }
 
     /**
      * Test method for {@link org.apache.james.user.ldap.ExceptionRetryHandler#perform()}.
      * @throws Exception 
      */
+    @Test
     public final void testPerform() throws NamingException {
-        Object result = new NamingExceptionRetryHandler(
-                _exceptionClasses, _proxy, _schedule, 0) {
+	Object result = new NamingExceptionRetryHandler(
+		_exceptionClasses, _proxy, _schedule, 0) {
 
-            @Override
-            public Object operation() throws NamingException {
-                return "Hi!";
-            }
-        }.perform();
-        assertEquals("Hi!", result);
-
-        try {
-            new NamingExceptionRetryHandler(
-                    _exceptionClasses, _proxy, _schedule, 0) {
-
-                @Override
-                public Object operation() throws Exception {
-                    throw new NamingException();
-                }
-            }.perform();
-        } catch (NamingException ex) {
-            // no-op
-        }
-        assertEquals("Hi!", result);
+	    @Override
+	    public Object operation() throws NamingException {
+		return "Hi!";
+	    }
+	}.perform();
+	assertEquals("Hi!", result);
+
+	try {
+	    new NamingExceptionRetryHandler(
+		    _exceptionClasses, _proxy, _schedule, 0) {
+
+		@Override
+		public Object operation() throws Exception {
+		    throw new NamingException();
+		}
+	    }.perform();
+	} catch (NamingException ex) {
+	    // no-op
+	}
+	assertEquals("Hi!", result);
     }
-
 }



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