Skip to content

Commit

Permalink
[MRESOLVER-448] Align Jetty versions (#390)
Browse files Browse the repository at this point in the history
Move off dead Jetty 9, and use 10.x in both modules, update to latest minor.

---

https://issues.apache.org/jira/browse/MRESOLVER-448
  • Loading branch information
cstamas authored Dec 7, 2023
1 parent a2e2912 commit 09ba0b9
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 208 deletions.
103 changes: 103 additions & 0 deletions maven-resolver-test-http/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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.apache.maven.resolver</groupId>
<artifactId>maven-resolver</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>maven-resolver-test-http</artifactId>

<name>Maven Artifact Resolver Test Utilities HTTP</name>
<description>A collection of utility classes to ease testing of HTTP transports.</description>

<properties>
<Automatic-Module-Name>org.apache.maven.resolver.test.http</Automatic-Module-Name>
<Bundle-SymbolicName>${Automatic-Module-Name}</Bundle-SymbolicName>

<javaVersion>11</javaVersion>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-spi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-test-util</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.eclipse.aether.transport.apache;
package org.eclipse.aether.internal.test.util.http;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -41,8 +41,11 @@
import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmHelper;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
Expand All @@ -57,18 +60,30 @@ public class HttpServer {

public static class LogEntry {

public final String method;
private final String method;

public final String path;
private final String path;

public final Map<String, String> headers;
private final Map<String, String> headers;

public LogEntry(String method, String path, Map<String, String> headers) {
this.method = method;
this.path = path;
this.headers = headers;
}

public String getMethod() {
return method;
}

public String getPath() {
return path;
}

public Map<String, String> getHeaders() {
return headers;
}

@Override
public String toString() {
return method + " " + path;
Expand Down Expand Up @@ -114,7 +129,7 @@ public enum ChecksumHeader {

private final AtomicInteger connectionsToClose = new AtomicInteger(0);

private List<LogEntry> logEntries = Collections.synchronizedList(new ArrayList<>());
private final List<LogEntry> logEntries = Collections.synchronizedList(new ArrayList<>());

public String getHost() {
return "localhost";
Expand Down Expand Up @@ -153,12 +168,18 @@ private HttpServer addSslConnector(boolean needClientAuth) {
ssl.setKeyStorePassword("server-pwd");
ssl.setTrustStorePath(new File("src/test/resources/ssl/client-store").getAbsolutePath());
ssl.setTrustStorePassword("client-pwd");
ssl.setSniRequired(false);
} else {
ssl.setNeedClientAuth(false);
ssl.setKeyStorePath(new File("src/test/resources/ssl/server-store-selfsigned").getAbsolutePath());
ssl.setKeyStorePassword("server-pwd");
ssl.setSniRequired(false);
}
httpsConnector = new ServerConnector(server, ssl);
HttpConfiguration httpsConfig = new HttpConfiguration();
SecureRequestCustomizer customizer = new SecureRequestCustomizer();
customizer.setSniHostCheck(false);
httpsConfig.addCustomizer(customizer);
httpsConnector = new ServerConnector(server, ssl, new HttpConnectionFactory(httpsConfig));
server.addConnector(httpsConnector);
try {
httpsConnector.start();
Expand Down Expand Up @@ -280,9 +301,9 @@ public void handle(String target, Request req, HttpServletRequest request, HttpS
}
}

private class RepoHandler extends AbstractHandler {
private static final Pattern SIMPLE_RANGE = Pattern.compile("bytes=([0-9])+-");

private final Pattern SIMPLE_RANGE = Pattern.compile("bytes=([0-9])+-");
private class RepoHandler extends AbstractHandler {

public void handle(String target, Request req, HttpServletRequest request, HttpServletResponse response)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.eclipse.aether.transport.apache;
package org.eclipse.aether.internal.test.util.http;

import java.io.ByteArrayOutputStream;
import java.nio.Buffer;
Expand All @@ -25,21 +25,21 @@
import org.eclipse.aether.spi.connector.transport.TransportListener;
import org.eclipse.aether.transfer.TransferCancelledException;

class RecordingTransportListener extends TransportListener {
public class RecordingTransportListener extends TransportListener {

public final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
private final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);

public long dataOffset;
private long dataOffset;

public long dataLength;
private long dataLength;

public int startedCount;
private int startedCount;

public int progressedCount;
private int progressedCount;

public boolean cancelStart;
private boolean cancelStart;

public boolean cancelProgress;
private boolean cancelProgress;

@Override
public void transportStarted(long dataOffset, long dataLength) throws TransferCancelledException {
Expand All @@ -61,4 +61,40 @@ public void transportProgressed(ByteBuffer data) throws TransferCancelledExcepti
throw new TransferCancelledException();
}
}

public ByteArrayOutputStream getBaos() {
return baos;
}

public long getDataOffset() {
return dataOffset;
}

public long getDataLength() {
return dataLength;
}

public int getStartedCount() {
return startedCount;
}

public int getProgressedCount() {
return progressedCount;
}

public boolean isCancelStart() {
return cancelStart;
}

public boolean isCancelProgress() {
return cancelProgress;
}

public void cancelStart() {
this.cancelStart = true;
}

public void cancelProgress() {
this.cancelProgress = true;
}
}
2 changes: 1 addition & 1 deletion maven-resolver-test-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<description>A collection of utility classes to ease testing of the repository system.</description>

<properties>
<Automatic-Module-Name>org.apache.maven.resolver.testutil</Automatic-Module-Name>
<Automatic-Module-Name>org.apache.maven.resolver.test.util</Automatic-Module-Name>
<Bundle-SymbolicName>${Automatic-Module-Name}</Bundle-SymbolicName>
</properties>

Expand Down
41 changes: 5 additions & 36 deletions maven-resolver-transport-apache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<properties>
<Automatic-Module-Name>org.apache.maven.resolver.transport.apache</Automatic-Module-Name>
<Bundle-SymbolicName>${Automatic-Module-Name}</Bundle-SymbolicName>
<jettyVersion>9.4.53.v20231009</jettyVersion>
</properties>

<dependencies>
Expand Down Expand Up @@ -78,6 +77,10 @@
<version>1.16.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
Expand Down Expand Up @@ -107,41 +110,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jettyVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jettyVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<artifactId>maven-resolver-test-http</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading

0 comments on commit 09ba0b9

Please sign in to comment.