From b72271805d473ea39259fc87a28216789c79c66a Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Fri, 7 Jul 2023 11:08:46 +0200 Subject: [PATCH] fix(test): converted some MockWebServer to long-running instances --- .../tests/edr/AbstractNegotiateEdrTest.java | 2 +- .../SsiContractNegotiationInMemoryTest.java | 18 +++++++------- ...AbstractHttpConsumerPullWithProxyTest.java | 2 +- ...HttpConsumerPullWithProxyInMemoryTest.java | 24 ++++++++++++------- .../proxy/e2e/DpfProxyEndToEndTest.java | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/edr/AbstractNegotiateEdrTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/edr/AbstractNegotiateEdrTest.java index c62bcf0de..0c4db22ea 100644 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/edr/AbstractNegotiateEdrTest.java +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/edr/AbstractNegotiateEdrTest.java @@ -135,7 +135,7 @@ void negotiateEdr_shouldInvokeCallbacks() throws IOException { } - ReceivedEvent waitForEvent(ReceivedEvent event) { + private ReceivedEvent waitForEvent(ReceivedEvent event) { try { var request = server.takeRequest(20, TimeUnit.SECONDS); if (request != null) { diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/negotiation/SsiContractNegotiationInMemoryTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/negotiation/SsiContractNegotiationInMemoryTest.java index 6523b2358..c55affeee 100644 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/negotiation/SsiContractNegotiationInMemoryTest.java +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/negotiation/SsiContractNegotiationInMemoryTest.java @@ -19,8 +19,8 @@ import org.eclipse.tractusx.edc.lifecycle.ParticipantRuntime; import org.eclipse.tractusx.edc.token.KeycloakDispatcher; import org.eclipse.tractusx.edc.token.MiwDispatcher; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.extension.RegisterExtension; import java.io.IOException; @@ -56,13 +56,13 @@ public class SsiContractNegotiationInMemoryTest extends AbstractContractNegotiat SOKRATES_BPN, sokratesSsiConfiguration() ); - MockWebServer miwSokratesServer; - MockWebServer miwPlatoServer; - MockWebServer oauthServer; + private static MockWebServer miwSokratesServer; + private static MockWebServer miwPlatoServer; + private static MockWebServer oauthServer; - @BeforeEach - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { miwSokratesServer = new MockWebServer(); miwPlatoServer = new MockWebServer(); oauthServer = new MockWebServer(); @@ -79,8 +79,8 @@ void setup() throws IOException { oauthServer.setDispatcher(new KeycloakDispatcher()); } - @AfterEach - void teardown() throws IOException { + @AfterAll + static void teardown() throws IOException { miwSokratesServer.shutdown(); miwPlatoServer.shutdown(); oauthServer.shutdown(); diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/AbstractHttpConsumerPullWithProxyTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/AbstractHttpConsumerPullWithProxyTest.java index b31830ce7..4f5fcda03 100644 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/AbstractHttpConsumerPullWithProxyTest.java +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/AbstractHttpConsumerPullWithProxyTest.java @@ -53,7 +53,7 @@ public abstract class AbstractHttpConsumerPullWithProxyTest { private static final Duration ASYNC_TIMEOUT = ofSeconds(45); private static final Duration ASYNC_POLL_INTERVAL = ofSeconds(1); - MockWebServer server; + private MockWebServer server; @BeforeEach void setup() throws IOException { diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/SsiHttpConsumerPullWithProxyInMemoryTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/SsiHttpConsumerPullWithProxyInMemoryTest.java index 38991a864..5879e130a 100644 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/SsiHttpConsumerPullWithProxyInMemoryTest.java +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/transfer/SsiHttpConsumerPullWithProxyInMemoryTest.java @@ -20,7 +20,8 @@ import org.eclipse.tractusx.edc.lifecycle.ParticipantRuntime; import org.eclipse.tractusx.edc.token.KeycloakDispatcher; import org.eclipse.tractusx.edc.token.MiwDispatcher; -import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -59,13 +60,12 @@ public class SsiHttpConsumerPullWithProxyInMemoryTest extends AbstractHttpConsum platoSsiConfiguration() ); - private MockWebServer oauthServer; - private MockWebServer miwPlatoServer; - private MockWebServer miwSokratesServer; + private static MockWebServer oauthServer; + private static MockWebServer miwPlatoServer; + private static MockWebServer miwSokratesServer; - @BeforeEach - void setup() throws IOException { - super.setup(); + @BeforeAll + static void prepare() throws IOException { miwSokratesServer = new MockWebServer(); miwPlatoServer = new MockWebServer(); oauthServer = new MockWebServer(); @@ -82,13 +82,19 @@ void setup() throws IOException { oauthServer.setDispatcher(new KeycloakDispatcher()); } - @AfterEach - void teardown() throws IOException { + @AfterAll + static void unwind() throws IOException { miwSokratesServer.shutdown(); miwPlatoServer.shutdown(); oauthServer.shutdown(); } + @BeforeEach + void setup() throws IOException { + super.setup(); + + } + @Override protected JsonObject createTestPolicy(String policyId, String bpn) { return frameworkPolicy(policyId, Map.of("Dismantler", "active")); diff --git a/edc-tests/edc-dataplane-proxy-e2e/src/test/java/org/eclipse/tractusx/edc/dataplane/proxy/e2e/DpfProxyEndToEndTest.java b/edc-tests/edc-dataplane-proxy-e2e/src/test/java/org/eclipse/tractusx/edc/dataplane/proxy/e2e/DpfProxyEndToEndTest.java index 691aa255f..6e628262f 100644 --- a/edc-tests/edc-dataplane-proxy-e2e/src/test/java/org/eclipse/tractusx/edc/dataplane/proxy/e2e/DpfProxyEndToEndTest.java +++ b/edc-tests/edc-dataplane-proxy-e2e/src/test/java/org/eclipse/tractusx/edc/dataplane/proxy/e2e/DpfProxyEndToEndTest.java @@ -103,7 +103,7 @@ void setUp() { @AfterEach void tearDown() throws IOException { if (mockEndpoint != null) { - mockEndpoint.close(); + mockEndpoint.shutdown(); } }