Author: jharting
Date: 2010-02-19 05:22:10 -0500 (Fri, 19 Feb 2010)
New Revision: 5890
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Animal.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Cow.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Hen.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java
Log:
Updated test for lifecycle callback interceptors on a normal scoped bean.
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Animal.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Animal.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Animal.java 2010-02-19
10:22:10 UTC (rev 5890)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.interceptors.tests.lifecycleCallback;
+
+public abstract class Animal
+{
+ void foo()
+ {
+
+ }
+}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Cow.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Cow.java 2010-02-19
09:59:00 UTC (rev 5889)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Cow.java 2010-02-19
10:22:10 UTC (rev 5890)
@@ -23,7 +23,7 @@
@Interceptors(AnimalInterceptor.class)
@RequestScoped
-class Cow
+class Cow extends Animal
{
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java 2010-02-19
09:59:00 UTC (rev 5889)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java 2010-02-19
10:22:10 UTC (rev 5890)
@@ -21,7 +21,7 @@
import javax.interceptor.Interceptors;
@Interceptors(AnimalInterceptor.class)
-class Goat
+class Goat extends Animal
{
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Hen.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Hen.java 2010-02-19
09:59:00 UTC (rev 5889)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Hen.java 2010-02-19
10:22:10 UTC (rev 5890)
@@ -23,7 +23,7 @@
@Interceptors(AnimalInterceptor.class)
@ApplicationScoped
-class Hen
+class Hen extends Animal
{
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java 2010-02-19
09:59:00 UTC (rev 5889)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java 2010-02-19
10:22:10 UTC (rev 5890)
@@ -31,16 +31,15 @@
{
@Test
@SpecAssertion(section = "5", id = "a")
- // WELD-436
public void testPostConstructInterceptor()
{
getInstanceByType(Goat.class);
assert Goat.isPostConstructInterceptorCalled();
assert AnimalInterceptor.isPostConstructInterceptorCalled(Goat.class);
- getInstanceByType(Hen.class);
+ getInstanceByType(Hen.class).toString();
assert Hen.isPostConstructInterceptorCalled();
assert AnimalInterceptor.isPostConstructInterceptorCalled(Hen.class);
- getInstanceByType(Cow.class);
+ getInstanceByType(Cow.class).toString();
assert Cow.isPostConstructInterceptorCalled();
assert AnimalInterceptor.isPostConstructInterceptorCalled(Cow.class);
}
@@ -56,17 +55,18 @@
createAndDestroyInstance(Hen.class);
assert Hen.isPreDestroyInterceptorCalled();
assert AnimalInterceptor.isPreDestroyInterceptorCalled(Hen.class);
- createAndDestroyInstance(Hen.class);
- assert Hen.isPreDestroyInterceptorCalled();
- assert AnimalInterceptor.isPreDestroyInterceptorCalled(Hen.class);
+ createAndDestroyInstance(Cow.class);
+ assert Cow.isPreDestroyInterceptorCalled();
+ assert AnimalInterceptor.isPreDestroyInterceptorCalled(Cow.class);
}
@SuppressWarnings("unchecked")
- private <T> void createAndDestroyInstance(Class<T> clazz)
+ private <T extends Animal> void createAndDestroyInstance(Class<T> clazz)
{
- Bean<T> bean = getBeans(clazz).iterator().next();
+ Bean<T> bean = getUniqueBean(clazz);
CreationalContext<T> ctx =
getCurrentManager().createCreationalContext(bean);
T instance = (T) getCurrentManager().getReference(bean, clazz, ctx);
+ instance.foo(); // invoke method so that the instance is actually created
// destroy the instance
bean.destroy(instance, ctx);
}