Author: jharting
Date: 2009-10-23 11:09:45 -0400 (Fri, 23 Oct 2009)
New Revision: 4236
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Car.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Garage.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
Log:
Test for 5.5 d)
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Car.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Car.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Car.java 2009-10-23
15:09:45 UTC (rev 4236)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.lookup.clientProxy;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+class Car implements Serializable
+{
+ private static final long serialVersionUID = -8183045197385584658L;
+ private String make = "unknown";
+
+ public String getMake()
+ {
+ return make;
+ }
+
+ public void setMake(String name)
+ {
+ this.make = name;
+ }
+}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-10-23
14:13:28 UTC (rev 4235)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-10-23
15:09:45 UTC (rev 4236)
@@ -62,26 +62,44 @@
assert tuna.getState().equals("tuned");
// TODO expand this test
}
- @Test
+ @Test(expectedExceptions = { ContextNotActiveException.class,
IllegalStateException.class })
@SpecAssertions({
@SpecAssertion(section="5.5.2", id="ab"),
@SpecAssertion(section = "6.5.4", id="a")
})
- public void testInactiveScope() throws Exception
+ public void testInactiveScope() throws Exception
{
assert getCurrentConfiguration().getContexts().getRequestContext().isActive();
setContextInactive(getCurrentConfiguration().getContexts().getRequestContext());
assert !getCurrentConfiguration().getContexts().getRequestContext().isActive();
- try {
+ try
+ {
getInstanceByType(TunedTuna.class).getState();
- assert false;
- } catch (ContextNotActiveException cnae) {
- } catch (IllegalStateException ise) {
- } catch (Throwable t) {
- assert false;
}
-
- // need to set request scope active again, some other tests will fail otherwise
+ finally
+ {
+ // need to set request scope active again, some other tests will fail otherwise
+ setContextActive(getCurrentConfiguration().getContexts().getRequestContext());
+ }
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "5.5", id = "d")
+ //WELD-229
+ public void testInvocationIsProcessedOnCurrentInstance() {
+ // create new car
+ getInstanceByType(Car.class).setMake("Honda");
+ // check that the car is injected
+ Garage garage = getInstanceByType(Garage.class);
+ assert garage.getMakeOfTheParkedCar().equals("Honda");
+ // destroy the request context
+ setContextInactive(getCurrentConfiguration().getContexts().getRequestContext());
setContextActive(getCurrentConfiguration().getContexts().getRequestContext());
+ // check that the old instance is not in the context anymore
+ // a new one should be created
+ assert getInstanceByType(Car.class).getMake().equals("unknown");
+ getInstanceByType(Car.class).setMake("Toyota");
+ // check that the invocation is processed by the current instance of injected bean
+ assert garage.getMakeOfTheParkedCar().equals("Toyota");
}
}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Garage.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Garage.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/Garage.java 2009-10-23
15:09:45 UTC (rev 4236)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.lookup.clientProxy;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+
+
+@ApplicationScoped
+class Garage
+{
+ @Inject
+ private Car car;
+
+ public String getMakeOfTheParkedCar()
+ {
+ return car.getMake();
+ }
+}
Show replies by date