Skip to content

Commit

Permalink
removing restassured dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
salaboy committed Jul 26, 2024
1 parent 4238719 commit 792561d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
6 changes: 0 additions & 6 deletions testcontainers-dapr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.domain.Metadata;
import io.dapr.client.domain.State;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.Testcontainers;

import java.io.IOException;
import java.util.Map;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
Expand Down Expand Up @@ -74,6 +77,7 @@ public static void setDaprProperties() {
}

private static void configStub() {

stubFor(any(urlMatching("/dapr/subscribe"))
.willReturn(aResponse().withBody("[]").withStatus(200)));

Expand Down Expand Up @@ -125,12 +129,20 @@ public void testPlacement() throws Exception {
client.waitForSidecar(5000).block();
}

RestAssured.baseURI = "http://" + daprContainer.getHost() + ":" + daprContainer.getMappedPort(3500);
JsonPath response = RestAssured.given().get("/v1.0/metadata").jsonPath();
String actorRuntimePlacement = response.getString("actorRuntime.placement");
boolean isPlacementConnected = actorRuntimePlacement.contentEquals("placement: connected");
OkHttpClient client = new OkHttpClient.Builder().build();

String url = "http://" + daprContainer.getHost() + ":" + daprContainer.getMappedPort(3500);
Request request = new Request.Builder().url(url + "/v1.0/metadata").build();

try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
assertTrue(response.body().string().contains("placement: connected"));

} else {
throw new IOException("Unexpected response: " + response.code());
}
}

assertTrue(isPlacementConnected);
}

@Test
Expand Down

0 comments on commit 792561d

Please sign in to comment.