Author: dallen6
Date: 2009-04-01 07:57:18 -0400 (Wed, 01 Apr 2009)
New Revision: 2290
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
Log:
A few more context tests for request scope
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-03-31
23:29:11 UTC (rev 2289)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -66,11 +66,11 @@
{
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
- TextPage firstRequestResult = webClient.getPage(getContextPath() +
"IntrospectApplication");
+ TextPage firstRequestResult = webClient.getPage(getContextPath() +
"IntrospectRequestScope");
assert firstRequestResult.getContent() != null;
assert Double.parseDouble(firstRequestResult.getContent()) != 0;
// Make a second request and make sure the same context is used
- TextPage secondRequestResult = webClient.getPage(getContextPath() +
"IntrospectApplication");
+ TextPage secondRequestResult = webClient.getPage(getContextPath() +
"IntrospectRequestScope");
assert secondRequestResult.getContent() != null;
assert Double.parseDouble(secondRequestResult.getContent()) ==
Double.parseDouble(firstRequestResult.getContent());
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java 2009-03-31
23:29:11 UTC (rev 2289)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -3,30 +3,33 @@
class NearMiss
{
private SimpleApplicationBean bean;
- private boolean sameBean = false;
+ private boolean sameBean = false;
public SimpleApplicationBean getBean()
{
return bean;
}
+
public void setBean(SimpleApplicationBean bean)
{
if (this.bean == null)
{
- this.bean = bean;
+ this.bean = bean;
}
else
{
sameBean = this.bean.getId() == bean.getId();
}
}
+
public boolean isSameBean()
{
return sameBean;
}
+
public void setSameBean(boolean sameBean)
{
this.sameBean = sameBean;
}
-
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java 2009-03-31
23:29:11 UTC (rev 2289)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -19,6 +19,10 @@
{
applicationScopeActive = true;
}
+ else
+ {
+ applicationScopeActive = false;
+ }
}
public void drawNearMiss(@Observes @Asynchronously NearMiss event)
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/FilterTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,55 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import java.io.IOException;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class FilterTest implements Filter
+{
+ @Current
+ private Manager jsr299Manager;
+
+ public void destroy()
+ {
+ jsr299Manager = null;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
+ {
+ if (!jsr299Manager.getContext(ApplicationScoped.class).isActive())
+ {
+ throw new ServletException("Application context is not active");
+ }
+ else
+ {
+ chain.doFilter(request, response);
+ }
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ if (jsr299Manager == null)
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/IntrospectApplication.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,50 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import java.io.IOException;
+
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class IntrospectRequestScope extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Current
+ private Manager jsr299Manager;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ resp.setContentType("text/text");
+ SimpleRequestBean aBean =
jsr299Manager.getInstanceByType(SimpleRequestBean.class);
+ resp.getWriter().print(aBean.getId());
+ }
+
+ @Override
+ public void init() throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ init();
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-03-31
23:29:11 UTC (rev 2289)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -4,14 +4,24 @@
import org.jboss.jsr299.tck.AbstractJSR299Test;
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.Resources;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
import org.testng.annotations.Test;
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+
/**
*
* Spec version: PRD2
*/
@Artifact
-@IntegrationTest
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION,
source="web.xml"),
+ @Resource(destination="SimplePage.html", source="SimplePage.html")
+})
public class RequestContextTest extends AbstractJSR299Test
{
@@ -19,34 +29,50 @@
* The request scope is active during the service() method of any Servlet in
* the web application.
*/
- @Test(groups = { "stub", "contexts", "servlet",
"integration" })
+ @Test(groups = { "contexts", "servlet", "integration"
})
@SpecAssertion(section = "8.5.1", id = "a")
- public void testRequestScopeActiveDuringServiceMethod()
+ public void testRequestScopeActiveDuringServiceMethod() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ webClient.getPage(getContextPath() + "serviceMethodTest");
}
-
/**
* The request scope is active during the doFilter() method of any Servlet in
* the web application.
*/
- @Test(groups = { "stub", "contexts", "servlet",
"integration" })
+ @Test(groups = { "contexts", "servlet", "integration"
})
@SpecAssertion(section = "8.5.1", id = "b")
- public void testRequestScopeActiveDuringServletFilter()
+ public void testRequestScopeActiveDuringServletFilter() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ webClient.getPage(getContextPath() + "SimplePage.html");
}
/**
* The request context is destroyed at the end of the servlet request, after
* the Servlet service() method returns.
*/
- @Test(groups = { "stub", "contexts", "servlet",
"integration" })
+ @Test(groups = { "contexts", "servlet", "integration"
})
@SpecAssertion(section = "8.5.1", id = "c")
- public void testRequestScopeIsDestroyedAfterServiceMethod()
+ public void testRequestScopeIsDestroyedAfterServletRequest() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ TextPage firstRequestResult = webClient.getPage(getContextPath() +
"IntrospectRequest");
+ assert firstRequestResult.getContent() != null;
+ assert Double.parseDouble(firstRequestResult.getContent()) != 0;
+ // Make a second request and make sure the same context is not there
+ TextPage secondRequestResult = webClient.getPage(getContextPath() +
"IntrospectRequest");
+ assert secondRequestResult.getContent() != null;
+ assert Double.parseDouble(secondRequestResult.getContent()) !=
Double.parseDouble(firstRequestResult.getContent());
+
+ // As final confirmation that the context was destroyed, check that its beans
+ // were also destroyed.
+// TextPage beanDestructionResult = webClient.getPage(getContextPath() +
"InvalidateSession?isBeanDestroyed");
+// assert Boolean.parseBoolean(beanDestructionResult.getContent());
}
/**
@@ -71,27 +97,6 @@
}
/**
- * The request scope is active during any asynchronous observer method notification
- */
- @Test(groups = { "stub", "contexts", "integration" })
- @SpecAssertion(section = "8.5.1", id = "f")
- public void testRequestScopeIsActiveDuringAsynchronousObserverMethodInvocation()
- {
- assert false;
- }
-
- /**
- * The request context is destroyed after the web service invocation
- * completes
- */
- @Test(groups = { "stub", "contexts", "integration" })
- @SpecAssertion(section = "8.5.1", id = "g")
- public void testRequestScopeIsDestroyedAfterAsynchronousObserverMethodInvocation()
- {
- assert false;
- }
-
- /**
* The request scope is active during any remote method invocation of any EJB
* bean, during any call to an EJB timeout method and during message delivery
* to any EJB message driven bean.
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ServiceMethodServlet.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,87 @@
+/*
+ * 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.context.request;
+
+import java.io.IOException;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet used just to test context during service method.
+ *
+ * @author David Allen
+ *
+ */
+public class ServiceMethodServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ @Current
+ private Manager jsr299Manager;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ if (!jsr299Manager.getContext(ApplicationScoped.class).isActive())
+ {
+ throw new ServletException("Application context is not active");
+ }
+ else
+ {
+ super.service(req, resp);
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ resp.setContentType("text/text");
+ resp.getWriter().println("It worked!");
+ }
+
+ @Override
+ public void init() throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ init();
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import javax.context.RequestScoped;
+
+@RequestScoped
+public class SimpleRequestBean
+{
+ private double id = Math.random();
+
+ public double getId()
+ {
+ return id;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,35 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+class NearMiss
+{
+ private SimpleRequestBean bean;
+ private boolean sameBean = false;
+
+ public SimpleRequestBean getBean()
+ {
+ return bean;
+ }
+
+ public void setBean(SimpleRequestBean bean)
+ {
+ if (this.bean == null)
+ {
+ this.bean = bean;
+ }
+ else
+ {
+ sameBean = this.bean.getId() == bean.getId();
+ }
+ }
+
+ public boolean isSameBean()
+ {
+ return sameBean;
+ }
+
+ public void setSameBean(boolean sameBean)
+ {
+ this.sameBean = sameBean;
+ }
+
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/ApplicationContextTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,62 @@
+/*
+ * 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.context.request.standalone;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * @author David Allen
+ *
+ * Spec version: PRD2
+ *
+ */
+@Artifact
+public class RequestContextTest extends AbstractJSR299Test
+{
+ /**
+ * The request scope is active during any asynchronous observer method notification
+ */
+ @Test(groups = { "ri-broken", "contexts", "integration"
})
+ @SpecAssertion(section = "8.5.1", id = "f")
+ public void testRequestScopeIsActiveDuringAsynchronousObserverMethodInvocation()
throws Exception
+ {
+ getCurrentManager().fireEvent(new TargetEvent());
+ Thread.sleep(200);
+ assert TcasDisplay.isRequestScopeActive();
+ }
+
+ /**
+ * The request context is destroyed after the asynchronous observer method
notification
+ * completes
+ */
+ @Test(groups = { "contexts", "integration" })
+ @SpecAssertion(section = "8.5.1", id = "g")
+ public void testRequestScopeIsDestroyedAfterAsynchronousObserverMethodInvocation()
throws Exception
+ {
+ NearMiss event = new NearMiss();
+ getCurrentManager().fireEvent(event);
+ Thread.sleep(200);
+ getCurrentManager().fireEvent(event);
+ Thread.sleep(200);
+ assert !event.isSameBean();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/SimpleApplicationBean.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+import javax.context.RequestScoped;
+
+@RequestScoped
+class SimpleRequestBean
+{
+ private double id = Math.random();
+
+ public double getId()
+ {
+ return id;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TargetEvent.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+class TargetEvent
+{
+
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,42 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+import javax.context.RequestScoped;
+import javax.event.Asynchronously;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+class TcasDisplay
+{
+ @Current
+ private Manager manager;
+
+ private static boolean requestScopeActive = false;
+
+ public void drawTarget(@Observes @Asynchronously TargetEvent targetEvent)
+ {
+ if (manager.getContext(RequestScoped.class).isActive())
+ {
+ requestScopeActive = true;
+ }
+ else
+ {
+ requestScopeActive = false;
+ }
+ }
+
+ public void drawNearMiss(@Observes @Asynchronously NearMiss event)
+ {
+ event.setBean(manager.getInstanceByType(SimpleRequestBean.class));
+ }
+
+ public static boolean isRequestScopeActive()
+ {
+ return requestScopeActive;
+ }
+
+ public static void setRequestScopeActive(boolean requestScopeActive)
+ {
+ TcasDisplay.requestScopeActive = requestScopeActive;
+ }
+}
Copied:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html
(from rev 2289,
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/session/SimplePage.html)
===================================================================
---
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html
(rev 0)
+++
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,11 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"
lang="de">
+<head>
+</head>
+
+<body>
+</body>
+
+</html>
Copied:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml (from
rev 2289,
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/session/web.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml
(rev 0)
+++
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml 2009-04-01
11:57:18 UTC (rev 2290)
@@ -0,0 +1,42 @@
+<?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">
+ <description>Test servlets used to test session contexts.</description>
+ <display-name>Session Context Tests</display-name>
+ <filter>
+ <display-name>Test Filter for Sessions</display-name>
+ <filter-name>filterTest</filter-name>
+
<filter-class>org.jboss.jsr299.tck.tests.context.request.FilterTest</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>filterTest</filter-name>
+ <url-pattern>/SimplePage.html</url-pattern>
+ </filter-mapping>
+ <listener>
+
<listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+ <servlet>
+ <display-name>serviceMethod</display-name>
+ <servlet-name>service</servlet-name>
+
<servlet-class>org.jboss.jsr299.tck.tests.context.request.ServiceMethodServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <display-name>Introspection Service for Request Context</display-name>
+ <servlet-name>requestIntrospector</servlet-name>
+
<servlet-class>org.jboss.jsr299.tck.tests.context.request.IntrospectRequestScope</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>service</servlet-name>
+ <url-pattern>/serviceMethodTest</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>requestIntrospector</servlet-name>
+ <url-pattern>/IntrospectRequest</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>