mirror of https://github.com/dapr/java-sdk.git
Adjust the tests
Signed-off-by: Artur Ciocanu <ciocanu@adobe.com>
This commit is contained in:
parent
4f637bc175
commit
695ec95037
|
@ -312,6 +312,7 @@ public class DaprRun implements Stoppable {
|
|||
.append(ports.getAppPort() != null ? " --app-port " + ports.getAppPort() : "")
|
||||
.append(ports.getHttpPort() != null ? " --dapr-http-port " + ports.getHttpPort() : "")
|
||||
.append(ports.getGrpcPort() != null ? " --dapr-grpc-port " + ports.getGrpcPort() : "")
|
||||
.append(" --log-level debug")
|
||||
.append(isAppHealthCheckEnabled(serviceClass) ?
|
||||
" --enable-app-health-check --app-health-probe-interval=1" : "")
|
||||
.append(serviceClass == null ? "" :
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
package io.dapr.it.methodinvoke.http;
|
||||
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
import io.dapr.client.DaprClient;
|
||||
import io.dapr.client.DaprClientBuilder;
|
||||
import io.dapr.client.domain.HttpExtension;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.post;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class GH_1314_IT {
|
||||
|
||||
private static WireMockServer wireMockServer;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
wireMockServer = new WireMockServer(3500);
|
||||
|
||||
wireMockServer.start();
|
||||
|
||||
WireMock.configureFor("localhost", 3500);
|
||||
|
||||
stubFor(post(
|
||||
urlEqualTo("/v1.0/invoke/say-hello/method/say-hello/hello")
|
||||
)
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody("\"Hello from say-hello app!\"")));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void teardown() {
|
||||
wireMockServer.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvokeSayHelloWithoutLeadingSlash() {
|
||||
String urlWithoutLeadingSlash = "say-hello/hello";
|
||||
|
||||
sayHelloUsingURL(urlWithoutLeadingSlash);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvokeSayHelloWithLeadingSlash() {
|
||||
String urlWithLeadingSlash = "/say-hello/hello";
|
||||
|
||||
sayHelloUsingURL(urlWithLeadingSlash);
|
||||
}
|
||||
|
||||
private static void sayHelloUsingURL(String url) {
|
||||
DaprClient client = new DaprClientBuilder().build();
|
||||
|
||||
try {
|
||||
Map<String, String> requestData = Map.of("message", "Hello");
|
||||
|
||||
String response = client.invokeMethod(
|
||||
"say-hello",
|
||||
url,
|
||||
requestData,
|
||||
HttpExtension.POST,
|
||||
String.class
|
||||
).block();
|
||||
|
||||
assertEquals("Hello from say-hello app!", response);
|
||||
} catch (Exception e) {
|
||||
fail("Exception occurred: " + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
client.close();
|
||||
} catch (Exception e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -81,7 +81,7 @@ public class MethodInvokeController {
|
|||
return persons;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/query-params")
|
||||
@GetMapping(path = "/query")
|
||||
public String getQueryParams(@RequestParam String uri) {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package io.dapr.it.methodinvoke.http;
|
||||
|
||||
import io.dapr.client.DaprClient;
|
||||
import io.dapr.client.DaprHttp;
|
||||
import io.dapr.client.domain.HttpExtension;
|
||||
import io.dapr.exceptions.DaprException;
|
||||
import io.dapr.it.BaseIT;
|
||||
|
@ -141,19 +140,4 @@ public class MethodInvokeIT extends BaseIT {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeQueryParams() throws Exception {
|
||||
try (DaprClient client = daprRun.newDaprClientBuilder().build()) {
|
||||
client.waitForSidecar(10000).block();
|
||||
|
||||
String uri = "abc/pqr";
|
||||
Map<String, List<String>> queryParams = Map.of("uri", List.of(uri));
|
||||
HttpExtension httpExtension = new HttpExtension(DaprHttp.HttpMethods.GET, queryParams, Map.of());
|
||||
String result = client.invokeMethod(daprRun.getAppName(), "query-params", null,
|
||||
httpExtension, String.class).block();
|
||||
|
||||
assertEquals(uri, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package io.dapr.it.methodinvoke.http;
|
||||
|
||||
import io.dapr.client.DaprClient;
|
||||
import io.dapr.client.DaprHttp;
|
||||
import io.dapr.client.domain.HttpExtension;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.DaprRun;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class MethodInvokeQueryParamEncodingIT extends BaseIT {
|
||||
|
||||
private DaprRun daprRun = null;
|
||||
|
||||
@BeforeEach
|
||||
public void init() throws Exception {
|
||||
daprRun = startDaprApp(
|
||||
MethodInvokeQueryParamEncodingIT.class.getSimpleName() + "http",
|
||||
MethodInvokeService.SUCCESS_MESSAGE,
|
||||
MethodInvokeService.class,
|
||||
true,
|
||||
30000);
|
||||
daprRun.waitForAppHealth(20000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeQueryParams() throws Exception {
|
||||
try (DaprClient client = daprRun.newDaprClientBuilder().build()) {
|
||||
client.waitForSidecar(10000).block();
|
||||
|
||||
String uri = "abc/pqr";
|
||||
Map<String, List<String>> queryParams = Map.of("uri", List.of(uri));
|
||||
HttpExtension httpExtension = new HttpExtension(DaprHttp.HttpMethods.GET, queryParams, Map.of());
|
||||
String result = client.invokeMethod(daprRun.getAppName(), "query", null,
|
||||
httpExtension, String.class).block();
|
||||
|
||||
assertEquals(uri, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue