-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5811 from pnicolucci/4809-18004ServletPathForDefa…
…ultMapping 4809 18004 servlet path for default mapping
- Loading branch information
Showing
19 changed files
with
332 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...ervlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingDefault.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.fat.wc.tests; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.ws.fat.util.LoggingTest; | ||
import com.ibm.ws.fat.util.SharedServer; | ||
import com.ibm.ws.fat.wc.WCApplicationHelper; | ||
|
||
import componenttest.custom.junit.runner.FATRunner; | ||
|
||
/** | ||
* This is a test class for the servlet-4.0 feature to test the behavior when servletPathForDefaultMapping | ||
* is true. There is no need to set the property in the server.xml because the value is true by default | ||
* for the servlet-4.0 feature. | ||
* | ||
*/ | ||
@RunWith(FATRunner.class) | ||
public class WCServletPathForDefaultMappingDefault extends LoggingTest { | ||
|
||
private static final Logger LOG = Logger.getLogger(WCServletPathForDefaultMappingDefault.class.getName()); | ||
|
||
@ClassRule | ||
public static SharedServer SHARED_SERVER = new SharedServer("servlet40_ServletPathForDefaultMapping_Default"); | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
|
||
LOG.info("Setup : add ServletPathDefaultMapping.war to the server if not already present."); | ||
|
||
WCApplicationHelper.addWarToServerDropins(SHARED_SERVER.getLibertyServer(), "ServletPathDefaultMapping.war", false, | ||
"servletpathdefaultmapping.war.servlets"); | ||
|
||
SHARED_SERVER.startIfNotStarted(); | ||
|
||
LOG.info("Setup : wait for message to indicate app has started"); | ||
|
||
SHARED_SERVER.getLibertyServer().waitForStringInLog("CWWKZ0001I.* ServletPathDefaultMapping", 10000); | ||
|
||
LOG.info("Setup : complete, ready for Tests"); | ||
|
||
} | ||
|
||
/** | ||
* Test to ensure that the default behavior when using the servlet-4.0 feature is | ||
* that a request to the default servlet will result in: | ||
* | ||
* servlet path = / + requestURI - context path | ||
* path info = null | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testServletPathForDefaultMapping_Default() throws Exception { | ||
this.verifyResponse("/ServletPathDefaultMapping", "ServletPath = / PathInfo = null"); | ||
} | ||
|
||
/** | ||
* Test to ensure that the default behavior when using the servlet-4.0 feature is | ||
* that a request to the default servlet will result in: | ||
* | ||
* servlet path = / + requestURI - context path | ||
* path info = null | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testServletPathForDefaultMapping_Default_2() throws Exception { | ||
this.verifyResponse("/ServletPathDefaultMapping/index.html", "ServletPath = /index.html PathInfo = null"); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see com.ibm.ws.fat.util.LoggingTest#getSharedServer() | ||
*/ | ||
@Override | ||
protected SharedServer getSharedServer() { | ||
return SHARED_SERVER; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
....servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingFalse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.fat.wc.tests; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.ws.fat.util.LoggingTest; | ||
import com.ibm.ws.fat.util.SharedServer; | ||
import com.ibm.ws.fat.wc.WCApplicationHelper; | ||
|
||
import componenttest.custom.junit.runner.FATRunner; | ||
|
||
/** | ||
* This is a test class for the servlet-4.0 feature to test the behavior when servletPathForDefaultMapping | ||
* is false. Setting servletPathForDefaultMapping to false is the testing the non default behavior. | ||
* | ||
*/ | ||
@RunWith(FATRunner.class) | ||
public class WCServletPathForDefaultMappingFalse extends LoggingTest { | ||
|
||
private static final Logger LOG = Logger.getLogger(WCServletPathForDefaultMappingFalse.class.getName()); | ||
|
||
@ClassRule | ||
public static SharedServer SHARED_SERVER = new SharedServer("servlet40_ServletPathForDefaultMapping_False"); | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
|
||
LOG.info("Setup : add ServletPathDefaultMapping.war to the server if not already present."); | ||
|
||
WCApplicationHelper.addWarToServerDropins(SHARED_SERVER.getLibertyServer(), "ServletPathDefaultMapping.war", false, | ||
"servletpathdefaultmapping.war.servlets"); | ||
|
||
SHARED_SERVER.startIfNotStarted(); | ||
|
||
LOG.info("Setup : wait for message to indicate app has started"); | ||
|
||
SHARED_SERVER.getLibertyServer().waitForStringInLog("CWWKZ0001I.* ServletPathDefaultMapping", 10000); | ||
|
||
LOG.info("Setup : complete, ready for Tests"); | ||
|
||
} | ||
|
||
/** | ||
* Test to ensure that if we set servletPathForDefaultMapping to false in the server.xml ( not the | ||
* default value for the servlet-4.0 feature) then a request to the default servlet will result in: | ||
* | ||
* servlet path = "" (empty string) | ||
* path info = / request URI - context path | ||
* | ||
* This is the incorrect behavior | ||
* according to the servlet specification and that is why we're making it the non default behavior | ||
* for the servlet-4.0 feature. | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testServletPathForDefaultMapping_False() throws Exception { | ||
this.verifyResponse("/ServletPathDefaultMapping", "ServletPath = PathInfo = /"); | ||
} | ||
|
||
/** | ||
* Test to ensure that if we set servletPathForDefaultMapping to false in the server.xml ( not the | ||
* default value for the servlet-4.0 feature) then a request to the default servlet will result in: | ||
* | ||
* servlet path = "" (empty string) | ||
* path info = / request URI - context path | ||
* | ||
* This is the incorrect behavior | ||
* according to the servlet specification and that is why we're making it the non default behavior | ||
* for the servlet-4.0 feature. | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testServletPathForDefaultMapping_False_2() throws Exception { | ||
this.verifyResponse("/ServletPathDefaultMapping/index.html", "ServletPath = PathInfo = /index.html"); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see com.ibm.ws.fat.util.LoggingTest#getSharedServer() | ||
*/ | ||
@Override | ||
protected SharedServer getSharedServer() { | ||
return SHARED_SERVER; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/apps | ||
/dropins |
4 changes: 4 additions & 0 deletions
4
...0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bootstrap.include=../testports.properties | ||
osgi.console=7777 | ||
com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all | ||
com.ibm.ws.classloading.tcclLockWaitTimeMillis=60000 |
15 changes: 15 additions & 0 deletions
15
...servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/server.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<server description="Server for testing Webcontainer"> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<featureManager> | ||
<feature>servlet-4.0</feature> | ||
</featureManager> | ||
|
||
<logging | ||
traceSpecification="*=info=enabled:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all" | ||
maxFileSize="20" | ||
maxFiles="10" | ||
traceFormat="BASIC"/> | ||
|
||
</server> |
2 changes: 2 additions & 0 deletions
2
...r.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/apps | ||
/dropins |
4 changes: 4 additions & 0 deletions
4
...4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bootstrap.include=../testports.properties | ||
osgi.console=7777 | ||
com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all | ||
com.ibm.ws.classloading.tcclLockWaitTimeMillis=60000 |
16 changes: 16 additions & 0 deletions
16
...r.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/server.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<server description="Server for testing Webcontainer"> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<featureManager> | ||
<feature>servlet-4.0</feature> | ||
</featureManager> | ||
|
||
<logging | ||
traceSpecification="*=info=enabled:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all" | ||
maxFileSize="20" | ||
maxFiles="10" | ||
traceFormat="BASIC"/> | ||
|
||
<webContainer servletPathForDefaultMapping="false"/> | ||
</server> |
40 changes: 40 additions & 0 deletions
40
...ping.war/src/servletpathdefaultmapping/war/servlets/ServletPathDefaultMappingServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package servletpathdefaultmapping.war.servlets; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletOutputStream; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* | ||
*/ | ||
@WebServlet("/") | ||
public class ServletPathDefaultMappingServlet extends HttpServlet { | ||
|
||
public ServletPathDefaultMappingServlet() { | ||
|
||
} | ||
|
||
@Override | ||
protected void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { | ||
ServletOutputStream sos = res.getOutputStream(); | ||
|
||
sos.println("RequestURI = " + req.getRequestURI()); | ||
sos.println(); | ||
sos.println("ServletPath = " + req.getServletPath() + " PathInfo = " + req.getPathInfo()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.