From webbeans-commits at lists.jboss.org Thu Sep 17 05:03:41 2009 Content-Type: multipart/mixed; boundary="===============5184538720056811549==" MIME-Version: 1.0 From: webbeans-commits at lists.jboss.org To: weld-commits at lists.jboss.org Subject: [webbeans-commits] Webbeans SVN: r3690 - in ri/trunk/tests/src/test: java/org/jboss/webbeans/test/unit/decorator and 4 other directories. Date: Thu, 17 Sep 2009 05:03:41 -0400 Message-ID: <200909170903.n8H93fCj002150@svn01.web.mwc.hst.phx2.redhat.com> --===============5184538720056811549== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: kabir.khan(a)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/simp= le/ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simp= le/SimpleBean.java ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simp= le/SimpleBeanImpl.java ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simp= le/SimpleDecorator1.java ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simp= le/SimpleDecorator2.java ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simp= le/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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/SimpleBean.java (rev 0) +++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/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 Kabir Khan + * @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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/SimpleBeanImpl.java (rev 0) +++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/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 Kabir Khan + * @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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/SimpleDecorator1.java (rev 0) +++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/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 Kabir Khan + * @version $Revision: 1.1 $ + */ +(a)Decorator +public class SimpleDecorator1 +{ + @Decorates + SimpleBean delegate; + = + public static boolean echo1; + public static boolean echo3; + = + public static void reset() + { + echo1 =3D false; + echo3 =3D false; + } + = + public int echo1(int i) + { + echo1 =3D true; + return delegate.echo1(i); + } + + public int echo3(int i) + { + echo3 =3D true; + return delegate.echo1(i); + } +} Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/= simple/SimpleDecorator2.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/SimpleDecorator2.java (rev 0) +++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/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 Kabir Khan + * @version $Revision: 1.1 $ + */ +(a)Decorator +public class SimpleDecorator2 +{ + @Decorates + SimpleBean delegate; + = + public static boolean echo2; + public static boolean echo3; + = + public static void reset() + { + echo2 =3D false; + echo3 =3D false; + } + + public int echo2(int i) + { + echo2 =3D true; + return delegate.echo1(i); + } + + public int echo3(int i) + { + echo3 =3D true; + return delegate.echo1(i); + } +} Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/= simple/SimpleDecoratorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/SimpleDecoratorTest.java (rev 0) +++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/sim= ple/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 Kabir Khan + * @version $Revision: 1.1 $ + */ +(a)Artifact +(a)BeansXml("beans.xml") +public class SimpleDecoratorTest extends AbstractWebBeansTest +{ + @Test + public void testSimpleDecorator() + { + SimpleBean simpleBean =3D getCurrentManager().getInstanceByType(Simp= leBean.class); + = + resetDecorators(); + assert simpleBean.echo1(1) =3D=3D 1; + assertDecorators(true, false, false); + = + resetDecorators(); + assert simpleBean.echo2(2) =3D=3D 2; + assertDecorators(false, true, false); + + //Only SimpleDecorator1 gets invoked, although I think SimpleDecorat= or2 should get invoked too + resetDecorators(); + assert simpleBean.echo3(3) =3D=3D 3; + assertDecorators(false, false, true); + = + resetDecorators(); + assert simpleBean.echo4(4) =3D=3D 4; = + assertDecorators(false, false, false); + } + = + private void resetDecorators() + { + SimpleDecorator1.reset(); + SimpleDecorator2.reset(); + } + = + private void assertDecorators(boolean echo1, boolean echo2, boolean ech= o3) + { + assert SimpleDecorator1.echo1 =3D=3D echo1; + assert SimpleDecorator1.echo3 =3D=3D echo3; + assert SimpleDecorator2.echo2 =3D=3D echo2; + assert SimpleDecorator2.echo3 =3D=3D echo3; + } +} + Added: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decor= ator/simple/beans.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorato= r/simple/beans.xml (rev 0) +++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/decorato= r/simple/beans.xml 2009-09-17 09:03:41 UTC (rev 3690) @@ -0,0 +1,6 @@ + = + + org.jboss.webbeans.test.unit.decorator.simple.SimpleDecorator= 1 + org.jboss.webbeans.test.unit.decorator.simple.SimpleDecorator= 2 + + --===============5184538720056811549==--