[webbeans-commits] Webbeans SVN: r3690 - in ri/trunk/tests/src/test: java/org/jboss/webbeans/test/unit/decorator and 4 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Sep 17 05:03:41 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-09-17 05:03:41 -0400 (Thu, 17 Sep 2009)
New Revision: 3690

Added:
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBean.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBeanImpl.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecoratorTest.java
   ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/
   ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/simple/
   ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/simple/beans.xml
Log:
Add decorator test

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBean.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBean.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBean.java	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.test.unit.decorator.simple;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface SimpleBean
+{
+   int echo1(int i);
+   
+   int echo2(int i);
+   
+   int echo3(int i);
+   
+   int echo4(int i);
+}

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBeanImpl.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBeanImpl.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleBeanImpl.java	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.test.unit.decorator.simple;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleBeanImpl implements SimpleBean
+{
+
+   public int echo1(int i)
+   {
+      return i;
+   }
+
+   public int echo2(int i)
+   {
+      return i;
+   }
+
+   public int echo3(int i)
+   {
+      return i;
+   }
+
+   public int echo4(int i)
+   {
+      return i;
+   }
+
+}

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.test.unit.decorator.simple;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Decorator
+public class SimpleDecorator1
+{
+   @Decorates
+   SimpleBean delegate;
+   
+   public static boolean echo1;
+   public static boolean echo3;
+   
+   public static void reset()
+   {
+      echo1 = false;
+      echo3 = false;
+   }
+   
+   public int echo1(int i)
+   {
+      echo1 = true;
+      return delegate.echo1(i);
+   }
+
+   public int echo3(int i)
+   {
+      echo3 = true;
+      return delegate.echo1(i);
+   }
+}

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.webbeans.test.unit.decorator.simple;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Decorator
+public class SimpleDecorator2
+{
+   @Decorates
+   SimpleBean delegate;
+   
+   public static boolean echo2;
+   public static boolean echo3;
+   
+   public static void reset()
+   {
+      echo2 = false;
+      echo3 = false;
+   }
+
+   public int echo2(int i)
+   {
+      echo2 = true;
+      return delegate.echo1(i);
+   }
+
+   public int echo3(int i)
+   {
+      echo3 = true;
+      return delegate.echo1(i);
+   }
+}

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecoratorTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecoratorTest.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecoratorTest.java	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,54 @@
+package org.jboss.webbeans.test.unit.decorator.simple;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+ at BeansXml("beans.xml")
+public class SimpleDecoratorTest extends AbstractWebBeansTest
+{
+   @Test
+   public void testSimpleDecorator()
+   {
+      SimpleBean simpleBean = getCurrentManager().getInstanceByType(SimpleBean.class);
+      
+      resetDecorators();
+      assert simpleBean.echo1(1) == 1;
+      assertDecorators(true, false, false);
+      
+      resetDecorators();
+      assert simpleBean.echo2(2) == 2;
+      assertDecorators(false, true, false);
+
+      //Only SimpleDecorator1 gets invoked, although I think SimpleDecorator2 should get invoked too
+      resetDecorators();
+      assert simpleBean.echo3(3) == 3;
+      assertDecorators(false, false, true);
+      
+      resetDecorators();
+      assert simpleBean.echo4(4) == 4; 
+      assertDecorators(false, false, false);
+   }
+   
+   private void resetDecorators()
+   {
+      SimpleDecorator1.reset();
+      SimpleDecorator2.reset();
+   }
+   
+   private void assertDecorators(boolean echo1, boolean echo2, boolean echo3)
+   {
+      assert SimpleDecorator1.echo1 == echo1;
+      assert SimpleDecorator1.echo3 == echo3;
+      assert SimpleDecorator2.echo2 == echo2;
+      assert SimpleDecorator2.echo3 == echo3;
+   }
+}
+

Added: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/simple/beans.xml
===================================================================
--- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/simple/beans.xml	                        (rev 0)
+++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorator/simple/beans.xml	2009-09-17 09:03:41 UTC (rev 3690)
@@ -0,0 +1,6 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.webbeans.test.unit.decorator.simple.SimpleDecorator1</class>
+      <class>org.jboss.webbeans.test.unit.decorator.simple.SimpleDecorator2</class>
+   </decorators>
+</beans>




More information about the weld-commits mailing list