Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3348 from soft4rchitecture/RESTEASY-3259/fixes-er…
…ror-when-mono-in-remote-interface RESTEASY-3259 Proxy Framework fails to Produce Mono<T> at runtime whe…
- Loading branch information
Showing
4 changed files
with
156 additions
and
35 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
resteasy-reactor/src/main/java/org/jboss/resteasy/reactor/MonoRxInvoker.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
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
18 changes: 18 additions & 0 deletions
18
resteasy-reactor/src/test/java/org/jboss/resteasy/reactor/proxyframework/CustomResource.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,18 @@ | ||
package org.jboss.resteasy.reactor.proxyframework; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import reactor.core.publisher.Mono; | ||
|
||
|
||
@Path("api/v1") | ||
public class CustomResource { | ||
|
||
public static final String THE_CUSTOM_RESOURCE = "the custom resource"; | ||
|
||
@GET | ||
@Path("resource/custom") | ||
public Mono<String> getCustomResource() { | ||
return Mono.just(THE_CUSTOM_RESOURCE); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
...rc/test/java/org/jboss/resteasy/reactor/proxyframework/MonoWithProxyFrameworkApiTest.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,92 @@ | ||
package org.jboss.resteasy.reactor.proxyframework; | ||
|
||
import io.netty.channel.group.DefaultChannelGroup; | ||
import io.netty.util.concurrent.DefaultEventExecutor; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyClient; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; | ||
import org.jboss.resteasy.client.jaxrs.engines.ReactorNettyClientHttpEngine; | ||
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; | ||
import org.jboss.resteasy.test.TestPortProvider; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty.http.client.HttpClient; | ||
import reactor.netty.resources.ConnectionProvider; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.jboss.resteasy.reactor.proxyframework.CustomResource.THE_CUSTOM_RESOURCE; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class MonoWithProxyFrameworkApiTest { | ||
|
||
|
||
private static int port; | ||
|
||
@Path("api/v1") | ||
public interface RemoteCustomResource { | ||
|
||
@GET | ||
@Path("resource/custom") | ||
Mono<String> getCustomResource(); | ||
} | ||
|
||
|
||
private static NettyJaxrsServer server; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
port = TestPortProvider.getPort(); | ||
server = new NettyJaxrsServer(); | ||
server.setPort(port); | ||
server.setRootResourcePath("/"); | ||
Arrays.asList((Class<?>[]) new Class[]{CustomResource.class}).forEach(server.getDeployment().getActualResourceClasses()::add); | ||
server.getDeployment().start(); | ||
server.getDeployment().registration(); | ||
server.start(); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() { | ||
server.stop(); | ||
server = null; | ||
} | ||
|
||
private ResteasyClient client; | ||
|
||
@Before | ||
public void before() { | ||
final ReactorNettyClientHttpEngine reactorEngine = | ||
new ReactorNettyClientHttpEngine( | ||
HttpClient.create(), | ||
new DefaultChannelGroup(new DefaultEventExecutor()), | ||
ConnectionProvider.newConnection() | ||
); | ||
client = ((ResteasyClientBuilder) ClientBuilder.newBuilder()) | ||
.httpEngine(reactorEngine) | ||
.readTimeout(5, TimeUnit.SECONDS) | ||
.connectionCheckoutTimeout(5, TimeUnit.SECONDS) | ||
.connectTimeout(5, TimeUnit.SECONDS) | ||
.build(); | ||
} | ||
|
||
@After | ||
public void after() { | ||
client.close(); | ||
} | ||
|
||
|
||
@Test | ||
public void givenRemoteServiceInterfaceAndWorkingRemoteServiceWhenProxyThenGenerateProxyWithMono() { | ||
final var proxy = client.target("http://localhost:" + port).proxy(RemoteCustomResource.class); | ||
assertEquals(THE_CUSTOM_RESOURCE, proxy.getCustomResource().block()); | ||
|
||
} | ||
} |