[weld-commits] Weld SVN: r5625 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/contexts/sessionInvalidation and 2 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Mon Jan 25 16:13:29 EST 2010
Author: pete.muir at jboss.org
Date: 2010-01-25 16:13:28 -0500 (Mon, 25 Jan 2010)
New Revision: 5625
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/.faces-config.xml.jsfdia
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/faces-config.xml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf
core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/web.xml
Log:
Test WELD-380
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.weld.tests.contexts.sessionInvalidation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+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.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+
+/**
+ * <p>Check what happens when session.invalidate() is called.</p>
+ *
+ * @author Pete Muir
+ *
+ */
+ at Artifact(addCurrentPackage=false)
+ at Classes({Storm.class})
+ at IntegrationTest(runLocally=true)
+ at Resources({
+ @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
+ @Resource(destination="storm.jspx", source="storm.jsf"),
+ @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
+})
+public class InvalidateSessionTest extends AbstractWeldTest
+{
+ @Test(description = "WELD-380")
+ public void testInvalidateSessionCalled() throws Exception
+ {
+ WebClient client = new WebClient();
+ client.setThrowExceptionOnFailingStatusCode(false);
+
+ HtmlPage page = client.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput invalidateSessionButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "invalidateSessionButton");
+ page = invalidateSessionButton.click();
+ }
+
+ protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
+ {
+ Set<T> result = new HashSet<T>();
+
+ for (HtmlElement element : rootElement.getAllHtmlChildElements())
+ {
+ result.addAll(getElements(element, elementClass));
+ }
+
+ if (elementClass.isInstance(rootElement))
+ {
+ result.add(elementClass.cast(rootElement));
+ }
+ return result;
+
+ }
+
+ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
+ {
+
+ Set<T> inputs = getElements(page.getBody(), elementClass);
+ for (T input : inputs)
+ {
+ if (input.getId().contains(id))
+ {
+ return input;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.weld.tests.contexts.sessionInvalidation;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpSession;
+
+ at Named
+public class Storm
+{
+
+ @Inject HttpSession session;
+
+ public String invalidateSession()
+ {
+ session.invalidate();
+ return "success";
+ }
+
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/.faces-config.xml.jsfdia
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/.faces-config.xml.jsfdia (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/.faces-config.xml.jsfdia 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS model-entity="JSFProcess"/>
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/faces-config.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/faces-config.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/faces-config.xml 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<faces-config version="1.2"
+ 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-facesconfig_1_2.xsd">
+
+</faces-config>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+ doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form id="form">
+ <h:commandButton action="#{storm.invalidateSession}" value="Invalidate Session" id="invalidateSessionButton"/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/web.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/web.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/web.xml 2010-01-25 21:13:28 UTC (rev 5625)
@@ -0,0 +1,27 @@
+<?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>Weld Core Tests</display-name>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jspx</param-value>
+ </context-param>
+ <!-- JSF -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list