Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
Jan Bartel 2022-03-28 14:05:53 +02:00
commit 967e8ea89b
8 changed files with 258 additions and 16 deletions

View File

@ -0,0 +1 @@
invoker.goals = test -e

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its</groupId>
<artifactId>it-parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>org.github.unb</groupId>
<artifactId>jetty-7677</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>jetty-7677</name>
<properties>
<jetty.port.file>${project.build.directory}/jetty-start-it.txt</jetty.port.file>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
<version>5.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>IntegrationTest*.java</include>
</includes>
<systemPropertyVariables>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
<context.path>/</context.path>
<pingServlet>fals</pingServlet>
<helloServlet>false</helloServlet>
<contentCheck>class javax.annotation.Nullable not found</contentCheck>
<pathToCheck>/test</pathToCheck>
<maven.it.name>${project.groupId}:${project.artifactId}</maven.it.name>
</systemPropertyVariables>
<dependenciesToScan>
<dependency>org.eclipse.jetty:jetty-maven-plugin</dependency>
</dependenciesToScan>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>test-compile</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<systemProperties>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</systemProperties>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.IntegrationTestGetContent')
assert buildLog.text.contains( 'Tests run: 1, Failures: 0, Errors: 0, Skipped: 0')
assert buildLog.text.contains( 'contentCheck')

View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme">https</Set>
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
<Set name="outputBufferSize">32768</Set>
<Set name="requestHeaderSize">8192</Set>
<Set name="responseHeaderSize">8192</Set>
<Set name="headerCacheSize">1024</Set>
</New>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="httpConfig" /></Arg>
</New>
</Item>
</Array>
</Arg>
<Call name="addEventListener">
<Arg>
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
</New>
</Arg>
</Call>
<Set name="host" property="jetty.host"/>
<Set name="port" property="jetty.port"/>
<Set name="idleTimeout">30000</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,82 @@
//
// ========================================================================
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.github.unb;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.stream.Collectors;
@WebServlet("/test")
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
try {
HttpServlet.class.getClassLoader().loadClass("javax.annotation.Nullable");
} catch (ClassNotFoundException e) {
response.getWriter().write("class javax.annotation.Nullable not found");
return;
}
Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
List<String> jars = new ArrayList<>();
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
String jar = getJar(url);
if (jar != null) {
jars.add(jar);
}
}
Collections.sort(jars);
String body = jars.stream().map(Object::toString).collect(Collectors.joining("\n", "", "\n"));
response.getWriter().write(body);
}
/**
* Tries to determine the JAR from a MANIFEST.MF url.
*
* @param url the MANIFEST.MF url
* @return the corresponding jar, or {@code null} if one cannot be determined
*/
private String getJar(URL url) {
String result = null;
String path = url.getPath();
int index = path.lastIndexOf('!');
if (index > 0) {
path = path.substring(0, index);
index = path.lastIndexOf('/');
if (index >= 0) {
path = path.substring(index + 1);
result = path.length() > 0 ? path : null;
}
}
return result;
}
}

View File

@ -61,6 +61,7 @@ public class IntegrationTestGetContent
}
String contentCheck = System.getProperty("contentCheck");
String pathToCheck = System.getProperty("pathToCheck");
System.out.println("contentCheck: " + contentCheck);
if (StringUtils.isNotBlank(contentCheck))
{
String url = "http://localhost:" + port + contextPath;

View File

@ -34,20 +34,5 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-sessions-common</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -163,7 +163,7 @@
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
<maven.war.plugin.version>3.3.2</maven.war.plugin.version>
<spotbugs.maven.plugin.version>4.5.3.0</spotbugs.maven.plugin.version>
<spotbugs.maven.plugin.version>4.6.0.0</spotbugs.maven.plugin.version>
<versions.maven.plugin.version>2.10.0</versions.maven.plugin.version>
<!-- testing -->
@ -632,6 +632,7 @@
<localRepositoryPath>${localRepoPath}</localRepositoryPath>
<settingsFile>${settingsPath}</settingsFile>
<skipInvocation>${skipTests}</skipInvocation>
<streamLogsOnFailures>true</streamLogsOnFailures>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
@ -1209,6 +1210,10 @@
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>