Skip to content

Commit

Permalink
Merge pull request #370 from jamezp/issue341
Browse files Browse the repository at this point in the history
[341] Upgrade Wiremock, which also upgrades Jetty. Also upgrade TestN…
  • Loading branch information
Emily-Jiang authored Feb 5, 2024
2 parents 01d9b1e + 6c129b3 commit 40afc49
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5.1</version>
<version>7.8.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
10 changes: 4 additions & 6 deletions tck/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To enable the tests in your project you need to add the following dependency to
[source, xml]
----
<properties>
<microprofile.rest.client.version>3.0</microprofile.rest.client.version>
<microprofile.rest.client.version>3.1</microprofile.rest.client.version>
</properties>
<dependency>
Expand All @@ -53,13 +53,12 @@ To enable the tests in your project you need to add the following dependency to
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
----
Expand All @@ -73,7 +72,7 @@ WireMock can be run as a maven plugin. Below is one example configuration:
<plugin>
<groupId>uk.co.deliverymind</groupId>
<artifactId>wiremock-maven-plugin</artifactId>
<version>2.7.0</version>
<version>7.3.0</version>
<executions>
<execution>
<phase>generate-test-sources</phase>
Expand Down Expand Up @@ -156,7 +155,6 @@ If you use Apache Maven then the tests are run via the `maven-surefire-plugin`
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>tck-suite.xml</suiteXmlFile>
Expand Down Expand Up @@ -194,4 +192,4 @@ TBD.

== Running against CDI Lite

For all tests under the https://github.com/eclipse/microprofile-rest-client/tree/master/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/cditests[cditest] folder, the implementation needs to provide a way to enable the injection working on the Arquillian subclass.
For all tests under the https://github.com/eclipse/microprofile-rest-client/tree/master/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/cditests[cditest] folder, the implementation needs to provide a way to enable the injection working on the Arquillian subclass.
24 changes: 9 additions & 15 deletions tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,8 @@
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>
<dependency>
<!-- actually only referenced in JavaDoc -->
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.2_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
Expand All @@ -74,6 +64,10 @@
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand All @@ -85,7 +79,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
Expand All @@ -98,5 +92,5 @@
</dependency>
</dependencies>

</project>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
import java.io.PrintWriter;
import java.net.URI;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
Expand All @@ -39,6 +36,8 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.annotations.Test;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.core.Response;

public class ProxyServerTest extends WiremockArquillianTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected static URL getServerURL() {

protected static String getStringURL() {
int port = getPort();
return scheme + "://" + host + ":" + port + "" + context;
return scheme + "://" + host + ":" + port + (context.isBlank() ? "/" : context);
}

@BeforeClass
Expand All @@ -73,6 +73,6 @@ private static void setupWireMockConnection() {
host = System.getProperty("wiremock.server.host", "localhost");
port = Integer.parseInt(System.getProperty("wiremock.server.port", "8765"));
scheme = System.getProperty("wiremock.server.scheme", "http");
context = System.getProperty("wiremock.server.context", "/");
context = System.getProperty("wiremock.server.context", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import java.util.Set;
import java.util.function.Consumer;

import javax.servlet.http.HttpServletRequest;

import org.eclipse.jetty.servlets.EventSource;
import org.eclipse.jetty.servlets.EventSourceServlet;

import jakarta.servlet.http.HttpServletRequest;

public class MyEventSourceServlet extends EventSourceServlet {
private static final long serialVersionUID = -45238967561209543L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.entity.ContentType;
import org.apache.hc.core5.http.ContentType;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
*
* HTTPS server which returns {@link #responseContent} on each request.
Expand All @@ -44,7 +45,7 @@ public class HttpsServer {
private static final String CONTENT_TYPE = "Content-Type";

private final Server server = new Server();
private SslContextFactory sslContextFactory = new SslContextFactory();
private SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();

private String responseContent = "{\"foo\": \"bar\"}";
private String responseContentType = ContentType.APPLICATION_JSON.getMimeType();
Expand Down Expand Up @@ -83,6 +84,11 @@ public void handle(String path,
HttpConfiguration httpsConfig = new HttpConfiguration(); // httpConfig);
httpsConfig.setSecureScheme("https");
httpsConfig.setSecurePort(httpsPort);
// We need to disable SNI checking as localhost is restricted.
final SecureRequestCustomizer customizer = new SecureRequestCustomizer();
customizer.setSniRequired(false);
customizer.setSniHostCheck(false);
httpsConfig.addCustomizer(customizer);

ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import javax.net.ssl.SSLContext;

import org.apache.http.ssl.SSLContextBuilder;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.eclipse.microprofile.rest.client.tck.interfaces.JsonPClient;
import org.jboss.arquillian.container.test.api.Deployment;
Expand Down

0 comments on commit 40afc49

Please sign in to comment.