Author: shane.bryzak(a)jboss.com
Date: 2009-03-18 02:31:05 -0400 (Wed, 18 Mar 2009)
New Revision: 2081
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/examples/Generator.java
Log:
don't dispense the same random number twice in a row, otherwise 1/100 test runs will
fail
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/examples/Generator.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/examples/Generator.java 2009-03-18
05:53:53 UTC (rev 2080)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/examples/Generator.java 2009-03-18
06:31:05 UTC (rev 2081)
@@ -6,6 +6,7 @@
@ApplicationScoped
public class Generator {
+ private int lastInt = 0;
private java.util.Random random = new java.util.Random( System.currentTimeMillis() );
java.util.Random getRandom()
@@ -13,8 +14,14 @@
return random;
}
- @Produces @Random int next() {
- return getRandom().nextInt(100);
+ @Produces @Random int next() {
+ int nextInt = getRandom().nextInt(100);
+ while (nextInt == lastInt)
+ {
+ nextInt = getRandom().nextInt(100);
+ }
+ lastInt = nextInt;
+ return nextInt;
}
}
Show replies by date