Skip to content

Commit

Permalink
Test build
Browse files Browse the repository at this point in the history
  • Loading branch information
skarpenko committed Nov 10, 2023
1 parent 114a56c commit 8880a24
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 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,19 +46,25 @@ 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
Expand Down

0 comments on commit 8880a24

Please sign in to comment.