-
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.
- Loading branch information
Showing
14 changed files
with
391 additions
and
0 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
94 changes: 94 additions & 0 deletions
94
dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava11Test.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,94 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.jsp23.fat.tests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.websphere.simplicity.ShrinkHelper; | ||
import com.ibm.ws.jsp23.fat.JSPUtils; | ||
import com.meterware.httpunit.GetMethodWebRequest; | ||
import com.meterware.httpunit.WebConversation; | ||
import com.meterware.httpunit.WebRequest; | ||
import com.meterware.httpunit.WebResponse; | ||
|
||
import componenttest.annotation.MinimumJavaLevel; | ||
import componenttest.annotation.Server; | ||
import componenttest.annotation.SkipForRepeat; | ||
import componenttest.custom.junit.runner.FATRunner; | ||
import componenttest.topology.impl.LibertyServer; | ||
|
||
/** | ||
* JSP 2.3 tests which use Java 11 specific features. | ||
* | ||
* Tests must only run when Java 11 is in use. | ||
* | ||
* Tests that just need to drive a simple request using our WebBrowser object can be placed in this class. | ||
* | ||
*/ | ||
// No need to run against cdi-2.0 since these tests don't use CDI at all. | ||
@MinimumJavaLevel(javaLevel = 11) | ||
@SkipForRepeat("CDI-2.0") | ||
@RunWith(FATRunner.class) | ||
public class JSPJava11Test { | ||
private static final String APP_NAME = "TestJSPWithJava11"; | ||
private static final Logger LOG = Logger.getLogger(JSPJava11Test.class.getName()); | ||
|
||
@Server("jspJava11Server") | ||
public static LibertyServer server; | ||
|
||
@BeforeClass | ||
public static void setup() throws Exception { | ||
ShrinkHelper.defaultDropinApp(server, APP_NAME + ".war"); | ||
|
||
server.startServer(JSPJava11Test.class.getSimpleName() + ".log"); | ||
} | ||
|
||
@AfterClass | ||
public static void testCleanup() throws Exception { | ||
// Stop the server | ||
if (server != null && server.isStarted()) { | ||
server.stopServer(); | ||
} | ||
} | ||
|
||
/** | ||
* Simple test for index.jsp. Page uses Java 11's String#strip method | ||
* | ||
* @throws Exception | ||
* if something goes horribly wrong | ||
*/ | ||
@Test | ||
public void testJava11JSP() throws Exception { | ||
WebConversation wc = new WebConversation(); | ||
wc.setExceptionsThrownOnErrorStatus(false); | ||
|
||
String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); | ||
LOG.info("url: " + url); | ||
|
||
WebRequest request = new GetMethodWebRequest(url); | ||
WebResponse response = wc.getResponse(request); | ||
LOG.info("Servlet response : " + response.getText()); | ||
|
||
assertEquals("Expected " + 200 + " status code was not returned!", | ||
200, response.getResponseCode()); | ||
assertTrue("The response did not contain: success", response.getText().contains("success")); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPJava17Test.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,94 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.jsp23.fat.tests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.websphere.simplicity.ShrinkHelper; | ||
import com.ibm.ws.jsp23.fat.JSPUtils; | ||
import com.meterware.httpunit.GetMethodWebRequest; | ||
import com.meterware.httpunit.WebConversation; | ||
import com.meterware.httpunit.WebRequest; | ||
import com.meterware.httpunit.WebResponse; | ||
|
||
import componenttest.annotation.MinimumJavaLevel; | ||
import componenttest.annotation.Server; | ||
import componenttest.annotation.SkipForRepeat; | ||
import componenttest.custom.junit.runner.FATRunner; | ||
import componenttest.topology.impl.LibertyServer; | ||
|
||
/** | ||
* JSP 2.3 tests which use Java 17 specific features. | ||
* | ||
* Tests must only run when Java 17 is in use. | ||
* | ||
* Tests that just need to drive a simple request using our WebBrowser object can be placed in this class. | ||
* | ||
*/ | ||
// No need to run against cdi-2.0 since these tests don't use CDI at all. | ||
@MinimumJavaLevel(javaLevel = 17) | ||
@SkipForRepeat("CDI-2.0") | ||
@RunWith(FATRunner.class) | ||
public class JSPJava17Test { | ||
private static final String APP_NAME = "TestJSPWithJava17"; | ||
private static final Logger LOG = Logger.getLogger(JSPJava17Test.class.getName()); | ||
|
||
@Server("jspJava17Server") | ||
public static LibertyServer server; | ||
|
||
@BeforeClass | ||
public static void setup() throws Exception { | ||
ShrinkHelper.defaultDropinApp(server, APP_NAME + ".war"); | ||
|
||
server.startServer(JSPJava17Test.class.getSimpleName() + ".log"); | ||
} | ||
|
||
@AfterClass | ||
public static void testCleanup() throws Exception { | ||
// Stop the server | ||
if (server != null && server.isStarted()) { | ||
server.stopServer(); | ||
} | ||
} | ||
|
||
/** | ||
* Simple test for index.jsp. Page uses Java 17's instanceof pattern matching | ||
* | ||
* @throws Exception | ||
* if something goes horribly wrong | ||
*/ | ||
@Test | ||
public void testJava17JSP() throws Exception { | ||
WebConversation wc = new WebConversation(); | ||
wc.setExceptionsThrownOnErrorStatus(false); | ||
|
||
String url = JSPUtils.createHttpUrlString(server, APP_NAME, "index.jsp"); | ||
LOG.info("url: " + url); | ||
|
||
WebRequest request = new GetMethodWebRequest(url); | ||
WebResponse response = wc.getResponse(request); | ||
LOG.info("Servlet response : " + response.getText()); | ||
|
||
assertEquals("Expected " + 200 + " status code was not returned!", | ||
200, response.getResponseCode()); | ||
assertTrue("The response did not contain: success", response.getText().contains("success")); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/.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 @@ | ||
/dropins |
16 changes: 16 additions & 0 deletions
16
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/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,16 @@ | ||
############################################################################### | ||
# Copyright (c) 2014 IBM Corporation and others. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# IBM Corporation - initial API and implementation | ||
############################################################################### | ||
bootstrap.include=../testports.properties | ||
osgi.console=7777 | ||
com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all | ||
|
25 changes: 25 additions & 0 deletions
25
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava11Server/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,25 @@ | ||
<!-- | ||
Copyright (c) 2020 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<server description="Server for testing JavaServer Pages 2.3"> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<featureManager> | ||
<feature>jsp-2.3</feature> | ||
</featureManager> | ||
|
||
<logging traceSpecification="*=info=enabled:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all" maxFileSize="32" maxFiles="24" traceFormat="BASIC"/> | ||
|
||
<jspEngine javaSourceLevel="17"/> | ||
|
||
</server> |
1 change: 1 addition & 0 deletions
1
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/.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 @@ | ||
/dropins |
16 changes: 16 additions & 0 deletions
16
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/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,16 @@ | ||
############################################################################### | ||
# Copyright (c) 2014 IBM Corporation and others. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# IBM Corporation - initial API and implementation | ||
############################################################################### | ||
bootstrap.include=../testports.properties | ||
osgi.console=7777 | ||
com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all | ||
|
25 changes: 25 additions & 0 deletions
25
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspJava17Server/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,25 @@ | ||
<!-- | ||
Copyright (c) 2020 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<server description="Server for testing JavaServer Pages 2.3"> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<featureManager> | ||
<feature>jsp-2.3</feature> | ||
</featureManager> | ||
|
||
<logging traceSpecification="*=info=enabled:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all" maxFileSize="32" maxFiles="24" traceFormat="BASIC"/> | ||
|
||
<jspEngine javaSourceLevel="17"/> | ||
|
||
</server> |
13 changes: 13 additions & 0 deletions
13
...ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/META-INF/permissions.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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<permissions xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/permissions_7.xsd" | ||
version="7"> | ||
|
||
<permission> | ||
<class-name>java.lang.RuntimePermission</class-name> | ||
<name>getClassLoader</name> | ||
</permission> | ||
|
||
</permissions> |
22 changes: 22 additions & 0 deletions
22
dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/WEB-INF/web.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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<web-app | ||
version="3.1" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> | ||
|
||
<display-name>Java11JSP</display-name> | ||
|
||
</web-app> |
25 changes: 25 additions & 0 deletions
25
dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava11.war/resources/index.jsp
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,25 @@ | ||
<!-- | ||
Copyright (c) 2023 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | ||
<title>Test Java 11 Compilation</title> | ||
</head> | ||
<body> | ||
|
||
Testing Java 11's String.strip function: | ||
<% out.print(" success ".strip()); %> | ||
|
||
</body> | ||
</html> |
22 changes: 22 additions & 0 deletions
22
dev/com.ibm.ws.jsp.2.3_fat/test-applications/TestJSPWithJava17.war/resources/WEB-INF/web.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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<web-app | ||
version="3.1" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> | ||
|
||
<display-name>TestJSPWithJava11</display-name> | ||
|
||
</web-app> |
Oops, something went wrong.