-
Notifications
You must be signed in to change notification settings - Fork 600
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
5 changed files
with
226 additions
and
1 deletion.
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
180 changes: 180 additions & 0 deletions
180
dev/com.ibm.ws.jsp.2.3_fat/fat/src/com/ibm/ws/jsp23/fat/tests/JSPUseJDKCompilerTests.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,180 @@ | ||
/******************************************************************************* | ||
* 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.Collections; | ||
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; | ||
|
||
import com.ibm.websphere.simplicity.config.ServerConfiguration; | ||
|
||
/** | ||
* 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. | ||
@SkipForRepeat("CDI-2.0") | ||
@RunWith(FATRunner.class) | ||
public class JSPUseJDKCompilerTests { | ||
private static final String APP_NAME = "TestJSPWithJava8"; | ||
private static final Logger LOG = Logger.getLogger(JSPJava11Test.class.getName()); | ||
|
||
@Server("jspUseJDKCompilerServer") | ||
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 testJava8viaUseJDKCompiler() throws Exception { | ||
|
||
ServerConfiguration configuration = server.getServerConfiguration(); | ||
LOG.info("Server configuration that was saved: " + configuration); | ||
|
||
configuration.getJspEngine().setJavaSourceLevel("8"); | ||
|
||
server.setMarkToEndOfLog(); | ||
server.updateServerConfiguration(configuration); | ||
server.restartApplication(APP_NAME); | ||
server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava8.*"); | ||
|
||
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: onetwothreefour", response.getText().contains("onetwothreefour")); | ||
} | ||
|
||
/** | ||
* Simple test for index.jsp. Page uses Java 11's String#strip method | ||
* | ||
* @throws Exception | ||
* if something goes horribly wrong | ||
*/ | ||
@Test | ||
public void testJava11viaUseJDKCompiler() throws Exception { | ||
|
||
ServerConfiguration configuration = server.getServerConfiguration(); | ||
configuration.getJspEngine().setJavaSourceLevel("11"); | ||
LOG.info("Server configuration that was updated: " + configuration); | ||
server.setMarkToEndOfLog(); | ||
server.updateServerConfiguration(configuration); | ||
server.restartApplication(APP_NAME); | ||
server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava8.*"); | ||
|
||
// ServerConfiguration configuration = server.getServerConfiguration(); | ||
// Log.info(JSPJava11Test.class, "testJava11viaUseJDKCompiler", "Server configuration that was saved: " + configuration); | ||
// server.setMarkToEndOfLog(); | ||
// server.setServerConfigurationFile("serverConfigs/useJDKCompiler-Source17server.xml"); | ||
// server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), true, "CWWKT0016I:.*TestJSPWithJava8.*"); | ||
|
||
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: onetwothreefour", response.getText().contains("onetwothreefour")); | ||
} | ||
|
||
|
||
/** | ||
* Simple test for index.jsp. Page uses Java 11's String#strip method | ||
* | ||
* @throws Exception | ||
* if something goes horribly wrong | ||
*/ | ||
@Test | ||
public void testJava17viaUseJDKCompiler() throws Exception { | ||
|
||
ServerConfiguration configuration = server.getServerConfiguration(); | ||
LOG.info("Server configuration that was saved: " + configuration); | ||
|
||
configuration.getJspEngine().setJavaSourceLevel("17"); | ||
|
||
server.setMarkToEndOfLog(); | ||
server.updateServerConfiguration(configuration); | ||
server.restartApplication(APP_NAME); | ||
server.waitForConfigUpdateInLogUsingMark(Collections.singleton(APP_NAME), false, "CWWKT0016I:.*TestJSPWithJava8.*"); | ||
|
||
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: onetwothreefour", response.getText().contains("onetwothreefour")); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspUseJDKCompilerServer/.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/jspUseJDKCompilerServer/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 | ||
|
26 changes: 26 additions & 0 deletions
26
dev/com.ibm.ws.jsp.2.3_fat/publish/servers/jspUseJDKCompilerServer/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,26 @@ | ||
<!-- | ||
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> | ||
<feature>localConnector-1.0</feature> | ||
</featureManager> | ||
|
||
<logging traceSpecification="*=info=enabled:com.ibm.ws.jsp*=all" maxFileSize="32" maxFiles="24" traceFormat="BASIC"/> | ||
|
||
<jspEngine useJDKCompiler="true"/> | ||
|
||
</server> |