Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test build #640

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions feign-reactor-core/src/test/java/reactivefeign/ReactivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.Test;
import reactivefeign.testcase.IcecreamServiceApi;
import reactivefeign.testcase.domain.OrderGenerator;
import reactor.core.publisher.Mono;
import reactor.netty.DisposableServer;
import reactor.netty.http.HttpProtocol;
import reactor.netty.http.server.HttpServer;

import java.time.Duration;
Expand All @@ -45,24 +46,31 @@ abstract public class ReactivityTest extends BaseReactorTest {

private static DisposableServer server;

@BeforeClass
public static void startServer() throws JsonProcessingException {
byte[] data = TestUtils.MAPPER.writeValueAsString(new OrderGenerator().generate(1)).getBytes();

server = HttpServer.create()
.protocol(HTTP11, H2C)
.route(r -> r.get("/icecream/orders/1",
(req, res) -> {
res.header("Content-Type", "application/json");
return Mono.delay(Duration.ofMillis(DELAY_IN_MILLIS))
.thenEmpty(res.sendByteArray(Mono.just(data)));
}))
.bindNow();
@Before
public void startServer() throws JsonProcessingException {
if(server == null) {
byte[] data = TestUtils.MAPPER.writeValueAsString(new OrderGenerator().generate(1)).getBytes();

server = HttpServer.create()
.protocol(serverProtocols())
.route(r -> r.get("/icecream/orders/1",
(req, res) -> {
res.header("Content-Type", "application/json");
return Mono.delay(Duration.ofMillis(DELAY_IN_MILLIS))
.thenEmpty(res.sendByteArray(Mono.just(data)));
}))
.bindNow();
}
}

protected HttpProtocol[] serverProtocols(){
return new HttpProtocol[]{HTTP11, H2C};
}

@AfterClass
public static void stopServer(){
server.disposeNow();
server = null;
}

@Test
Expand Down
Loading