Author: marius.bogoevici
Date: 2010-04-27 14:33:24 -0400 (Tue, 27 Apr 2010)
New Revision: 6166
Modified:
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/AnimalInterceptor.java
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:
CDITCK-146 replace relying on getClass() by a polymorphic method overridden in each of
Animal's hierarchy classes
Modified:
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 2010-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Animal.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -22,4 +22,6 @@
{
}
+
+ public abstract String getAnimalType();
}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/AnimalInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/AnimalInterceptor.java 2010-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/AnimalInterceptor.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -26,13 +26,13 @@
class AnimalInterceptor
{
- private static Set<Class<?>> postConstructInterceptorCalledFor = new
HashSet<Class<?>>();
- private static Set<Class<?>> preDestroyInterceptorCalledFor = new
HashSet<Class<?>>();
+ private static Set<String> postConstructInterceptorCalledFor = new
HashSet<String>();
+ private static Set<String> preDestroyInterceptorCalledFor = new
HashSet<String>();
@PostConstruct
public void postConstruct(InvocationContext ctx)
{
- postConstructInterceptorCalledFor.add(ctx.getTarget().getClass());
+ postConstructInterceptorCalledFor.add(((Animal) ctx.getTarget()).getAnimalType());
try
{
ctx.proceed();
@@ -59,7 +59,7 @@
@PreDestroy
public void preDestroy(InvocationContext ctx)
{
- preDestroyInterceptorCalledFor.add(ctx.getTarget().getClass());
+ preDestroyInterceptorCalledFor.add(((Animal) ctx.getTarget()).getAnimalType());
try
{
ctx.proceed();
@@ -70,13 +70,13 @@
}
}
- public static boolean isPostConstructInterceptorCalled(Class<?> clazz)
+ public static boolean isPostConstructInterceptorCalled(String animalType)
{
- return postConstructInterceptorCalledFor.contains(clazz);
+ return postConstructInterceptorCalledFor.contains(animalType);
}
- public static boolean isPreDestroyInterceptorCalled(Class<?> clazz)
+ public static boolean isPreDestroyInterceptorCalled(String animalType)
{
- return preDestroyInterceptorCalledFor.contains(clazz);
+ return preDestroyInterceptorCalledFor.contains(animalType);
}
}
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-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Cow.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -25,9 +25,12 @@
@RequestScoped
class Cow extends Animal
{
+ protected static final String COW = "Cow";
+
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
+
@PostConstruct
public void postConstruct()
{
@@ -54,4 +57,10 @@
{
return preDestroyInterceptorCalled;
}
+
+ @Override
+ public String getAnimalType()
+ {
+ return COW;
+ }
}
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-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -23,9 +23,12 @@
@Interceptors(AnimalInterceptor.class)
class Goat extends Animal
{
+ protected static final String GOAT = "Goat";
+
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
+
@PostConstruct
public void postConstruct()
{
@@ -52,4 +55,10 @@
{
return preDestroyInterceptorCalled;
}
+
+ @Override
+ public String getAnimalType()
+ {
+ return GOAT;
+ }
}
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-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Hen.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -25,6 +25,8 @@
@ApplicationScoped
class Hen extends Animal
{
+ protected static final String HEN = "Hen";
+
private static boolean postConstructInterceptorCalled = false;
private static boolean preDestroyInterceptorCalled = false;
@@ -54,4 +56,10 @@
{
return preDestroyInterceptorCalled;
}
+
+ @Override
+ public String getAnimalType()
+ {
+ return HEN;
+ }
}
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-04-27
08:34:27 UTC (rev 6165)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java 2010-04-27
18:33:24 UTC (rev 6166)
@@ -35,13 +35,13 @@
{
getInstanceByType(Goat.class);
assert Goat.isPostConstructInterceptorCalled();
- assert AnimalInterceptor.isPostConstructInterceptorCalled(Goat.class);
+ assert AnimalInterceptor.isPostConstructInterceptorCalled(Goat.GOAT);
getInstanceByType(Hen.class).toString();
assert Hen.isPostConstructInterceptorCalled();
- assert AnimalInterceptor.isPostConstructInterceptorCalled(Hen.class);
+ assert AnimalInterceptor.isPostConstructInterceptorCalled(Hen.HEN);
getInstanceByType(Cow.class).toString();
assert Cow.isPostConstructInterceptorCalled();
- assert AnimalInterceptor.isPostConstructInterceptorCalled(Cow.class);
+ assert AnimalInterceptor.isPostConstructInterceptorCalled(Cow.COW);
}
@Test
@@ -51,13 +51,13 @@
{
createAndDestroyInstance(Goat.class);
assert Goat.isPreDestroyInterceptorCalled();
- assert AnimalInterceptor.isPreDestroyInterceptorCalled(Goat.class);
+ assert AnimalInterceptor.isPreDestroyInterceptorCalled(Goat.GOAT);
createAndDestroyInstance(Hen.class);
assert Hen.isPreDestroyInterceptorCalled();
- assert AnimalInterceptor.isPreDestroyInterceptorCalled(Hen.class);
+ assert AnimalInterceptor.isPreDestroyInterceptorCalled(Hen.HEN);
createAndDestroyInstance(Cow.class);
assert Cow.isPreDestroyInterceptorCalled();
- assert AnimalInterceptor.isPreDestroyInterceptorCalled(Cow.class);
+ assert AnimalInterceptor.isPreDestroyInterceptorCalled(Cow.COW);
}
@SuppressWarnings("unchecked")
Show replies by date