[jboss-cvs] JBossAS SVN: r78253 - in trunk/testsuite: imports/sections and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 9 10:57:25 EDT 2008
Author: emuckenhuber
Date: 2008-09-09 10:57:25 -0400 (Tue, 09 Sep 2008)
New Revision: 78253
Added:
trunk/testsuite/src/main/org/jboss/test/web/test/VirtualHostTestCase.java
trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/
trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/jbossweb.sar/
trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/jbossweb.sar/server.xml
trunk/testsuite/src/resources/web/virtual/
trunk/testsuite/src/resources/web/virtual/index.html
trunk/testsuite/src/resources/web/virtual/jboss-web.xml
trunk/testsuite/src/resources/web/virtual/web.xml
Modified:
trunk/testsuite/build.xml
trunk/testsuite/imports/sections/web.xml
Log:
[JBAS-3918] test virtual host
Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml 2008-09-09 14:40:00 UTC (rev 78252)
+++ trunk/testsuite/build.xml 2008-09-09 14:57:25 UTC (rev 78253)
@@ -810,6 +810,7 @@
<!-- Tests needing tomcat WebCtxLoader set via the UseJBossWebLoader setting -->
<patternset id="tomcat.webctx.includes">
<include name="org/jboss/test/web/test/WebCtxLoaderTestCase.class"/>
+ <include name="org/jboss/test/web/test/VirtualHostTestCase.class"/>
</patternset>
<!-- ws-bpel integration tests -->
<patternset id="jbpm-bpel.includes">
Modified: trunk/testsuite/imports/sections/web.xml
===================================================================
--- trunk/testsuite/imports/sections/web.xml 2008-09-09 14:40:00 UTC (rev 78252)
+++ trunk/testsuite/imports/sections/web.xml 2008-09-09 14:57:25 UTC (rev 78253)
@@ -855,6 +855,15 @@
<include name="org/jboss/test/web/classloader/caseg/**"/>
</classes>
</war>
+ <war destfile="${build.lib}/jbossweb-virtual-host.war"
+ webxml="${build.resources}/web/virtual/web.xml">
+ <webinf dir="${build.resources}/web/virtual/">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ <fileset dir="${build.resources}/web/virtual">
+ <include name="**/*.html"/>
+ </fileset>
+ </war>
</target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/web/test/VirtualHostTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/VirtualHostTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/VirtualHostTestCase.java 2008-09-09 14:57:25 UTC (rev 78253)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.test.web.test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.web.HttpUtils;
+
+import com.meterware.httpunit.HttpException;
+
+/**
+ * Test virtual hosts.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class VirtualHostTestCase extends JBossTestCase
+{
+ /** The base URL. */
+ private String baseURL = HttpUtils.getBaseURL();
+
+ /** The web ctx url. */
+ private static final String webURL = "jbossweb-virtual-host/index.html";
+
+ /**
+ * @return the Test
+ * @throws Exception
+ */
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(VirtualHostTestCase.class, "jbossweb-virtual-host.war");
+ }
+
+ /**
+ * Create a new VirtualHostUnitTestCase.
+ *
+ * @param name the name
+ */
+ public VirtualHostTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the virtual.host
+ *
+ * @throws Exception
+ */
+ public void testVirtualHost() throws Exception
+ {
+ URL url = new URL(baseURL + webURL);
+ testHost(url, "virtual.host");
+ }
+
+ /**
+ * Test the virtual.alias
+ *
+ * @throws Exception
+ */
+ public void testVirtualAlias() throws Exception
+ {
+ URL url = new URL(baseURL + webURL);
+ testHost(url, "virtual.alias");
+ }
+
+ /**
+ * Check the response of the server based on a virtual host.
+ *
+ * @param url the url
+ * @param virtualHost the virtual host
+ * @throws Exception
+ */
+ protected void testHost(URL url, String virtualHost) throws Exception
+ {
+ HttpClient httpConn = new HttpClient();
+ HttpMethodBase request = new OverrideGetMethod(url.toString(), virtualHost);
+ int responseCode = httpConn.executeMethod(request);
+
+ if( responseCode != HttpURLConnection.HTTP_OK )
+ {
+ throw new IOException("Expected reply code:"+ HttpURLConnection.HTTP_OK
+ +", actual="+responseCode);
+ }
+ }
+
+ /**
+ * Test the non existing web app.
+ *
+ * @throws Exception
+ */
+ public void testNormalHost() throws Exception
+ {
+ URL url = new URL(baseURL + webURL);
+ Header[] hdrs = new Header[0];
+ HttpUtils.accessURL(url, null, HttpURLConnection.HTTP_NOT_FOUND, hdrs, HttpUtils.GET);
+ }
+
+ /**
+ * Override the GetMethod to add a specific host to the http header.
+ */
+ private static class OverrideGetMethod extends GetMethod
+ {
+ /** . */
+ private final String virtualHost;
+
+ public OverrideGetMethod(String url, String virtualHost)
+ {
+ super(url);
+ this.virtualHost = virtualHost;
+ }
+
+ /**
+ * Override the host header in the http request.
+ */
+ @Override
+ protected void addHostRequestHeader(HttpState state, HttpConnection conn)
+ throws IOException, HttpException
+ {
+ setRequestHeader("Host", virtualHost);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/jbossweb.sar/server.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/jbossweb.sar/server.xml (rev 0)
+++ trunk/testsuite/src/resources/test-configs/tomcat-webctx/deploy/jbossweb.sar/server.xml 2008-09-09 14:57:25 UTC (rev 78253)
@@ -0,0 +1,153 @@
+<Server>
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener" />
+
+ <Service name="jboss.web">
+
+ <!-- A HTTP/1.1 Connector on port 8080 -->
+ <Connector protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}"
+ connectionTimeout="20000" redirectPort="8443" />
+
+ <!-- A AJP 1.3 Connector on port 8009 -->
+ <Connector protocol="AJP/1.3" port="8009" address="${jboss.bind.address}"
+ redirectPort="8443" />
+
+ <Engine name="jboss.web" defaultHost="localhost">
+
+ <!-- The JAAS based authentication and authorization realm implementation
+ that is compatible with the jboss 3.2.x realm implementation.
+ - certificatePrincipal : the class name of the
+ org.jboss.security.auth.certs.CertificatePrincipal impl
+ used for mapping X509[] cert chains to a Princpal.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ -->
+ <Realm className="org.jboss.web.tomcat.security.JBossWebRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ <!-- A subclass of JBossSecurityMgrRealm that uses the authentication
+ behavior of JBossSecurityMgrRealm, but overrides the authorization
+ checks to use JACC permissions with the current java.security.Policy
+ to determine authorized access.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ <Realm className="org.jboss.web.tomcat.security.JaccAuthorizationRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ -->
+
+ <Host name="localhost">
+
+ <!-- Uncomment to enable request dumper. This Valve "logs interesting
+ contents from the specified Request (before processing) and the
+ corresponding Response (after processing). It is especially useful
+ in debugging problems related to headers and cookies."
+ -->
+ <!--
+ <Valve className="org.apache.catalina.valves.RequestDumperValve" />
+ -->
+
+ <!-- Access logger -->
+ <!--
+ <Valve className="org.apache.catalina.valves.AccessLogValve"
+ prefix="localhost_access_log." suffix=".log"
+ pattern="common" directory="${jboss.server.log.dir}"
+ resolveHosts="false" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host. Does not provide SSO across a cluster.
+
+ If this valve is used, do not use the JBoss ClusteredSingleSignOn
+ valve shown below.
+
+ A new configuration attribute is available beginning with
+ release 4.0.4:
+
+ cookieDomain configures the domain to which the SSO cookie
+ will be scoped (i.e. the set of hosts to
+ which the cookie will be presented). By default
+ the cookie is scoped to "/", meaning the host
+ that presented it. Set cookieDomain to a
+ wider domain (e.g. "xyz.com") to allow an SSO
+ to span more than one hostname.
+ -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host AND to all other hosts in the cluster.
+
+ If this valve is used, do not use the standard Tomcat SingleSignOn
+ valve shown above.
+
+ Valve uses a JBossCache instance to support SSO credential
+ caching and replication across the cluster. The JBossCache
+ instance must be configured separately. See the
+ "jboss-web-clusteredsso-beans.xml" file in the
+ server/all/deploy directory for cache configuration details.
+
+ Besides the attributes supported by the standard Tomcat
+ SingleSignOn valve (see the Tomcat docs), this version also
+ supports the following attributes:
+
+ cookieDomain see above
+
+ treeCacheName JMX ObjectName of the JBossCache MBean used to
+ support credential caching and replication across
+ the cluster. If not set, the default value is
+ "jboss.cache:service=ClusteredSSOCache"
+
+ maxEmptyLife The maximum number of seconds an SSO with no
+ active sessions will be usable by a request
+
+ processExpiresInterval The minimum number of seconds between
+ efforts by the valve to find and invalidate
+ SSO's that have exceeded their 'maxEmptyLife'.
+ Does not imply effort will be spent on such
+ cleanup every 'processExpiresInterval'.
+ -->
+ <!--
+ <Valve className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn" />
+ -->
+
+ <!-- Check for unclosed connections and transaction terminated checks
+ in servlets/jsps.
+
+ Important: The dependency on the CachedConnectionManager
+ in META-INF/jboss-service.xml must be uncommented, too
+ -->
+
+ <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
+ cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
+ transactionManagerObjectName="jboss:service=TransactionManager" />
+
+ </Host>
+
+ <Host name="virtual.host">
+ <Alias>virtual.alias</Alias>
+ <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
+ cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
+ transactionManagerObjectName="jboss:service=TransactionManager" />
+
+ </Host>
+
+ </Engine>
+
+ </Service>
+
+</Server>
\ No newline at end of file
Added: trunk/testsuite/src/resources/web/virtual/index.html
===================================================================
--- trunk/testsuite/src/resources/web/virtual/index.html (rev 0)
+++ trunk/testsuite/src/resources/web/virtual/index.html 2008-09-09 14:57:25 UTC (rev 78253)
@@ -0,0 +1,8 @@
+<html>
+<head>
+ <title>Simple html</title>
+</head>
+<body>
+Done.
+</body>
+</html>
\ No newline at end of file
Added: trunk/testsuite/src/resources/web/virtual/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/web/virtual/jboss-web.xml (rev 0)
+++ trunk/testsuite/src/resources/web/virtual/jboss-web.xml 2008-09-09 14:57:25 UTC (rev 78253)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-web
+ PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <virtual-host>virtual.host</virtual-host>
+ <virtual-host>virtual.alias</virtual-host>
+</jboss-web>
\ No newline at end of file
Added: trunk/testsuite/src/resources/web/virtual/web.xml
===================================================================
--- trunk/testsuite/src/resources/web/virtual/web.xml (rev 0)
+++ trunk/testsuite/src/resources/web/virtual/web.xml 2008-09-09 14:57:25 UTC (rev 78253)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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>
+ <description>WebApp Virtual Host Tests</description>
+</web-app>
More information about the jboss-cvs-commits
mailing list