openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1681961 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java unittests/decorator/Decorator1Test.java
Date Wed, 27 May 2015 10:41:42 GMT
Author: struberg
Date: Wed May 27 10:41:42 2015
New Revision: 1681961

URL: http://svn.apache.org/r1681961
Log:
OWB-933 adding test to verify all works now

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java
      - copied, changed from r1681588, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java
(from r1681588, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java&r1=1681588&r2=1681961&rev=1681961&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecoratorWithCtInjectionPoint.java
Wed May 27 10:41:42 2015
@@ -18,27 +18,30 @@
  */
 package org.apache.webbeans.test.component.decorator.clean;
 
-import javax.decorator.Delegate;
 import javax.decorator.Decorator;
+import javax.decorator.Delegate;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
-import javax.inject.Named;
 
 import org.apache.webbeans.test.annotation.binding.Binding1;
 import org.apache.webbeans.test.component.service.IService;
 
+/**
+ * The same as {@see ServiceDecorator} but with the @Delegate in a ct and not as a field
+ */
 @Decorator
-public  class ServiceDecorator implements IService
+public  class ServiceDecoratorWithCtInjectionPoint implements IService
 {
-    private @Inject @Delegate @Binding1 IService delegate;
+    private IService delegate;
 
     public static String delegateAttr = null;
     public static InjectionPoint ip;
 
     @Inject
-    public ServiceDecorator(InjectionPoint ip)
+    public ServiceDecoratorWithCtInjectionPoint(@Delegate @Binding1 IService delegate, InjectionPoint
ip)
     {
-        ServiceDecorator.ip = ip;
+        ServiceDecoratorWithCtInjectionPoint.ip = ip;
+        this.delegate = delegate;
     }
 
     @Override
@@ -46,7 +49,7 @@ public  class ServiceDecorator implement
     {
         this.delegateAttr = delegate.service();
 
-        return "ServiceDecorator";
+        return "ServiceDecoratorWithCtInjectionPoint";
     }
 
     public String getDelegateAttr()

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java?rev=1681961&r1=1681960&r2=1681961&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java
Wed May 27 10:41:42 2015
@@ -38,6 +38,7 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.decorator.clean.AccountComponent;
 import org.apache.webbeans.test.component.decorator.clean.LargeTransactionDecorator;
 import org.apache.webbeans.test.component.decorator.clean.ServiceDecorator;
+import org.apache.webbeans.test.component.decorator.clean.ServiceDecoratorWithCtInjectionPoint;
 import org.apache.webbeans.test.component.service.IService;
 import org.apache.webbeans.test.component.service.ServiceImpl1;
 import org.junit.Test;
@@ -101,4 +102,31 @@ public class Decorator1Test extends Abst
 
     }
 
+
+    @Test
+    public void testDecoratorWithCtDelegate()
+    {
+        addDecorator(ServiceDecoratorWithCtInjectionPoint.class);
+        addDecorator(LargeTransactionDecorator.class);
+
+        startContainer(ServiceDecoratorWithCtInjectionPoint.class, CheckWithCheckPayment.class,
ServiceImpl1.class, Binding1.class);
+
+        ServiceDecoratorWithCtInjectionPoint.delegateAttr = null;
+        ServiceDecoratorWithCtInjectionPoint.ip = null;
+
+        ServiceImpl1 serviceImpl = getInstance(ServiceImpl1.class, new Annotation[]{new Binding1Literal()});
+        String s = serviceImpl.service();
+
+        Assert.assertEquals("ServiceDecoratorWithCtInjectionPoint", s);
+
+        Set<Type> apiTyeps = new HashSet<Type>();
+        apiTyeps.add(IService.class);
+
+        List<Decorator<?>> decs = getBeanManager().resolveDecorators(apiTyeps,
new Annotation[]{new Binding1Literal()});
+        Assert.assertNotNull(decs);
+        Assert.assertTrue(decs.size() > 0);
+
+        Assert.assertEquals("ServiceImpl1", ServiceDecoratorWithCtInjectionPoint.delegateAttr);
+    }
+
 }



Mime
View raw message