Author: gavin.king(a)jboss.com
Date: 2008-11-06 11:49:13 -0500 (Thu, 06 Nov 2008)
New Revision: 265
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Game.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Generator.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Tests.java
Log:
add some more assertions
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Game.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Game.java 2008-11-06
16:32:45 UTC (rev 264)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Game.java 2008-11-06
16:49:13 UTC (rev 265)
@@ -1,8 +1,16 @@
package org.jboss.webbeans.examples;
+import javax.webbeans.Initializer;
+
public class Game
{
- private @Random int number;
+ private final int number;
+
+ @Initializer
+ Game(@Random int number)
+ {
+ this.number = number;
+ }
public int getNumber()
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Generator.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Generator.java 2008-11-06
16:32:45 UTC (rev 264)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Generator.java 2008-11-06
16:49:13 UTC (rev 265)
@@ -8,8 +8,13 @@
private java.util.Random random = new java.util.Random( System.currentTimeMillis() );
+ java.util.Random getRandom()
+ {
+ return random;
+ }
+
@Produces @Random int next() {
- return random.nextInt(100);
+ return getRandom().nextInt(100);
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Tests.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Tests.java 2008-11-06
16:32:45 UTC (rev 264)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/examples/Tests.java 2008-11-06
16:49:13 UTC (rev 265)
@@ -22,6 +22,11 @@
manager.addBean(nextBean);
Game game1 = manager.getInstanceByType(Game.class);
Game game2 = manager.getInstanceByType(Game.class);
+ assert game1!=game2;
assert game1.getNumber()!=game2.getNumber();
+ Generator gen1 = manager.getInstanceByType(Generator.class);
+ Generator gen2 = manager.getInstanceByType(Generator.class);
+ assert gen1.getRandom()!=null;
+ assert gen1.getRandom()==gen2.getRandom();
}
}
Show replies by thread