diff --git a/impl/src/main/java/org/jboss/cdi/tck/interceptors/tests/contract/invocationContext/InvocationContextTest.java b/impl/src/main/java/org/jboss/cdi/tck/interceptors/tests/contract/invocationContext/InvocationContextTest.java index 96201ac8c..95cae963b 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/interceptors/tests/contract/invocationContext/InvocationContextTest.java +++ b/impl/src/main/java/org/jboss/cdi/tck/interceptors/tests/contract/invocationContext/InvocationContextTest.java @@ -56,7 +56,7 @@ public void testGetTargetMethod() { SimpleBean instance = getContextualReference(SimpleBean.class); instance.setId(10); assertEquals(instance.getId(), 10); - assertSame(Interceptor1.getTarget(), instance); + assertEquals(Interceptor1.getTarget().getId(), 10); } @Test diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/InterceptorBindingInheritanceTest.java b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/InterceptorBindingInheritanceTest.java index 400ee962c..18093063d 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/InterceptorBindingInheritanceTest.java +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/InterceptorBindingInheritanceTest.java @@ -52,48 +52,54 @@ public static WebArchive createTestArchive() { @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = TYPE_LEVEL_INHERITANCE, id = "ad"), @SpecAssertion(section = TYPE_LEVEL_INHERITANCE, id = "ada") }) public void testInterceptorBindingDirectlyInheritedFromManagedBean(Larch larch) throws Exception { + Plant.clearInspections(); larch.pong(); - assertTrue(Plant.inspectedBy(larch, squirrel)); - assertFalse(Plant.inspectedBy(larch, woodpecker)); + assertTrue(Plant.inspectedBy(squirrel)); + assertFalse(Plant.inspectedBy(woodpecker)); } @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = TYPE_LEVEL_INHERITANCE, id = "aj"), @SpecAssertion(section = TYPE_LEVEL_INHERITANCE, id = "aja") }) public void testInterceptorBindingIndirectlyInheritedFromManagedBean(@European Larch europeanLarch) throws Exception { + Plant.clearInspections(); europeanLarch.pong(); assertTrue(europeanLarch instanceof EuropeanLarch); - assertTrue(Plant.inspectedBy(europeanLarch, squirrel)); - assertFalse(Plant.inspectedBy(europeanLarch, woodpecker)); + assertTrue(Plant.inspectedBy(squirrel)); + assertFalse(Plant.inspectedBy(woodpecker)); } @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = MEMBER_LEVEL_INHERITANCE, id = "ka") public void testMethodInterceptorBindingDirectlyInheritedFromManagedBean(Herb herb) { + Plant.clearInspections(); herb.pong(); - assertTrue(Plant.inspectedBy(herb, squirrel)); + assertTrue(Plant.inspectedBy(squirrel)); } @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = MEMBER_LEVEL_INHERITANCE, id = "kc") public void testMethodInterceptorBindingIndirectlyInheritedFromManagedBean(@Culinary Herb thyme) { + Plant.clearInspections(); thyme.pong(); assertTrue(thyme instanceof Thyme); - assertTrue(Plant.inspectedBy(thyme, squirrel)); + assertTrue(Plant.inspectedBy(squirrel)); } @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = MEMBER_LEVEL_INHERITANCE, id = "ka") public void testMethodInterceptorBindingDirectlyNotInheritedFromManagedBean(Shrub shrub) { + Plant.clearInspections(); shrub.pong(); - assertFalse(Plant.inspectedBy(shrub, squirrel)); + assertFalse(Plant.inspectedBy(squirrel)); } @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = MEMBER_LEVEL_INHERITANCE, id = "kc") public void testMethodInterceptorBindingIndirectlyNotInheritedFromManagedBean(@Culinary Shrub rosehip) { + Plant.clearInspections(); rosehip.pong(); assertTrue(rosehip instanceof Rosehip); - assertFalse(Plant.inspectedBy(rosehip, squirrel)); + assertFalse(Plant.inspectedBy(squirrel)); } } diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/Plant.java b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/Plant.java index 44573212f..f44c8c8c2 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/Plant.java +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/Plant.java @@ -21,16 +21,18 @@ public abstract class Plant implements Ping { - private List inspections = new ArrayList(); + private static List inspections = new ArrayList(); - // all beans of type `Plant` are `@Dependent`, so accessing the field is OK + public static void clearInspections() { + inspections.clear(); + } - public static void inspect(Plant plant, String id) { - plant.inspections.add(id); + public static void inspect(String id) { + inspections.add(id); } - public static boolean inspectedBy(Plant plant, String id) { - return plant.inspections.contains(id); + public static boolean inspectedBy(String id) { + return inspections.contains(id); } } diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/SquirrelInterceptor.java b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/SquirrelInterceptor.java index 37c1e9ab0..ecec83c85 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/SquirrelInterceptor.java +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/SquirrelInterceptor.java @@ -32,7 +32,7 @@ public Object intercept(InvocationContext ctx) throws Exception { Object target = ctx.getTarget(); if (target instanceof Plant) { - Plant.inspect((Plant) target, SquirrelInterceptor.class.getName()); + Plant.inspect(SquirrelInterceptor.class.getName()); } return ctx.proceed(); } diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/WoodpeckerInterceptor.java b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/WoodpeckerInterceptor.java index 9c466066a..15eeb577e 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/WoodpeckerInterceptor.java +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/interceptors/definition/inheritance/WoodpeckerInterceptor.java @@ -32,7 +32,7 @@ public Object intercept(InvocationContext ctx) throws Exception { Object target = ctx.getTarget(); if (target instanceof Plant) { - Plant.inspect((Plant) target, WoodpeckerInterceptor.class.getName()); + Plant.inspect(WoodpeckerInterceptor.class.getName()); } return ctx.proceed(); }