Skip to content

Commit a202bee

Browse files
ludochgae-java-bot
authored andcommitted
Remove Java 8 specific logic from App Engine tools.
PiperOrigin-RevId: 811849151 Change-Id: I5fa26ee3a609fc73e6583363e08d351e853c0384
1 parent 0729f69 commit a202bee

35 files changed

Lines changed: 196 additions & 1012 deletions

File tree

api_dev/src/main/java/com/google/appengine/tools/util/ApiVersionFinder.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

e2etests/stagingtests/src/test/java/com/google/appengine/tools/admin/ApplicationTest.java

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ public class ApplicationTest {
9595
private static final String TEST_ERROR_IN_TAGS_FILES = getWarPath("sample-error-in-tag-file");
9696
private static final String NOJSP_TEST_FILES = getWarPath("sample-nojsps");
9797
private static final String BAD_WEBXML_TEST_FILES = getWarPath("sample-badweb");
98-
private static final String BAD_RUNTIME_CHANNEL = getWarPath("sample-badruntimechannel");
9998
private static final String TEST_JAVA11 = getWarPath("sample-java11");
10099
private static final String TEST_JAVA17 = getWarPath("sample-java17");
101-
private static final String BAD_ENTRYPOINT = getWarPath("sample-badentrypoint");
102100
private static final String BAD_APPENGINEWEBXML_TEST_FILES = getWarPath("sample-badaeweb");
103101
private static final String BAD_INDEXESXML_TEST_FILES = getWarPath("sample-badindexes");
104102
private static final String MISSING_APP_ID_TEST_FILES = getWarPath("sample-missingappid");
@@ -518,7 +516,6 @@ private static void testStagedFiles(Application testApp) throws Exception {
518516
assertThat(new File(stage, "nested/dukebanner.html").canRead()).isTrue();
519517
assertThat(new File(stage, "WEB-INF/lib").isDirectory()).isTrue();
520518
File appYaml = new File(stage, "WEB-INF/appengine-generated/app.yaml");
521-
assertThat(Files.asCharSource(appYaml, UTF_8).read()).contains("api_version: 'user_defined'");
522519
int count = 0;
523520
for (File file : AppengineSdk.getSdk().getUserJspLibFiles()) {
524521
if (file.getName().contains("apache-jsp")) {
@@ -611,7 +608,6 @@ private static void doTestAppEngineApiJarIncluded(File tmpDir, String testName,
611608
application.createStagingDirectory(opts);
612609
File stage = application.getStagingDir();
613610
File appYaml = new File(stage, "WEB-INF/appengine-generated/app.yaml");
614-
assertFileContains(appYaml, "api_version: 'user_defined'");
615611
File stagedApiJar = new File(stage, "WEB-INF/lib/appengine-api.jar");
616612
assertWithMessage(stagedApiJar.toString()).that(stagedApiJar.exists()).isTrue();
617613
byte[] originalApiJarBytes = Files.toByteArray(apiJar);
@@ -1123,28 +1119,6 @@ public void testXmlValidation() throws IOException {
11231119
}
11241120
}
11251121

1126-
@Test
1127-
public void testBadRuntimeChannel() throws IOException {
1128-
try {
1129-
Application.readApplication(BAD_RUNTIME_CHANNEL);
1130-
fail("iappengine-web.xml content was incorrectly accepted with a runtime-channel.");
1131-
} catch (AppEngineConfigException ex) {
1132-
assertThat(ex)
1133-
.hasMessageThat()
1134-
.isEqualTo("'runtime-channel' is not valid with this runtime.");
1135-
}
1136-
}
1137-
1138-
@Test
1139-
public void testBadEntrypoint() throws IOException {
1140-
try {
1141-
Application.readApplication(BAD_ENTRYPOINT);
1142-
fail("appengine-web.xml content was incorrectly accepted with an entrypoint.");
1143-
} catch (AppEngineConfigException ex) {
1144-
assertThat(ex).hasMessageThat().isEqualTo("'entrypoint' is not valid with this runtime.");
1145-
}
1146-
}
1147-
11481122
@Test
11491123
public void testCronEntries() throws IOException {
11501124
Application testApp = Application.readApplication(TEST_FILES);
@@ -1657,7 +1631,7 @@ public void testStageGaeStandardJava8Servlet31QuickstartWithJSP()
16571631
assertThat(patterns).doesNotContain("/*");
16581632
}
16591633

1660-
@Ignore // TODO(ludo): Re-enable this test for java25 JDK target build.
1634+
@Test
16611635
public void testStageGaeStandardJava8WithOnlyJasperContextInitializer()
16621636
throws IOException, ParserConfigurationException, SAXException {
16631637

@@ -1690,21 +1664,20 @@ public void testStageGaeStandardJava8WithOnlyJasperContextInitializer()
16901664
assertThat(trimmedContextParams)
16911665
.containsEntry("org.eclipse.jetty.containerInitializers", expectedJasperInitializer);
16921666
} else if (Boolean.getBoolean("appengine.use.EE11")) {
1693-
List<String> possibleValues =
1694-
Arrays.asList(
1695-
"\"ContainerInitializer{org.eclipse.jetty.ee11.apache.jsp.JettyJasperInitializer,interested=[],applicable=[],annotated=[]}\",\n"
1696-
+ " \"ContainerInitializer{org.glassfish.wasp.runtime.TldScanner,interested=[],applicable=[],annotated=[]}\"",
1697-
"\"ContainerInitializer{org.glassfish.wasp.runtime.TldScanner,interested=[],applicable=[],annotated=[]}\",\n"
1698-
+ " \"ContainerInitializer{org.eclipse.jetty.ee11.apache.jsp.JettyJasperInitializer,interested=[],applicable=[],annotated=[]}\"");
1699-
assertThat(trimmedContextParams.get("org.eclipse.jetty.containerInitializers"))
1700-
.isIn(possibleValues);
1667+
String initializers = trimmedContextParams.get("org.eclipse.jetty.containerInitializers");
1668+
assertThat(initializers)
1669+
.contains(
1670+
"\"ContainerInitializer{org.eclipse.jetty.ee11.apache.jsp.JettyJasperInitializer,interested=[],applicable=[],annotated=[]}\"");
1671+
assertThat(initializers)
1672+
.contains(
1673+
"\"ContainerInitializer{org.glassfish.wasp.runtime.TldScanner,interested=[],applicable=[],annotated=[]}\"");
17011674
} else {
17021675
String expectedJasperInitializer =
17031676
"\"ContainerInitializer"
17041677
+ "{org.eclipse.jetty.apache.jsp.JettyJasperInitializer"
17051678
+ ",interested=[],applicable=[],annotated=[]}\"";
1706-
assertThat(trimmedContextParams)
1707-
.containsEntry("org.eclipse.jetty.containerInitializers", expectedJasperInitializer);
1679+
assertThat(trimmedContextParams)
1680+
.containsEntry("org.eclipse.jetty.containerInitializers", expectedJasperInitializer);
17081681
}
17091682
}
17101683

@@ -1777,8 +1750,6 @@ public void testJava8NoWebXmlNoApiJar() throws Exception {
17771750

17781751
File appYaml = new File(stageDir, "WEB-INF/appengine-generated/app.yaml");
17791752
assertFileContains(appYaml, "runtime: java8");
1780-
assertFileContains(appYaml, "threadsafe: True");
1781-
assertFileContains(appYaml, "api_version: 'user_defined'");
17821753
}
17831754

17841755
/** returns the Java version of the first class in the jar, or -1 if error. */

e2etests/testlocalapps/bundle_standard_with_container_initializer/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@
4949
<version>3.1.0</version>
5050
<scope>provided</scope>
5151
</dependency>
52-
<dependency>
53-
<groupId>com.google.auto.value</groupId>
54-
<artifactId>auto-value</artifactId>
55-
<version>1.11.0</version>
56-
</dependency>
57-
<dependency>
58-
<groupId>com.google.auto.service</groupId>
59-
<artifactId>auto-service-annotations</artifactId>
60-
<version>1.1.1</version>
61-
</dependency>
6252
</dependencies>
6353

6454
<build>

e2etests/testlocalapps/bundle_standard_with_container_initializer/src/main/java/servletthree/Servlet3ContainerInitializer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
*/
1616
package servletthree;
1717

18-
import com.google.auto.service.AutoService;
1918
import java.util.Set;
2019
import javax.servlet.ServletContainerInitializer;
2120
import javax.servlet.ServletContext;
2221
import javax.servlet.ServletException;
2322

2423
/** Simple ServletContainerInitializer */
25-
@AutoService(ServletContainerInitializer.class)
2624
public class Servlet3ContainerInitializer implements ServletContainerInitializer {
2725

2826
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
servletthree.Servlet3ContainerInitializer
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2021 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<groupId>com.google.appengine.demos</groupId>
24+
<artifactId>bundle_standard_with_container_initializer_jakarta</artifactId>
25+
<parent>
26+
<groupId>com.google.appengine</groupId>
27+
<artifactId>testlocalapps</artifactId>
28+
<version>3.0.0-SNAPSHOT</version>
29+
</parent>
30+
<packaging>war</packaging>
31+
32+
<name>AppEngine :: bundle_standard_with_container_initializer_jakarta</name>
33+
<url>https://github.com/GoogleCloudPlatform/appengine-java-standard/</url>
34+
<description>A sample application that bundles the standard App Engine API with a container initializer.</description>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
<maven.deploy.skip>true</maven.deploy.skip>
39+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
40+
<maven.compiler.target>1.8</maven.compiler.target>
41+
<maven.compiler.source>1.8</maven.compiler.source>
42+
</properties>
43+
44+
<dependencies>
45+
<!-- Include Servlet API -->
46+
<dependency>
47+
<groupId>jakarta.servlet</groupId>
48+
<artifactId>jakarta.servlet-api</artifactId>
49+
<scope>provided</scope>
50+
</dependency>
51+
</dependencies>
52+
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>com.google.cloud.tools</groupId>
57+
<artifactId>appengine-maven-plugin</artifactId>
58+
<version>2.8.3</version>
59+
<configuration>
60+
<!-- can be set w/ -DprojectId=myProjectId on command line -->
61+
<projectId>ludo-in-in</projectId>
62+
<!--promote>false</promote-->
63+
<version>demo</version>
64+
<!-- set the GAE version or use "GCLOUD_CONFIG" for an autogenerated GAE version -->
65+
</configuration>
66+
</plugin>
67+
</plugins>
68+
</build>
69+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package servletthree;
17+
18+
import jakarta.servlet.ServletContainerInitializer;
19+
import jakarta.servlet.ServletContext;
20+
import jakarta.servlet.ServletException;
21+
import java.util.Set;
22+
23+
/** Simple ServletContainerInitializer */
24+
public class Servlet3ContainerInitializer implements ServletContainerInitializer {
25+
26+
@Override
27+
public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
28+
System.out.println("test");
29+
}
30+
}

e2etests/testlocalapps/sample-badruntimechannel/src/main/webapp/WEB-INF/appengine-web.xml renamed to e2etests/testlocalapps/bundle_standard_with_container_initializer_jakarta/src/main/webapp/WEB-INF/appengine-web.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
1817
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
19-
<threadsafe>true</threadsafe>
20-
<runtime>java8</runtime>
21-
<runtime-channel>canary</runtime-channel>
22-
</appengine-web-app>
18+
<application>servlet3-demo</application>
19+
<version>1</version>
20+
<sessions-enabled>true</sessions-enabled>
21+
<runtime>java21</runtime>
22+
</appengine-web-app>

e2etests/testlocalapps/sample-badentrypoint/src/main/webapp/WEB-INF/web.xml renamed to e2etests/testlocalapps/bundle_standard_with_container_initializer_jakarta/src/main/webapp/WEB-INF/web.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1"
19+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd">
20+
<display-name>Servlet3 Test</display-name>
1721

18-
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
19-
20-
</web-app>
22+
</web-app>

e2etests/testlocalapps/sample-badruntimechannel/src/main/webapp/WEB-INF/web.xml renamed to e2etests/testlocalapps/bundle_standard_with_container_initializer_jakarta/src/main/webapp/index.jsp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
18-
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
19-
20-
</web-app>
17+
<%@page contentType="text/html" pageEncoding="UTF-8"%>
18+
<!DOCTYPE html>
19+
<html>
20+
<head>
21+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
22+
<title>JSP Page</title>
23+
</head>
24+
<body>
25+
<h1>Hello World!</h1>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)