openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1407086 - in /openwebbeans/trunk/webbeans-impl/src/test: java/org/apache/webbeans/newtests/decorators/multiple/ java/org/apache/webbeans/newtests/decorators/tests/ resources/org/apache/webbeans/newtests/decorators/tests/
Date Thu, 08 Nov 2012 14:02:56 GMT
Author: rmannibucau
Date: Thu Nov  8 14:02:55 2012
New Revision: 1407086

URL: http://svn.apache.org/viewvc?rev=1407086&view=rev
Log:
adding MultipleCallDecoratorTest test to let work on it

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/MultipleCallDecorator.java
      - copied, changed from r1406406, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/Decorator1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.java
      - copied, changed from r1406406, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.xml
      - copied, changed from r1406406, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.xml

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/MultipleCallDecorator.java
(from r1406406, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/Decorator1.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/MultipleCallDecorator.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/MultipleCallDecorator.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/Decorator1.java&r1=1406406&r2=1407086&rev=1407086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/Decorator1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/multiple/MultipleCallDecorator.java
Thu Nov  8 14:02:55 2012
@@ -23,36 +23,25 @@ import javax.decorator.Delegate;
 import javax.inject.Inject;
 
 @Decorator
-public class Decorator1 implements IOutputProvider
+public class MultipleCallDecorator implements IOutputProvider
 {
 
     @Inject @Delegate IOutputProvider op;
-    
-    @Inject RequestStringBuilder rsb;
 
-    public void init()
-    {
-        System.out.println("decorator created!");
+    public String getOutput() {
+        return null;
     }
 
-    public String getOutput()
-    {
-        rsb.addOutput("Decorator1\n");
-        return op.getOutput();
+    public String trace() {
+        op.trace();
+        return op.trace();
     }
 
-    public String trace() 
-    {
-        return "Decorator1/trace," + op.trace();
-    }
-    public String otherMethod() 
-    {
-        return "Decorator1/otherMethod," + op.otherMethod();
+    public String otherMethod() {
+        return null;
     }
 
-    @Override
-    public String getDelayedOutput() throws InterruptedException
-    {
-        return op.getDelayedOutput();
+    public String getDelayedOutput() throws InterruptedException {
+        return null;
     }
 }

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.java
(from r1406406, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.java&r1=1406406&r2=1407086&rev=1407086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.java
Thu Nov  8 14:02:55 2012
@@ -18,67 +18,46 @@
  */
 package org.apache.webbeans.newtests.decorators.tests;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.enterprise.inject.Default;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.util.AnnotationLiteral;
-
-import junit.framework.Assert;
-
 import org.apache.webbeans.newtests.AbstractUnitTest;
-import org.apache.webbeans.newtests.decorators.multiple.Decorator1;
-import org.apache.webbeans.newtests.decorators.multiple.Decorator2;
-import org.apache.webbeans.newtests.decorators.multiple.Decorator3;
-import org.apache.webbeans.newtests.decorators.multiple.Decorator4;
 import org.apache.webbeans.newtests.decorators.multiple.IOutputProvider;
+import org.apache.webbeans.newtests.decorators.multiple.MultipleCallDecorator;
 import org.apache.webbeans.newtests.decorators.multiple.OutputProvider;
 import org.apache.webbeans.newtests.decorators.multiple.RequestStringBuilder;
+import org.junit.Ignore;
 import org.junit.Test;
 
-public class AbstractDecoratorTest extends AbstractUnitTest
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+public class MultipleCallDecoratorTest extends AbstractUnitTest
 {
     public static final String PACKAGE_NAME = MultipleDecoratorStackTests.class.getPackage().getName();
 
     @Test
+    @Ignore("Decorator can't call twice the delegate")
     public void testDecoratorStackWithAbstractAtEnd()
     {
         Collection<Class<?>> classes = new ArrayList<Class<?>>();
-        classes.add(Decorator1.class);
-        classes.add(Decorator2.class);
-        
-        //Abstract Decorator with a single method, at the end of the execution order
-        classes.add(Decorator3.class);
-        
-        //Abstract Decorator with no methods, in the middle of the execution order
-        classes.add(Decorator4.class);
-        
+        classes.add(MultipleCallDecorator.class);
         classes.add(IOutputProvider.class);
         classes.add(OutputProvider.class);
         classes.add(RequestStringBuilder.class);
 
         Collection<String> xmls = new ArrayList<String>();
-        xmls.add(getXmlPath(PACKAGE_NAME, "AbstractDecoratorTest"));
+        xmls.add(getXmlPath(PACKAGE_NAME, "MultipleCallDecoratorTest"));
 
         startContainer(classes, xmls);
 
         Bean<?> bean = getBeanManager().getBeans(OutputProvider.class, new AnnotationLiteral<Default>()
         {
         }).iterator().next();
-        Object instance = getBeanManager().getReference(bean, OutputProvider.class, getBeanManager().createCreationalContext(bean));
-
-        OutputProvider outputProvider = (OutputProvider) instance;
-
-        Assert.assertTrue(outputProvider != null);
 
-        String result = outputProvider.getOutput();
-        System.out.println(result);
-        // Verify that the Decorators were called in order, and in a stack, including the
Abstract Decorator 3
-        Assert.assertTrue(result.equalsIgnoreCase("Decorator1\nDecorator2\nDecorator3\nOutputProvider\n"));
-        
-        String hijackedStack = outputProvider.trace();
-        // Verify that the a method change in Decorator2 from trace->otherMethod results
in the right stack
-        Assert.assertEquals("Decorator1/trace,Decorator2/trace,delegate/otherMethod", hijackedStack);
  
+        IOutputProvider instance = (IOutputProvider) getBeanManager().getReference(bean,
IOutputProvider.class, getBeanManager().createCreationalContext(bean));
+        assertEquals("delegate/trace", instance.trace()); // StackOverFlow
     }
 }
\ No newline at end of file

Copied: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.xml
(from r1406406, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.xml)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.xml?p2=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.xml&p1=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.xml&r1=1406406&r2=1407086&rev=1407086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/AbstractDecoratorTest.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleCallDecoratorTest.xml
Thu Nov  8 14:02:55 2012
@@ -19,9 +19,6 @@ under the License.
 -->
 <beans>
    <decorators>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator4</class>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator2</class>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator3</class>
+      <class>org.apache.webbeans.newtests.decorators.multiple.MultipleCallDecorator</class>
    </decorators>
 </beans>
\ No newline at end of file



Mime
View raw message