tephra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] incubator-tephra git commit: Make startShort() throw IllegalArgumentException consistently for invalid timeout values
Date Fri, 21 Oct 2016 06:51:45 GMT
Repository: incubator-tephra
Updated Branches:
  refs/heads/master 36c38f0c0 -> 1502a021f


http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/1502a021/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
----------------------------------------------------------------------
diff --git a/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java b/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
index 77e9232..24798ca 100644
--- a/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
@@ -33,25 +33,33 @@ import java.util.concurrent.TimeUnit;
  */
 public abstract class TransactionSystemTest {
 
-  public static final byte[] C1 = new byte[] { 'c', '1' };
-  public static final byte[] C2 = new byte[] { 'c', '2' };
-  public static final byte[] C3 = new byte[] { 'c', '3' };
-  public static final byte[] C4 = new byte[] { 'c', '4' };
+  private static final byte[] C1 = new byte[] { 'c', '1' };
+  private static final byte[] C2 = new byte[] { 'c', '2' };
+  private static final byte[] C3 = new byte[] { 'c', '3' };
+  private static final byte[] C4 = new byte[] { 'c', '4' };
 
   protected abstract TransactionSystemClient getClient() throws Exception;
 
   protected abstract TransactionStateStorage getStateStorage() throws Exception;
 
-  // Unfortunately, in-memory mode and thrift mode throw different exceptions here
-  @Test(expected = Exception.class)
+  @Test // can't do (expected=IllegalArgumentException) because the subclass needs to perform
an extra assert
   public void testNegativeTimeout() throws Exception {
-    getClient().startShort(-1);
+    try {
+      getClient().startShort(-1);
+      Assert.fail("Expected illegal argument for negative timeout");
+    } catch (IllegalArgumentException e) {
+      // expected
+    }
   }
 
-  // Unfortunately, in-memory mode and thrift mode throw different exceptions here
-  @Test(expected = Exception.class)
+  @Test // can't do (expected=IllegalArgumentException) because the subclass needs to perform
an extra assert
   public void testExcessiveTimeout() throws Exception {
-    getClient().startShort((int) TimeUnit.DAYS.toSeconds(10));
+    try {
+      getClient().startShort((int) TimeUnit.DAYS.toSeconds(10));
+      Assert.fail("Expected illegal argument for excessive timeout");
+    } catch (IllegalArgumentException e) {
+      // expected
+    }
   }
 
   @Test


Mime
View raw message