[webbeans-commits] Webbeans SVN: r3363 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean: custom and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Jul 30 05:09:00 EDT 2009
Author: jharting
Date: 2009-07-30 05:09:00 -0400 (Thu, 30 Jul 2009)
New Revision: 3363
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/Cat.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CatBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CustomBeanImplementationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/House.java
Log:
Added tests for a custom implementation of Bean interface
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/Cat.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/Cat.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/Cat.java 2009-07-30 09:09:00 UTC (rev 3363)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.definition.bean.custom;
+
+class Cat
+{
+
+ @SuppressWarnings("unused")
+ private String name;
+
+ public Cat(String name)
+ {
+ this.name = name;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CatBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CatBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CatBean.java 2009-07-30 09:09:00 UTC (rev 3363)
@@ -0,0 +1,168 @@
+package org.jboss.jsr299.tck.tests.definition.bean.custom;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.deployment.Production;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
+
+class CatBean implements Bean<Cat>
+{
+ public static final CatBean bean = new CatBean();
+
+ private boolean getBindingsCalled = false;
+ private boolean getInjectionPointsCalled = false;
+ private boolean getNameCalled = false;
+ private boolean getScopeTypeCalled = false;
+ private boolean getTypesCalled = false;
+ private boolean isPolicyCalled = false;
+ private boolean isSerializableCalled = false;
+ private boolean isNullableCalled = false;
+ private boolean isGetBeanClassCalled = false;
+ private boolean getStereotypesCalled = false;
+
+
+ @SuppressWarnings("serial")
+ public Set<Annotation> getBindings()
+ {
+ getBindingsCalled = true;
+ return new HashSet<Annotation>(){{ add(new CurrentLiteral());}};
+ }
+
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Production.class;
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ getInjectionPointsCalled = true;
+ return new HashSet<InjectionPoint>();
+ }
+
+ public String getName()
+ {
+ getNameCalled = true;
+ return "cat";
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes() {
+ getStereotypesCalled = true;
+ return new HashSet<Class<? extends Annotation>>();
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ getScopeTypeCalled = true;
+ return Dependent.class;
+ }
+
+ @SuppressWarnings("serial")
+ public Set<Type> getTypes()
+ {
+ getTypesCalled = true;
+ return new HashSet<Type>() {{ add(Cat.class); add(Object.class); }};
+ }
+
+ public boolean isNullable()
+ {
+ isNullableCalled = true;
+ return false;
+ }
+
+ public boolean isSerializable()
+ {
+ isSerializableCalled = true;
+ return false;
+ }
+
+ public Class<?> getBeanClass()
+ {
+ isGetBeanClassCalled = true;
+ return Cat.class;
+ }
+
+ public boolean isPolicy()
+ {
+ isPolicyCalled = true;
+ return false;
+ }
+
+ public Cat create(CreationalContext<Cat> creationalContext)
+ {
+ return new Cat("kitty");
+ }
+
+ public void destroy(Cat instance, CreationalContext<Cat> creationalContext)
+ {
+ creationalContext.release();
+ }
+
+ public boolean isGetBindingsCalled()
+ {
+ return getBindingsCalled;
+ }
+
+ public boolean isGetInjectionPointsCalled()
+ {
+ return getInjectionPointsCalled;
+ }
+
+ public boolean isGetNameCalled()
+ {
+ return getNameCalled;
+ }
+
+ public boolean isGetScopeTypeCalled()
+ {
+ return getScopeTypeCalled;
+ }
+
+ public boolean isGetTypesCalled()
+ {
+ return getTypesCalled;
+ }
+
+ public boolean isPolicyCalled()
+ {
+ return isPolicyCalled;
+ }
+
+ public boolean isSerializableCalled()
+ {
+ return isSerializableCalled;
+ }
+
+ public boolean isNullableCalled()
+ {
+ return isNullableCalled;
+ }
+
+ public static CatBean getBean()
+ {
+ return bean;
+ }
+
+ public boolean isGetBeanClassCalled()
+ {
+ return isGetBeanClassCalled;
+ }
+
+ public boolean isGetStereotypesCalled()
+ {
+ return getStereotypesCalled;
+ }
+
+ public void afterDiscovery(@Observes AfterBeanDiscovery event) {
+ event.addBean(bean);
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CustomBeanImplementationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CustomBeanImplementationTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CustomBeanImplementationTest.java 2009-07-30 09:09:00 UTC (rev 3363)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.definition.bean.custom;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at SpecVersion("20090625")
+// TODO declare injection point on Cat and verify remaining assertions
+public class CustomBeanImplementationTest extends AbstractJSR299Test
+{
+
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section="5.1", id="b"),
+ @SpecAssertion(section="5.2", id="k")
+ })
+ //WBRI-328
+ public void testGetBeanClassCalled() {
+ assert CatBean.bean.isGetBeanClassCalled();
+ }
+
+ @Test(groups={"ri-broken"})
+ @SpecAssertion(section="5.2", id="k")
+ //WBRI-328
+ public void testGetStereotypesCalled() {
+ assert CatBean.bean.isGetStereotypesCalled();
+ }
+
+ @Test(groups={"ri-broken"})
+ @SpecAssertion(section="5.2", id="k")
+ //WBRI-328
+ public void testIsPolicyCalled() {
+ assert CatBean.bean.isPolicyCalled();
+ }
+
+ @Test
+ @SpecAssertion(section="5.3", id="na")
+ public void testGetTypesCalled() {
+ assert CatBean.bean.isGetTypesCalled();
+ }
+
+ @Test
+ @SpecAssertion(section="5.3", id="nb")
+ public void testGetBindingsCalled() {
+ assert CatBean.bean.isGetBindingsCalled();
+ }
+
+ @Test
+ @SpecAssertion(section="5.3.1", id="b")
+ public void testGetInjectionPointsCalled() {
+ assert CatBean.bean.isGetInjectionPointsCalled();
+ }
+
+ @Test(groups={"ri-broken"})
+ @SpecAssertion(section="5.3.4", id="ba")
+ //WBRI-328
+ public void testIsNullableCalled() {
+ assert CatBean.bean.isNullableCalled();
+ }
+
+ @Test
+ @SpecAssertion(section="5.4", id="e")
+ public void testGetNameCalled() {
+ assert CatBean.bean.isGetNameCalled();
+ }
+
+ @Test
+ @SpecAssertion(section="6.5.2", id="e")
+ public void testGetScopeTypeCalled() {
+ assert CatBean.bean.isGetScopeTypeCalled();
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/House.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/House.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/House.java 2009-07-30 09:09:00 UTC (rev 3363)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.definition.bean.custom;
+
+import javax.enterprise.inject.Current;
+
+class House
+{
+ @SuppressWarnings("unused")
+ @Current private Cat cat;
+}
More information about the weld-commits
mailing list