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 ma...@apache.org on 2018/03/16 10:18:00 UTC
[21/22] james-project git commit: JAMES-2352 Reindent,
remove useless comments and enhance ExceptionRetryHandlerTest a bit
JAMES-2352 Reindent, remove useless comments and enhance ExceptionRetryHandlerTest a bit
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6f75e238
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6f75e238
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6f75e238
Branch: refs/heads/master
Commit: 6f75e238419dd202b52b89a7fc74081251f74aa8
Parents: ddc0484
Author: benwa <bt...@linagora.com>
Authored: Thu Mar 15 17:23:25 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Fri Mar 16 11:13:15 2018 +0100
----------------------------------------------------------------------
.../util/retry/ExceptionRetryHandlerTest.java | 196 ++++++++-----------
1 file changed, 82 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/6f75e238/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java b/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
index d8a20fd..9848efd 100644
--- a/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
@@ -33,154 +33,122 @@ import org.apache.james.util.retry.api.RetrySchedule;
import org.junit.Before;
import org.junit.Test;
-/**
- * <code>ExceptionRetryHandlerTest</code>
- */
public class ExceptionRetryHandlerTest {
+ private static class TestRetryingProxy implements ExceptionRetryingProxy {
+
+ @Override
+ public Context getDelegate() {
+ return null;
+ }
+
+ @Override
+ public Context newDelegate() {
+ return null;
+ }
+
+ @Override
+ public void resetDelegate() {
+ }
+ }
private Class<?>[] exceptionClasses = null;
private ExceptionRetryingProxy proxy = null;
private RetrySchedule schedule = null;
- /**
- * @see junit.framework.TestCase#setUp()
- */
@Before
public void setUp() throws Exception {
- exceptionClasses = new Class<?>[]{Exception.class};
- proxy = new TestRetryingProxy();
- schedule = new TestRetrySchedule();
- }
-
- private class TestRetryingProxy implements ExceptionRetryingProxy {
-
- @Override
- public Context getDelegate() {
- return null;
- }
-
- @Override
- public Context newDelegate() throws Exception {
- return null;
- }
-
- @Override
- public void resetDelegate() throws Exception {
- }
- }
-
- private class TestRetrySchedule implements RetrySchedule {
-
- @Override
- public long getInterval(int index) {
- return index;
- }
+ exceptionClasses = new Class<?>[]{Exception.class};
+ proxy = new TestRetryingProxy();
+ schedule = i -> i;
}
- /**
- * Test method for .
- */
@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() {
+ return null;
+ }
+ }.getClass()));
}
- /**
- * Test method for .
- * @throws Exception
- */
@Test
public final void testPerform() throws Exception {
- Object result = new ExceptionRetryHandler(
- exceptionClasses, proxy, schedule, 0) {
-
- @Override
- public Object operation() throws Exception {
- return "Hi!";
- }
- }.perform();
- assertEquals("Hi!", result);
-
- try {
- new ExceptionRetryHandler(
+ Object result = new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
- @Override
- public Object operation() throws Exception {
- throw new Exception();
- }
+ @Override
+ public Object operation() {
+ return "Hi!";
+ }
}.perform();
- } catch (Exception ex) {
- // no-op
- }
- assertEquals("Hi!", result);
+ 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 .
- */
@Test
public final void testPostFailure() {
- final List<Exception> results = new ArrayList<>();
- 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();
+ final List<Exception> results = new ArrayList<>();
+ 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
}
- };
- try {
- handler.perform();
- } catch (Exception ex) {
- // no-op
- }
- assertEquals(7, results.size());
+ assertEquals(7, results.size());
}
- /**
- * Test method for .
- * @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() {
+ return "Hi!";
+ }
+ };
+ assertEquals("Hi!", handler.operation());
}
- /**
- * Test method for .
- */
@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() {
+ return null;
+ }
+ };
+ assertEquals(8, handler.getRetryInterval(8));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org