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

fix(test): converted some MockWebServer to long-running instances #588

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void setUp() {
@AfterEach
void tearDown() throws IOException {
if (mockEndpoint != null) {
mockEndpoint.close();
mockEndpoint.shutdown();
}
}

Expand Down