Author: jharting
Date: 2009-10-23 11:33:22 -0400 (Fri, 23 Oct 2009)
New Revision: 4237
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Car.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/ClientProxyTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Garage.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/TestServlet.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/web.xml
Log:
Test for 5.5 d)
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Car.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Car.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Car.java 2009-10-23
15:33:22 UTC (rev 4237)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.lookup.clientProxy.incontainer;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+class Car implements Serializable
+{
+ private static final long serialVersionUID = -5928715726257481259L;
+ private String make = "unknown";
+
+ public String getMake()
+ {
+ return make;
+ }
+
+ public void setMake(String name)
+ {
+ this.make = name;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/ClientProxyTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/ClientProxyTest.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/ClientProxyTest.java 2009-10-23
15:33:22 UTC (rev 4237)
@@ -0,0 +1,47 @@
+/*
+ * 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.lookup.clientProxy.incontainer;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+
+@Artifact
+@IntegrationTest(runLocally = true)
+@Resource(destination = WarArtifactDescriptor.WEB_XML_DESTINATION, source =
"web.xml")
+@SpecVersion(spec="cdi", version="20091018")
+public class ClientProxyTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "5.5", id = "d")
+ public void testInvocationIsProcessedOnCurrentInstance() throws Exception {
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ String response;
+ response = webClient.getPage(getContextPath() +
"Test/Garage?make=Honda").getWebResponse().getContentAsString();
+ assert response.contains("Honda");
+ response = webClient.getPage(getContextPath() +
"Test/Garage?make=Toyota").getWebResponse().getContentAsString();
+ assert response.contains("Toyota");
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Garage.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Garage.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/Garage.java 2009-10-23
15:33:22 UTC (rev 4237)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.lookup.clientProxy.incontainer;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+@ApplicationScoped
+class Garage
+{
+ @Inject
+ private Car car;
+
+ public String getMakeOfTheParkedCar()
+ {
+ return car.getMake();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/TestServlet.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/TestServlet.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/TestServlet.java 2009-10-23
15:33:22 UTC (rev 4237)
@@ -0,0 +1,36 @@
+package org.jboss.jsr299.tck.tests.lookup.clientProxy.incontainer;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TestServlet extends HttpServlet
+{
+ private static final long serialVersionUID = -4722487503814381947L;
+ @Inject
+ private Car car;
+ @Inject
+ private Garage garage;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ if (car.getMake().equals("unknown"))
+ {
+ // set the make of the car
+ car.setMake(req.getParameter("make"));
+ // make sure that the garage contains the current instance
+ resp.getWriter().append(garage.getMakeOfTheParkedCar());
+ resp.setContentType("text/plain");
+ resp.setStatus(200);
+ }
+ else
+ {
+ resp.setStatus(500);
+ }
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/web.xml
===================================================================
---
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/web.xml
(rev 0)
+++
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/clientProxy/incontainer/web.xml 2009-10-23
15:33:22 UTC (rev 4237)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>Dependency Injection Test</display-name>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.jsr299.tck.tests.lookup.clientProxy.incontainer.TestServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>JBoss Test Harness Test Runner</servlet-name>
+ <servlet-class>org.jboss.testharness.impl.runner.servlet.ServletTestRunner</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/Test/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JBoss Test Harness Test Runner</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+</web-app>