Skip to content

Commit

Permalink
impr
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Aug 29, 2024
1 parent 6df061d commit 82130be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public void stop() {
}
}

public boolean isRunning() {
return servers.stream().allMatch(CoapServer::isRunning);
}

public List<Integer> getLocalPorts() {
return servers.stream().map(server -> server.getLocalSocketAddress().getPort()).collect(toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.mbed.coap.transport.udp.DatagramSocketTransport.udp;
import static com.mbed.coap.utils.Assertions.assertEquals;
import static com.mbed.coap.utils.Networks.localhost;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.mbed.coap.client.CoapClient;
import com.mbed.coap.server.CoapServer;
Expand Down Expand Up @@ -51,6 +52,7 @@ void test() throws Exception {
.get("/test", __ -> ok("OK").toFuture())
);
MultiCoapServer coapServer = MultiCoapServer.create(builder, bootstrap).start();
assertTrue(coapServer.isRunning());

// verify that all channels are working
for (int i = 0; i < THREADS; i++) {
Expand All @@ -63,6 +65,7 @@ void test() throws Exception {
}

coapServer.stop();
assertFalse(coapServer.isRunning());
}

private Bootstrap createBootstrap() {
Expand Down

0 comments on commit 82130be

Please sign in to comment.