openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1562309 [2/2] - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans: newtests/ test/component/ test/component/dependent/ test/component/inject/broken/ test/component/inject/named/ test/component/library/ test/component/p...
Date Tue, 28 Jan 2014 23:23:26 GMT
Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/Producer1ConsumerComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/Producer1ConsumerComponentTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/Producer1ConsumerComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/Producer1ConsumerComponentTest.java
Tue Jan 28 23:23:25 2014
@@ -18,77 +18,30 @@
  */
 package org.apache.webbeans.test.unittests.producer;
 
-import java.util.List;
-
-import javax.enterprise.inject.spi.BeanManager;
-
 import junit.framework.Assert;
 
-import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.producer.Producer1;
 import org.apache.webbeans.test.component.service.IService;
 import org.apache.webbeans.test.component.service.Producer1ConsumerComponent;
 import org.apache.webbeans.test.component.service.ServiceImpl1;
-import org.junit.Before;
 import org.junit.Test;
 
-public class Producer1ConsumerComponentTest extends TestContext
+public class Producer1ConsumerComponentTest extends AbstractUnitTest
 {
-    BeanManager container = null;
-
-    public Producer1ConsumerComponentTest()
-    {
-        super(Producer1ConsumerComponentTest.class.getSimpleName());
-    }
-
-    @Override
-    @Before
-    public void init()
-    {
-        super.init();
-        this.container = WebBeansContext.getInstance().getBeanManagerImpl();
-    }
-
     @Test
     public void testTypedComponent() throws Throwable
     {
-        clear();
-
-        defineManagedBean(ServiceImpl1.class);
-        defineManagedBean(Producer1.class);
-        defineManagedBean(Producer1ConsumerComponent.class);
+        startContainer(IService.class, ServiceImpl1.class, Producer1.class, Producer1ConsumerComponent.class);
 
-        List<AbstractOwbBean<?>> comps = getComponents();
+        IService svc1Named = getInstance("service");
+        Assert.assertNotNull(svc1Named);
+        Assert.assertEquals("ServiceImpl1", svc1Named.service());
 
-        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
-        contextFactory.initRequestContext(null);
-        contextFactory.initApplicationContext(null);
-
-        Assert.assertEquals(4, getDeployedComponents());
-
-        Object obj = getManager().getInstance(comps.get(0));
-        
-        Assert.assertNotNull(obj);
-
-        getInstanceByName("service");
-
-        getManager().getInstance(comps.get(1));
-
-        Object object = getManager().getInstance(comps.get(2));
-
-        Assert.assertTrue(object instanceof Producer1ConsumerComponent);
-
-        Producer1ConsumerComponent single = (Producer1ConsumerComponent) object;
+        Producer1ConsumerComponent single = getInstance(Producer1ConsumerComponent.class);
 
         IService service = single.getService();
-
         Assert.assertNotNull(service);
-
-        contextFactory.destroyApplicationContext(null);
-        contextFactory.destroyRequestContext(null);
+        Assert.assertEquals("ServiceImpl1", service.service());
     }
-
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/ProducerComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/ProducerComponentTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/ProducerComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/ProducerComponentTest.java
Tue Jan 28 23:23:25 2014
@@ -18,122 +18,55 @@
  */
 package org.apache.webbeans.test.unittests.producer;
 
-import java.lang.annotation.Annotation;
 import java.util.List;
 
 import javax.enterprise.util.TypeLiteral;
 
 import junit.framework.Assert;
 
-import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.producer.ParametrizedModel1;
 import org.apache.webbeans.test.component.producer.ParametrizedModel2;
 import org.apache.webbeans.test.component.producer.ParametrizedProducer;
-import org.apache.webbeans.test.component.producer.Producer1;
-import org.apache.webbeans.test.component.producer.Producer2;
-import org.apache.webbeans.test.component.producer.Producer3;
 import org.apache.webbeans.test.component.producer.Producer4;
 import org.apache.webbeans.test.component.producer.Producer4ConsumerComponent;
-import org.junit.Before;
 import org.junit.Test;
 
-public class ProducerComponentTest extends TestContext
+public class ProducerComponentTest extends AbstractUnitTest
 {
 
-    public ProducerComponentTest()
-    {
-        super(ProducerComponentTest.class.getSimpleName());
-    }
-
-    @Override
-    @Before
-    public void init()
-    {
-        super.init();
-    }
-
-    /**
-     * From the container with servlet context
-     */
-    @Override
-    public void startTests(Object ctx)
-    {
-        testProducerDeployment1();
-        testProducerDeployment2();
-    }
-
-    @Test
-    public void testProducerDeployment1()
-    {
-        clear();
-        defineManagedBean(Producer1.class);
-        Assert.assertEquals(2, getDeployedComponents());
-
-    }
-
-    @Test
-    public void testProducerDeployment2()
-    {
-        clear();
-        defineManagedBean(Producer2.class);
-        Assert.assertEquals(3, getDeployedComponents());
-    }
-
-    @Test
-    public void testProducerDeployment3()
-    {
-        clear();
-        defineManagedBean(Producer3.class);
-
-        Assert.assertEquals(5, getDeployedComponents());
-    }
-
     @Test
     public void testParametrizedProducer()
     {
-        clear();
-        defineManagedBean(ParametrizedProducer.class);
-
-        WebBeansContext.getInstance().getContextFactory().initRequestContext(null);
-        Assert.assertEquals(3, getDeployedComponents());
-
+        startContainer(ParametrizedProducer.class);
         TypeLiteral<List<ParametrizedModel1>> model1 = new TypeLiteral<List<ParametrizedModel1>>()
         {
         };
 
-        List<ParametrizedModel1> instance = getManager().getInstanceByType(model1,
new Annotation[0]);
+        List<ParametrizedModel1> instance = getInstance(model1.getType());
         Assert.assertNull(instance);
-        Assert.assertTrue(ParametrizedProducer.getCALLMODEL1());
-        Assert.assertTrue(!ParametrizedProducer.getCALLMODEL2());
+        Assert.assertTrue(ParametrizedProducer.callModel1);
+        Assert.assertTrue(!ParametrizedProducer.callModel2);
 
         TypeLiteral<List<ParametrizedModel2>> model2 = new TypeLiteral<List<ParametrizedModel2>>()
         {
         };
-        List<ParametrizedModel2> instance2 = getManager().getInstanceByType(model2,
new Annotation[0]);
+        List<ParametrizedModel2> instance2 = getInstance(model2.getType());
 
         Assert.assertNull(instance2);
-        Assert.assertTrue(ParametrizedProducer.getCALLMODEL2());
-
+        Assert.assertTrue(ParametrizedProducer.callModel2);
     }
 
     @Test
     public void testProducer4()
     {
-        defineManagedBean(Producer4.class);
-        AbstractOwbBean<Producer4ConsumerComponent> component = defineManagedBean(Producer4ConsumerComponent.class);
+        startContainer(Producer4.class, Producer4ConsumerComponent.class);
 
-        WebBeansContext.getInstance().getContextFactory().initSessionContext(new Object());
-
-        Producer4ConsumerComponent instance = getManager().getInstance(component);
-
-        Assert.assertNotNull(instance);
+        Producer4ConsumerComponent instance = getInstance(Producer4ConsumerComponent.class);
 
         int count = instance.count();
 
         Assert.assertEquals(1, count);
-
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/primitive/PrimitiveProducerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/primitive/PrimitiveProducerTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/primitive/PrimitiveProducerTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/primitive/PrimitiveProducerTest.java
Tue Jan 28 23:23:25 2014
@@ -20,39 +20,21 @@ package org.apache.webbeans.test.unittes
 
 import junit.framework.Assert;
 
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.producer.primitive.PrimitiveConsumer;
 import org.apache.webbeans.test.component.producer.primitive.PrimitiveProducer;
-import org.junit.Before;
 import org.junit.Test;
 
-public class PrimitiveProducerTest extends TestContext
+public class PrimitiveProducerTest extends AbstractUnitTest
 {
-    public PrimitiveProducerTest()
-    {
-        super(PrimitiveProducerTest.class.getName());
-    }
-
-    @Override
-    @Before
-    public void init()
-    {
-    }
-    
-    
     @Test
     public void testPrimitiveProducer()
     {
-        WebBeansContext.getInstance().getContextFactory().initRequestContext(null);
-
-        defineManagedBean(PrimitiveProducer.class);
-        defineManagedBean(PrimitiveConsumer.class);
+        startContainer(PrimitiveProducer.class, PrimitiveConsumer.class);
         
-        PrimitiveConsumer consumer = (PrimitiveConsumer) getInstanceByName("primitiveConsumer");
+        PrimitiveConsumer consumer = getInstance("primitiveConsumer");
         
         Assert.assertEquals(56.7f, consumer.getSalary());
-        
     }
 }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
Tue Jan 28 23:23:25 2014
@@ -22,39 +22,17 @@ import javax.enterprise.inject.spi.BeanM
 
 import junit.framework.Assert;
 
-import org.apache.webbeans.component.BeanManagerBean;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.test.TestContext;
-import org.junit.Before;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.junit.Test;
 
-public class ManagerResolutionTest extends TestContext
+public class ManagerResolutionTest extends AbstractUnitTest
 {
-    public ManagerResolutionTest()
-    {
-        super(ManagerResolutionTest.class.getName());
-    }
-
-    @Before
-    public void beforeTest()
-    {
-        super.init();
-        getManager().addInternalBean(WebBeansContext.getInstance().getWebBeansUtil().getManagerBean());
-    }
 
     @Test
     public void testManagerResolution()
     {
-        BeanManagerBean component = WebBeansContext.getInstance().getWebBeansUtil().getManagerBean();
-        BeanManager manager = getManager().getInstance(component);
-
+        startContainer();
+        BeanManager manager = getInstance(BeanManager.class);
         Assert.assertNotNull(manager);
     }
-
-    @Test
-    public void test2()
-    {
-
-    }
-
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/logger/LoggerSpecializationTest.java
Tue Jan 28 23:23:25 2014
@@ -18,102 +18,44 @@
  */
 package org.apache.webbeans.test.unittests.specializes.logger;
 
-import java.io.InputStream;
-import java.util.ArrayList;
-
-import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
-
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.specializes.logger.ISomeLogger;
 import org.apache.webbeans.test.component.specializes.logger.MockNotSpecializedLogger;
 import org.apache.webbeans.test.component.specializes.logger.MockSpecializedLogger;
 import org.apache.webbeans.test.component.specializes.logger.SpecializedInjector;
 import org.apache.webbeans.test.component.specializes.logger.SystemLogger;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.junit.Test;
 
-public class LoggerSpecializationTest extends TestContext
+public class LoggerSpecializationTest extends AbstractUnitTest
 {
-    public LoggerSpecializationTest()
-    {
-        super(LoggerSpecializationTest.class.getName());
-    }
-
     @Test
     public void testNotSpecializedVersion()
     {
-        clear();
-
-        WebBeansContext.getInstance().getPluginLoader().startUp();
-        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/specializes/alternatives.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternative.xml");
-        
-        defineManagedBean(SystemLogger.class);
-        defineManagedBean(MockNotSpecializedLogger.class);        
-        
-        Bean<SpecializedInjector> bean = defineManagedBean(SpecializedInjector.class);
-        Object instance = getManager().getReference(bean, SpecializedInjector.class, getManager().createCreationalContext(bean));
-        
-        Assert.assertTrue(instance instanceof SpecializedInjector);
-        SpecializedInjector injector = (SpecializedInjector)instance;
+        startContainer("org/apache/webbeans/test/xml/specializes/alternatives.xml",
+                       SystemLogger.class, MockNotSpecializedLogger.class, SpecializedInjector.class);
         
+        SpecializedInjector injector = getInstance(SpecializedInjector.class);
         ISomeLogger logger = injector.logger();
-        
         Assert.assertTrue(logger instanceof SystemLogger);
-        
         logger.printError("Hello World");
-        
         SystemLogger sysLogger = (SystemLogger)logger;
-        
         Assert.assertEquals("Hello World", sysLogger.getMessage());
-
-        WebBeansContext.getInstance().getPluginLoader().shutDown();
-        WebBeansContext.getInstance().getAlternativesManager().clear();
     }
     
     @Test
     public void testSpecializedVersion()
     {
-        clear();
-
-        WebBeansContext.getInstance().getPluginLoader().startUp();
+        startContainer("org/apache/webbeans/test/xml/specializes/alternatives.xml",
+                SystemLogger.class, MockSpecializedLogger.class, SpecializedInjector.class);
         
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/specializes/alternatives.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives.xml");
-        
-        defineManagedBean(SystemLogger.class);
-        defineManagedBean(MockSpecializedLogger.class);
-        
-        ArrayList<Class<?>> specialClassList = new ArrayList<Class<?>>();
-        specialClassList.add(MockSpecializedLogger.class);
-        WebBeansContext.getInstance().getWebBeansUtil().configureSpecializations(specialClassList);
-
-        Bean<SpecializedInjector> bean = defineManagedBean(SpecializedInjector.class);
-        Object instance = getManager().getReference(bean, SpecializedInjector.class, getManager().createCreationalContext(bean));
-        
-        Assert.assertTrue(instance instanceof SpecializedInjector);
-        SpecializedInjector injector = (SpecializedInjector)instance;
+        SpecializedInjector injector = getInstance(SpecializedInjector.class);
         
         ISomeLogger logger = injector.logger();
-        
         Assert.assertTrue(logger instanceof MockSpecializedLogger);
-        
         logger.printError("Hello World");
-        
         MockSpecializedLogger sysLogger = (MockSpecializedLogger)logger;
-        
         Assert.assertEquals("Hello World", sysLogger.getMessage());
-
-        WebBeansContext.getInstance().getPluginLoader().shutDown();
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java
Tue Jan 28 23:23:25 2014
@@ -23,19 +23,14 @@ import java.io.InputStream;
 import junit.framework.Assert;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.xml.strict.DummyDecorator;
 import org.apache.webbeans.test.xml.strict.DummyInterceptor;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.junit.Test;
 
-public class XMLSpecStrictTest extends TestContext
+public class XMLSpecStrictTest extends AbstractUnitTest
 {
-    public XMLSpecStrictTest()
-    {
-        super(XMLSpecStrictTest.class.getName());
-    }
-
     @Test
     public void testXMLSpecStrictDecorators()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/DummyDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/DummyDecorator.java?rev=1562309&r1=1562308&r2=1562309&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/DummyDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/DummyDecorator.java
Tue Jan 28 23:23:25 2014
@@ -18,10 +18,21 @@
  */
 package org.apache.webbeans.test.xml.strict;
 
+import org.apache.webbeans.test.component.IPayment;
+
 import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
 
 @Decorator
-public class DummyDecorator
+public class DummyDecorator implements IPayment
 {
+    @Inject
+    @Delegate
+    private IPayment delegate;
 
+    @Override
+    public String pay() {
+        return delegate.pay();
+    }
 }



Mime
View raw message