(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sat, 31 Jul 2010 17:32:41 +0000 (17:32 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sat, 31 Jul 2010 17:32:41 +0000 (17:32 +0000)
12 files changed:
support/cdi/.project [deleted file]
support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
support/cdi/src/main/java/org/wamblee/cdi/package-info.java
support/cdi/src/test/java/org/wamblee/cdi/BaseTestFixture.java
support/cdi/src/test/java/org/wamblee/cdi/BeanManagerLookupTest.java
support/cdi/src/test/java/org/wamblee/cdi/BeanManagerSetup.java
support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorFactoryTest.java
support/cdi/src/test/java/org/wamblee/cdi/InjectorBuilderTest.java
support/cdi/src/test/java/org/wamblee/cdi/MyPojo.java
support/cdi/src/test/java/org/wamblee/cdi/MySingleton.java
support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java
support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java

diff --git a/support/cdi/.project b/support/cdi/.project
deleted file mode 100644 (file)
index b0870aa..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>wamblee-support-cdi</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.maven.ide.eclipse.maven2Builder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-               <nature>org.maven.ide.eclipse.maven2Nature</nature>
-       </natures>
-</projectDescription>
index 8d9ab46d4c252ab11675e706db2e2f0c52c445c3..8c9f2cb0916b793ba00b55dd3381fbefb8f0ebc6 100644 (file)
@@ -28,9 +28,9 @@ import javax.naming.NamingException;
  * In case no bean manager is found the beanmanager is set to null and the
  * problem is logged.
  * 
  * In case no bean manager is found the beanmanager is set to null and the
  * problem is logged.
  * 
- * This class does caching of the obtained reference to the bean manager. 
- * As a result, it is necessary to call {@link #setBeanManager(BeanManager)}
- * in the setup phase of unit tests to make sure that the lookup is done again. 
+ * This class does caching of the obtained reference to the bean manager. As a
+ * result, it is necessary to call {@link #setBeanManager(BeanManager)} in the
+ * setup phase of unit tests to make sure that the lookup is done again.
  * 
  * @author Erik Brakkee
  */
  * 
  * @author Erik Brakkee
  */
index 65bdfebc059be7beceaa27a54f258690af318d55..ceb1c7a0b016ce17b5dce91b52f1bdf9024194ce 100644 (file)
@@ -25,4 +25,3 @@
  */
 package org.wamblee.cdi;
 
  */
 package org.wamblee.cdi;
 
-
index dd3abc40a8430edcad6b1ec67c6e5f9ff6a835e1..a8275e0d173c91098a486d3e8a8f4c59c0018e2b 100644 (file)
@@ -21,14 +21,13 @@ import org.junit.Before;
 public class BaseTestFixture {
 
     @Before
 public class BaseTestFixture {
 
     @Before
-    public void setUp() throws Exception { 
+    public void setUp() throws Exception {
         BeanManagerLookup.setBeanManager(null);
     }
         BeanManagerLookup.setBeanManager(null);
     }
-    
 
     @After
 
     @After
-    public void tearDown() throws Exception { 
+    public void tearDown() throws Exception {
         BeanManagerLookup.setBeanManager(null);
     }
         BeanManagerLookup.setBeanManager(null);
     }
-    
+
 }
 }
index 5b7f51d495981a426e9729bb76fbcaf0a65cc2c9..2889a2fabfdc6dfb0ab6fb8cb5da9bc65c84d9c6 100644 (file)
@@ -25,13 +25,13 @@ import org.junit.Test;
 import org.wamblee.test.jndi.StubInitialContextFactory;
 
 public class BeanManagerLookupTest extends BaseTestFixture {
 import org.wamblee.test.jndi.StubInitialContextFactory;
 
 public class BeanManagerLookupTest extends BaseTestFixture {
-  
+
     @Test
     public void testLookupInJndi() throws Exception {
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
     @Test
     public void testLookupInJndi() throws Exception {
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
-        InitialContext ctx = new InitialContext(); 
+        InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             assertSame(setup.getBeanManager(), BeanManagerLookup.lookup());
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             assertSame(setup.getBeanManager(), BeanManagerLookup.lookup());
@@ -40,13 +40,13 @@ public class BeanManagerLookupTest extends BaseTestFixture {
             StubInitialContextFactory.unregister();
         }
     }
             StubInitialContextFactory.unregister();
         }
     }
-    
+
     @Test
     @Test
-    public void testWithJndiButWithOverride() throws Exception { 
+    public void testWithJndiButWithOverride() throws Exception {
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
-        InitialContext ctx = new InitialContext(); 
+        InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             BeanManager override = mock(BeanManager.class);
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             BeanManager override = mock(BeanManager.class);
@@ -57,9 +57,9 @@ public class BeanManagerLookupTest extends BaseTestFixture {
             StubInitialContextFactory.unregister();
         }
     }
             StubInitialContextFactory.unregister();
         }
     }
-    
+
     @Test
     @Test
-    public void testNoJndiButWithOverride() throws Exception { 
+    public void testNoJndiButWithOverride() throws Exception {
         BeanManager override = mock(BeanManager.class);
         BeanManagerLookup.setBeanManager(override);
         assertSame(override, BeanManagerLookup.lookup());
         BeanManager override = mock(BeanManager.class);
         BeanManagerLookup.setBeanManager(override);
         assertSame(override, BeanManagerLookup.lookup());
index cbf85bcf325fbf89ffa02cfe5aa1f6b8804bda10..8065031136950a586e3450b168b24790567b473d 100644 (file)
@@ -35,7 +35,7 @@ public class BeanManagerSetup {
         container = weld.initialize();
         beanManager = container.getBeanManager();
     }
         container = weld.initialize();
         beanManager = container.getBeanManager();
     }
-    
+
     public BeanManager getBeanManager() {
         return beanManager;
     }
     public BeanManager getBeanManager() {
         return beanManager;
     }
@@ -43,7 +43,7 @@ public class BeanManagerSetup {
     public void shutdown() {
         weld.shutdown();
         weld = null;
     public void shutdown() {
         weld.shutdown();
         weld = null;
-        container = null; 
-        beanManager = null; 
+        container = null;
+        beanManager = null;
     }
 }
     }
 }
index 5461d5c03e11b6d499cc6ba2688538bf592b396a..861e8809159e277982917bc20b2f4e90a90d5c06 100644 (file)
@@ -42,7 +42,8 @@ public class CdiInjectorFactoryTest extends BaseTestFixture {
 
     @Test
     public void testGetInjector() {
 
     @Test
     public void testGetInjector() {
-        InjectorFactory factory = new CdiInjectorFactory(manager.getBeanManager());
+        InjectorFactory factory = new CdiInjectorFactory(manager
+            .getBeanManager());
         Injector injector = factory.create(MyPojo.class);
         MyPojo pojo = new MyPojo();
         injector.inject(pojo);
         Injector injector = factory.create(MyPojo.class);
         MyPojo pojo = new MyPojo();
         injector.inject(pojo);
index 36440cf460b6d7e18086be2a29b1b9fca5f43979..daffe9b1e615ee767af569324b6557b84de1dcee 100644 (file)
@@ -29,14 +29,13 @@ import org.wamblee.inject.InjectorBuilder;
 import org.wamblee.test.jndi.StubInitialContextFactory;
 
 public class InjectorBuilderTest extends BaseTestFixture {
 import org.wamblee.test.jndi.StubInitialContextFactory;
 
 public class InjectorBuilderTest extends BaseTestFixture {
-    
 
     @Test
 
     @Test
-    public void testCdiInjectorFactoryIsFound() throws Exception { 
+    public void testCdiInjectorFactoryIsFound() throws Exception {
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
         BeanManagerSetup setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
-        InitialContext ctx = new InitialContext(); 
+        InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             InjectorFactory factory = InjectorBuilder.getInjectorFactory();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         try {
             InjectorFactory factory = InjectorBuilder.getInjectorFactory();
@@ -46,7 +45,7 @@ public class InjectorBuilderTest extends BaseTestFixture {
             StubInitialContextFactory.unregister();
         }
     }
             StubInitialContextFactory.unregister();
         }
     }
-    
+
     @Test
     public void testInjectManyTimes() {
         int n = 1000;
     @Test
     public void testInjectManyTimes() {
         int n = 1000;
index 0504deb862a0017f43435b95efa85d6d763f4903..573a7f25fc437e9656f48f07e7916d786b0b1789 100644 (file)
@@ -20,16 +20,16 @@ import javax.inject.Inject;
 public class MyPojo {
 
     @Inject
 public class MyPojo {
 
     @Inject
-    private MySingleton singleton; 
-    
-    public MyPojo() { 
+    private MySingleton singleton;
+
+    public MyPojo() {
         // Empty.
     }
         // Empty.
     }
-    
+
     public MySingleton getSingleton() {
         return singleton;
     }
     public MySingleton getSingleton() {
         return singleton;
     }
-    
+
     public void setSingleton(MySingleton aSingleton) {
         singleton = aSingleton;
     }
     public void setSingleton(MySingleton aSingleton) {
         singleton = aSingleton;
     }
index 8af870eac46caf05a3dced7030a950ab8d04251b..60c0c06fd765a4b602f1b0b695c46549b9ddfda4 100644 (file)
@@ -17,22 +17,21 @@ package org.wamblee.cdi;
 
 import javax.enterprise.context.ApplicationScoped;
 
 
 import javax.enterprise.context.ApplicationScoped;
 
-
 @ApplicationScoped
 public class MySingleton {
 @ApplicationScoped
 public class MySingleton {
-    
-    private static int instances = 0; 
 
 
-    public MySingleton() { 
-        instances++;
+    private static int INSTANCES = 0;
+
+    public MySingleton() {
+        INSTANCES++;
     }
     }
-    
-    public static void reset() { 
-        instances = 0; 
+
+    public static void reset() {
+        INSTANCES = 0;
     }
     }
-    
+
     public static int getInstances() {
     public static int getInstances() {
-        return instances;
+        return INSTANCES;
     }
     }
-   
+
 }
 }
index 93f260e2d3f170ba889a83640b9919820e577bed..7c4bd11297225477778b773942c1d80007c10325 100644 (file)
@@ -43,7 +43,7 @@ public class SimpleInjectorTest extends BaseTestFixture {
         StubInitialContextFactory.register();
         InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
         StubInitialContextFactory.register();
         InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
-        MySingleton.reset();        
+        MySingleton.reset();
     }
 
     @After
     }
 
     @After
@@ -56,7 +56,8 @@ public class SimpleInjectorTest extends BaseTestFixture {
     @Test
     public void testGetSingleton() {
         MyPojo pojo = new MyPojo();
     @Test
     public void testGetSingleton() {
         MyPojo pojo = new MyPojo();
-        SimpleInjector injector = new SimpleInjector(new CdiInjectorFactory(BeanManagerLookup.lookup()));
+        SimpleInjector injector = new SimpleInjector(new CdiInjectorFactory(
+            BeanManagerLookup.lookup()));
         injector.inject(pojo);
 
         MySingleton obj = pojo.getSingleton();
         injector.inject(pojo);
 
         MySingleton obj = pojo.getSingleton();
@@ -82,37 +83,38 @@ public class SimpleInjectorTest extends BaseTestFixture {
             @Override
             public void inject(Object aComponent) {
                 MyPojo pojo2 = (MyPojo) aComponent;
             @Override
             public void inject(Object aComponent) {
                 MyPojo pojo2 = (MyPojo) aComponent;
-                pojo2.setSingleton(singleton); 
+                pojo2.setSingleton(singleton);
             }
         });
             }
         });
-        
+
         injector.inject(pojo);
         injector.inject(pojo);
-        // verify the custom injector was called. 
+        // verify the custom injector was called.
         assertSame(singleton, pojo.getSingleton());
     }
         assertSame(singleton, pojo.getSingleton());
     }
-    
+
     @RequestScoped
     @RequestScoped
-    public static class Y { 
-        
+    public static class Y {
+
     }
     }
-    public static class X { 
+
+    public static class X {
         @Inject
         @Inject
-        private Y y; 
-        
+        private Y y;
+
     }
     }
-    
-    @Test 
-    public void testInjectStorage() throws Exception { 
-        X x = new X(); 
+
+    @Test
+    public void testInjectStorage() throws Exception {
+        X x = new X();
         InjectorBuilder.setInjectorFactory(null);
         InjectorBuilder.getInjector().inject(x);
     }
         InjectorBuilder.setInjectorFactory(null);
         InjectorBuilder.getInjector().inject(x);
     }
-    
-    @Test 
-    public void testInjectStorage2() { 
-        X x = new X(); 
+
+    @Test
+    public void testInjectStorage2() {
+        X x = new X();
         InjectorBuilder.setInjectorFactory(null);
         InjectorBuilder.getInjector().inject(x);
     }
         InjectorBuilder.setInjectorFactory(null);
         InjectorBuilder.getInjector().inject(x);
     }
-    
+
 }
 }
index 640608377a282edbca17c34ed9f940058f2245ae..d2aa8a5516e63e0817e229f6a30b37f5d35f1810 100644 (file)
@@ -11,46 +11,50 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class WeldTest {
 import org.junit.Test;
 
 public class WeldTest {
-    
-    private BeanManagerSetup setup; 
-    
+
+    private BeanManagerSetup setup;
+
     @Before
     public void setUp() {
     @Before
     public void setUp() {
-        setup = new BeanManagerSetup(); 
-        setup.initialize(); 
+        setup = new BeanManagerSetup();
+        setup.initialize();
         MySingleton.reset();
     }
         MySingleton.reset();
     }
-    
+
     @After
     @After
-    public void tearDown() { 
+    public void tearDown() {
         setup.shutdown();
     }
         setup.shutdown();
     }
-    
+
     @Test
     @Test
-    public void testGetSingleton() { 
-        AnnotatedType<MyPojo> type = setup.getBeanManager().createAnnotatedType(MyPojo.class);
-        InjectionTarget<MyPojo> target = setup.getBeanManager().createInjectionTarget(type);
-        CreationalContext<MyPojo> ctx = setup.getBeanManager().createCreationalContext(null);
-        
-        MyPojo pojo = new MyPojo(); 
-        
-        target.inject(pojo, ctx); 
-        
-        MySingleton obj = pojo.getSingleton(); 
-        
+    public void testGetSingleton() {
+        AnnotatedType<MyPojo> type = setup.getBeanManager()
+            .createAnnotatedType(MyPojo.class);
+        InjectionTarget<MyPojo> target = setup.getBeanManager()
+            .createInjectionTarget(type);
+        CreationalContext<MyPojo> ctx = setup.getBeanManager()
+            .createCreationalContext(null);
+
+        MyPojo pojo = new MyPojo();
+
+        target.inject(pojo, ctx);
+
+        MySingleton obj = pojo.getSingleton();
+
         assertNotNull(obj);
         assertNotNull(obj);
-        
-        MyPojo pojo2 = new MyPojo(); 
-        target.inject(pojo2, ctx); 
-                
-        // Objects will not be the same as they are contextual references to the same object.
+
+        MyPojo pojo2 = new MyPojo();
+        target.inject(pojo2, ctx);
+
+        // Objects will not be the same as they are contextual references to the
+        // same object.
         // assertSame(pojo2, pojo);
 
         assertEquals(1, MySingleton.getInstances());
     }
         // assertSame(pojo2, pojo);
 
         assertEquals(1, MySingleton.getInstances());
     }
-    
+
     @Test
     @Test
-    public void testAgain() { 
+    public void testAgain() {
         testGetSingleton();
     }
 }
         testGetSingleton();
     }
 }