-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Framework container provider (Helidon 4.x)
Signed-off-by: Maxim Nesen <[email protected]>
- Loading branch information
Showing
13 changed files
with
405 additions
and
11 deletions.
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
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
80 changes: 80 additions & 0 deletions
80
...iners/helidon/src/main/java/org/glassfish/jersey/helidon/HelidonHttpContainerBuilder.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,80 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* | ||
*/ | ||
|
||
package org.glassfish.jersey.helidon; | ||
|
||
import jakarta.ws.rs.core.Application; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* Helidon container builder | ||
*/ | ||
class HelidonHttpContainerBuilder { | ||
|
||
private URI baseUri; | ||
|
||
private Application application; | ||
|
||
private String host; | ||
|
||
private String path; | ||
|
||
private int port; | ||
|
||
private HelidonHttpContainerBuilder() { | ||
} | ||
|
||
|
||
|
||
public static HelidonHttpContainerBuilder builder() { | ||
return new HelidonHttpContainerBuilder(); | ||
} | ||
|
||
public HelidonHttpContainerBuilder withUri(URI baseUri) { | ||
this.baseUri = baseUri; | ||
return this; | ||
} | ||
|
||
public HelidonHttpContainerBuilder withApplication(Application application) { | ||
this.application = application; | ||
return this; | ||
} | ||
|
||
public HelidonHttpContainerBuilder withPort(int port) { | ||
this.port = port; | ||
return this; | ||
} | ||
|
||
public HelidonHttpContainerBuilder withHost(String host) { | ||
this.host = host; | ||
return this; | ||
} | ||
|
||
public HelidonHttpContainerBuilder withPath(String path) { | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
public HelidonHttpContainer build() { | ||
if (this.baseUri == null) { | ||
baseUri = UriBuilder.fromPath(path).port(port).host(host).build(); | ||
} | ||
return new HelidonHttpContainer(baseUri, application); | ||
} | ||
} |
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
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
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
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,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0, which is available at | ||
http://www.eclipse.org/legal/epl-2.0. | ||
This Source Code may also be made available under the following Secondary | ||
Licenses when the conditions for such availability set forth in the | ||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
version 2 with the GNU Classpath Exception, which is available at | ||
https://www.gnu.org/software/classpath/license.html. | ||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
--> | ||
|
||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
<artifactId>project</artifactId> | ||
<version>3.1.99-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jersey-test-framework-provider-helidon</artifactId> | ||
<packaging>jar</packaging> | ||
<name>jersey-test-framework-provider-helidon</name> | ||
|
||
<description>Jersey Test Framework - Helidon (4.x) container</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.test-framework</groupId> | ||
<artifactId>jersey-test-framework-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.containers</groupId> | ||
<artifactId>jersey-container-helidon-http</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
88 changes: 88 additions & 0 deletions
88
...don-http/src/main/java/org/glassfish/jersey/test/helidon/HelidonTestContainerFactory.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,88 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.test.helidon; | ||
|
||
import io.helidon.webserver.WebServer; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
import org.glassfish.jersey.client.ClientConfig; | ||
import org.glassfish.jersey.helidon.HelidonHttpContainerFactory; | ||
import org.glassfish.jersey.test.DeploymentContext; | ||
import org.glassfish.jersey.test.spi.TestContainer; | ||
import org.glassfish.jersey.test.spi.TestContainerFactory; | ||
import org.glassfish.jersey.test.spi.TestHelper; | ||
|
||
import javax.net.ssl.SSLParameters; | ||
import java.net.URI; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class HelidonTestContainerFactory implements TestContainerFactory { | ||
|
||
private static class HelidonTestContainer implements TestContainer { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(HelidonTestContainer.class.getName()); | ||
|
||
private URI baseUri; | ||
|
||
private final WebServer server; | ||
|
||
private HelidonTestContainer(final URI baseUri, final DeploymentContext context) { | ||
this.baseUri = UriBuilder.fromUri(baseUri).path(context.getContextPath()).build(); | ||
|
||
if (LOGGER.isLoggable(Level.INFO)) { | ||
LOGGER.info("Creating HelidonTestContainer configured at the base URI " | ||
+ TestHelper.zeroPortToAvailablePort(baseUri)); | ||
} | ||
|
||
if (context.getSslContext().isPresent() && context.getSslParameters().isPresent()) { | ||
final SSLParameters sslParameters = context.getSslParameters().get(); | ||
this.server = HelidonHttpContainerFactory.createServer( | ||
this.baseUri, context.getResourceConfig()); | ||
} else { | ||
this.server = HelidonHttpContainerFactory.createServer(this.baseUri, context.getResourceConfig()); | ||
} | ||
} | ||
|
||
@Override | ||
public ClientConfig getClientConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public URI getBaseUri() { | ||
return baseUri; | ||
} | ||
|
||
@Override | ||
public void start() { | ||
if (!server.isRunning()) { | ||
server.start(); | ||
} | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
if (server.isRunning()) { | ||
server.stop(); | ||
} | ||
} | ||
} | ||
@Override | ||
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) { | ||
return new HelidonTestContainer(baseUri, deploymentContext); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../providers/helidon-http/src/main/java/org/glassfish/jersey/test/helidon/package-info.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,22 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* | ||
*/ | ||
|
||
/** | ||
* Test Framework Jersey container provider based on Helidon 4.x. | ||
*/ | ||
|
||
package org.glassfish.jersey.test.helidon; |
1 change: 1 addition & 0 deletions
1
...p/src/main/resources/META-INF/services/org.glassfish.jersey.test.spi.TestContainerFactory
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 @@ | ||
org.glassfish.jersey.test.helidon.HelidonTestContainerFactory |
Oops, something went wrong.