-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge of the actual master into the 3.x branch
- Loading branch information
Showing
63 changed files
with
1,516 additions
and
389 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
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
99 changes: 99 additions & 0 deletions
99
...n-connector/src/test/java/org/glassfish/jersey/helidon/connector/MetaInfOverrideTest.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,99 @@ | ||
/* | ||
* Copyright (c) 2023 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.connector; | ||
|
||
import org.glassfish.jersey.client.ClientConfig; | ||
import org.glassfish.jersey.client.ClientProperties; | ||
import org.glassfish.jersey.client.HttpUrlConnectorProvider; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.glassfish.jersey.test.JerseyTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import jakarta.ws.rs.client.ClientRequestContext; | ||
import jakarta.ws.rs.client.ClientRequestFilter; | ||
import jakarta.ws.rs.core.Application; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.HttpHeaders; | ||
import jakarta.ws.rs.core.Response; | ||
import java.io.IOException; | ||
|
||
// The Helidon jar has META-INF set | ||
// Test of override | ||
class MetaInfOverrideTest extends JerseyTest { | ||
|
||
@Path("/origin") | ||
public static class UserAgentServer { | ||
@GET | ||
public String get(@Context HttpHeaders headers) { | ||
return headers.getHeaderString(HttpHeaders.USER_AGENT); | ||
} | ||
} | ||
|
||
@Override | ||
protected Application configure() { | ||
return new ResourceConfig(UserAgentServer.class); | ||
} | ||
|
||
@Test | ||
void defaultMetaInfTest() { | ||
try (Response r = target("origin").request().get()) { | ||
Assertions.assertEquals(200, r.getStatus()); | ||
Assertions.assertTrue(r.readEntity(String.class).contains("Helidon")); | ||
} | ||
} | ||
|
||
@Test | ||
void overrideMetaInfTest() { | ||
ClientConfig config = new ClientConfig(); | ||
config.connectorProvider(new HttpUrlConnectorProvider()); | ||
try (Response r = ClientBuilder.newClient(config).target(target("origin").getUri()).request().get()) { | ||
Assertions.assertEquals(200, r.getStatus()); | ||
r.bufferEntity(); | ||
System.out.println(r.readEntity(String.class)); | ||
Assertions.assertTrue(r.readEntity(String.class).contains("HttpUrlConnection")); | ||
} | ||
} | ||
|
||
@Test | ||
void overrideMetaInfByOtherConfigPropertyTest() { | ||
ClientConfig config = new ClientConfig(); | ||
config.property(ClientProperties.CONNECTOR_PROVIDER, "org.glassfish.jersey.client.HttpUrlConnectorProvider"); | ||
try (Response r = ClientBuilder.newClient(config).target(target("origin").getUri()).request().get()) { | ||
Assertions.assertEquals(200, r.getStatus()); | ||
r.bufferEntity(); | ||
System.out.println(r.readEntity(String.class)); | ||
Assertions.assertTrue(r.readEntity(String.class).contains("HttpUrlConnection")); | ||
} | ||
} | ||
|
||
@Test | ||
void overrideMetaInfByThePropertyTest() { | ||
try (Response r = ClientBuilder.newBuilder() | ||
.property(ClientProperties.CONNECTOR_PROVIDER, "org.glassfish.jersey.client.HttpUrlConnectorProvider") | ||
.build() | ||
.target(target("origin").getUri()).request().get()) { | ||
Assertions.assertEquals(200, r.getStatus()); | ||
r.bufferEntity(); | ||
System.out.println(r.readEntity(String.class)); | ||
Assertions.assertTrue(r.readEntity(String.class).contains("HttpUrlConnection")); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.