From b64c1f7da2b149f7a38dd0fbbf3667f479d9f4ca Mon Sep 17 00:00:00 2001 From: Szymon Sasin Date: Mon, 26 Aug 2024 16:12:13 +0300 Subject: [PATCH] test --- .../coap/server/CoapServerBuilderTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/coap-core/src/test/java/com/mbed/coap/server/CoapServerBuilderTest.java b/coap-core/src/test/java/com/mbed/coap/server/CoapServerBuilderTest.java index 52181f03..bdf6670d 100644 --- a/coap-core/src/test/java/com/mbed/coap/server/CoapServerBuilderTest.java +++ b/coap-core/src/test/java/com/mbed/coap/server/CoapServerBuilderTest.java @@ -16,11 +16,12 @@ */ package com.mbed.coap.server; +import static com.mbed.coap.transport.InMemoryCoapTransport.create; +import static com.mbed.coap.utils.Networks.localhost; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import com.mbed.coap.client.CoapClient; -import com.mbed.coap.transport.InMemoryCoapTransport; import java.time.Duration; import java.util.concurrent.ScheduledExecutorService; import org.junit.jupiter.api.Test; @@ -62,20 +63,19 @@ public void shouldFail_whenIllegalTimeoutValue() throws Exception { @Test public void shouldReuseBuilder() throws Exception { CoapServer server = new CoapServerBuilder() - .transport(InMemoryCoapTransport.create(5683)) + .transport(create(5683)) .build().start(); // when, builder is created - CoapServerBuilder builder = CoapServer.builder() - .transport(InMemoryCoapTransport.create()); + CoapServerBuilder builder = CoapServer.builder(); // then, it can be reused multiple times - for (int i = 0; i < 3; i++) { - CoapClient client = builder.buildClient(server.getLocalSocketAddress()); - assertNotNull(client.ping().get()); - client.close(); - } + CoapClient client1 = builder.transport(create()).buildClient(localhost(5683)); + CoapClient client2 = builder.transport(create()).buildClient(localhost(5683)); + assertNotNull(client1.ping().get()); + assertNotNull(client2.ping().get()); + client1.close(); server.stop(); } }