Author: mwringe
Date: 2012-01-18 14:32:20 -0500 (Wed, 18 Jan 2012)
New Revision: 8303
Added:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPINativeSkipTestCase.java
components/wci/trunk/test/portlets/native-skipped-portlet/
components/wci/trunk/test/portlets/native-skipped-portlet/pom.xml
components/wci/trunk/test/portlets/native-skipped-portlet/src/
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/WEB-INF/
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/WEB-INF/web.xml
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/.settings/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/pom.xml
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/WEB-INF/
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/WEB-INF/web.xml
Log:
GTNPC-76: committing tests for issue
Added:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPINativeSkipTestCase.java
===================================================================
---
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPINativeSkipTestCase.java
(rev 0)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPINativeSkipTestCase.java 2012-01-18
19:32:20 UTC (rev 8303)
@@ -0,0 +1,205 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2011, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.gatein.wci.spi;
+
+import static org.jboss.unit.api.Assert.fail;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.gatein.wci.ServletContainer;
+import org.gatein.wci.ServletContextDispatcher;
+import org.gatein.wci.ServletTestCase;
+import org.gatein.wci.TestServlet;
+import org.gatein.wci.WebApp;
+import org.gatein.wci.WebAppRegistry;
+import org.gatein.wci.WebRequest;
+import org.gatein.wci.WebResponse;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.spi.callbacks.ExceptionCallback;
+import org.gatein.wci.spi.callbacks.NormalCallback;
+import org.jboss.unit.Failure;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.remote.driver.handler.deployer.response.DeployResponse;
+import org.jboss.unit.remote.driver.handler.deployer.response.UndeployResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+/**
+ * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class SPINativeSkipTestCase extends ServletTestCase
+{
+
+ /** . */
+ private WebAppRegistry registry;
+
+ /** . */
+ private Set<String> keys;
+
+ /** . */
+ private ServletContainer container;
+
+
+ @Override
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse
resp) throws ServletException,
+ IOException
+ {
+ System.out.println("SERVICE GETREQUESTCOUNT : " + getRequestCount());
+ if (getRequestCount() == 2)
+ {
+ // Check that this web app is here
+ String key = req.getContextPath();
+ if (!keys.contains(key))
+ {
+ fail("The current test web app with key " + key + " is not
seen as deployed among " + keys);
+ }
+
+ // Should try
+ ServletContext appContext =
testServlet.getServletContext().getContext("/test-native-skip-with-gateinservlet-app");
+
+ //
+ if (appContext == null)
+ {
+ fail("Cannot get access to the /test-native-skip-with-gateinservlet-app
context");
+ }
+
+ //
+ WebApp webApp =
registry.getWebApp("/test-native-skip-with-gateinservlet-app");
+ NormalCallback cb1 = new NormalCallback(appContext, webApp.getClassLoader());
+ Exception ex = new Exception();
+ ExceptionCallback cb2 = new ExceptionCallback(appContext, ex, ex);
+ Error err = new Error();
+ ExceptionCallback cb3 = new ExceptionCallback(appContext, err, err);
+ RuntimeException rex = new RuntimeException();
+ ExceptionCallback cb4 = new ExceptionCallback(appContext, rex, rex);
+ IOException ioe = new IOException();
+ ExceptionCallback cb5 = new ExceptionCallback(appContext, ioe, ioe);
+
+ //
+ ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp,
container);
+ DriverResponse response = cb1.test(null, dispatcher);
+ response = cb2.test(response, dispatcher);
+ response = cb3.test(response, dispatcher);
+ response = cb4.test(response, dispatcher);
+ response = cb5.test(response, dispatcher);
+
+ return new
UndeployResponse("test-native-skip-with-gateinservlet-app.war");
+ }
+
+ else if (getRequestCount() == 3)
+ {
+ return new UndeployResponse("test-native-skip-app.war");
+ }
+ else if (getRequestCount() == 4)
+ {
+ return new EndTestResponse();
+ }
+ else
+ {
+ return new FailureResponse(Failure.createAssertionFailure("Test not
expected to reach RequestCount of " + getRequestCount()));
+ }
+ }
+
+ @Override
+ public DriverResponse invoke(TestServlet testServlet, DriverCommand driverCommand)
+ {
+ System.out.println("INVOKE GETREQUESTCOUNT : " + getRequestCount());
+ if (getRequestCount() == -1)
+ {
+ container = DefaultServletContainerFactory.getInstance().getServletContainer();
+ if (container == null)
+ {
+ return new FailureResponse(Failure.createAssertionFailure("No servlet
container present"));
+ }
+
+ // Register and save the deployed web apps
+ registry = new WebAppRegistry();
+ container.addWebAppListener(registry);
+ keys = new HashSet<String>(registry.getKeys());
+
+ // Deploy the web app with init param of gatein.wci.native.DisableRegistration
set to true
+ return new DeployResponse("test-native-skip-app.war");
+ }
+ else if (getRequestCount() == 0)
+ {
+ //make sure the test-native-skip-app.war is actually skipped
+ if (registry.getWebApp("/test-native-skip-app") != null)
+ {
+ return new FailureResponse(Failure.createAssertionFailure("The
test-native-skip-app.war should not be seen by the native implemetentation."));
+ }
+
+ // Compute the difference with the previous deployed web apps
+ Set diff = new HashSet<String>(registry.getKeys());
+ diff.removeAll(keys);
+
+ // It should be 0, since the test-native-skip-app.war should not get registered
by the native implementation
+ if (diff.size() != 0)
+ {
+ return new FailureResponse(Failure.createAssertionFailure("The size of
the new web application deployed should be 0, it is " + diff.size() + "
instead." +
+ "The previous set was " + keys + " and the new set is " +
registry.getKeys()));
+ }
+
+ return new
DeployResponse("test-native-skip-with-gateinservlet-app.war");
+ }
+ else if (getRequestCount() == 1)
+ {
+ // Compute the difference with the previous deployed web apps
+ Set diff = new HashSet<String>(registry.getKeys());
+ diff.removeAll(keys);
+
+ // It should be 1
+ if (diff.size() != 1)
+ {
+ return new FailureResponse(Failure.createAssertionFailure("The size of
the new web application deployed should be 1, it is " + diff.size() + "
instead." +
+ "The previous set was " + keys + " and the new set is " +
registry.getKeys()));
+ }
+
+ WebApp webapp =
registry.getWebApp("/test-native-skip-with-gateinservlet-app");
+ //make sure the test-native-skip-with-gateinservlet-app.war is picked up
+ if (webapp== null)
+ {
+ return new FailureResponse(Failure.createAssertionFailure("The
test-native-skip-with-gateinservler-app.war should be seen."));
+ }
+ if
(!webapp.getContextPath().equals("/test-native-skip-with-gateinservlet-app"))
+ {
+ return new FailureResponse(Failure.createAssertionFailure("The web app
context is not equals to the expected value but has the value " +
webapp.getContextPath()));
+ }
+ return new InvokeGetResponse("/test-spi-server");
+ }
+ else
+ {
+ return new FailureResponse(new Failure("Test not expected to reach
RequestCount of " + getRequestCount(), FailureType.ERROR));
+ }
+ }
+
+}
+
Property changes on:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPINativeSkipTestCase.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: components/wci/trunk/test/portlets/native-skipped-portlet/pom.xml
===================================================================
--- components/wci/trunk/test/portlets/native-skipped-portlet/pom.xml
(rev 0)
+++ components/wci/trunk/test/portlets/native-skipped-portlet/pom.xml 2012-01-18 19:32:20
UTC (rev 8303)
@@ -0,0 +1,12 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-test-portlets</artifactId>
+ <version>2.1.1-Beta01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>wci-test-native-skipped-portlet</artifactId>
+ <version>2.1.1-Beta01-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>GateIn - WCI Native Skip Test Portlet</name>
+</project>
Added:
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++
components/wci/trunk/test/portlets/native-skipped-portlet/src/main/webapp/WEB-INF/web.xml 2012-01-18
19:32:20 UTC (rev 8303)
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <!-- Disable the Native Application Registration -->
+ <context-param>
+ <param-name>gatein.wci.native.DisableRegistration</param-name>
+ <param-value>true</param-value>
+ </context-param>
+</web-app>
+
Added:
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/pom.xml
===================================================================
--- components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/pom.xml
(rev 0)
+++
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/pom.xml 2012-01-18
19:32:20 UTC (rev 8303)
@@ -0,0 +1,12 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-test-portlets</artifactId>
+ <version>2.1.1-Beta01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
<artifactId>wci-test-native-skipped-with-gateinservlet-portlet</artifactId>
+ <version>2.1.1-Beta01-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>GateIn - WCI Native Skip Test Portlet With GateInServlet
Registration</name>
+</project>
Added:
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++
components/wci/trunk/test/portlets/native-skipped-with-gateinservlet-portlet/src/main/webapp/WEB-INF/web.xml 2012-01-18
19:32:20 UTC (rev 8303)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <!-- Disable the Native Application Registration -->
+ <context-param>
+ <param-name>gatein.wci.native.DisableRegistration</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- Register Using the Generic Method -->
+ <servlet>
+ <servlet-name>GateInServlet</servlet-name>
+ <servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>GateInServlet</servlet-name>
+ <url-pattern>/gateinservlet</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+