Author: britter
Date: Sat Jan 11 19:39:21 2014
New Revision: 1557446
URL: http://svn.apache.org/r1557446
Log:
Use annotation based testing for failure cases
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java?rev=1557446&r1=1557445&r2=1557446&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java
(original)
+++
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java
Sat Jan 11 19:39:21 2014
@@ -34,56 +34,51 @@ public class RandomUtilsTest {
* For comparing doubles and floats
*/
private static final double DELTA = 1e-5;
-
- /**
- * Tests exceptions
- */
- @Test
- public void testExceptions() throws Exception {
- try {
- RandomUtils.nextBytes(-1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextInt(2, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextDouble(2, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextLong(2, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextFloat(2, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextInt(-1, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextDouble(-1, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextLong(-1, 1);
- fail();
- } catch (IllegalArgumentException e) {}
-
- try {
- RandomUtils.nextFloat(-1, 1);
- fail();
- } catch (IllegalArgumentException e) {}
+
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextBytesNegative() throws Exception {
+ RandomUtils.nextBytes(-1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextIntNegative() throws Exception {
+ RandomUtils.nextInt(-1, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextLongNegative() throws Exception {
+ RandomUtils.nextLong(-1, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextDoubleNegative() throws Exception {
+ RandomUtils.nextDouble(-1, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextFloatNegative() throws Exception {
+ RandomUtils.nextFloat(-1, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextIntLowerGreaterUpper() throws Exception {
+ RandomUtils.nextInt(2, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextLongLowerGreaterUpper() throws Exception {
+ RandomUtils.nextLong(2, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextDoubleLowerGreaterUpper() throws Exception {
+ RandomUtils.nextDouble(2, 1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNextFloatLowerGreaterUpper() throws Exception {
+ RandomUtils.nextFloat(2, 1);
}
/**