Skip to content
Open
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 @@ -45,7 +45,7 @@ public final class RequestTemplate {

private String contextId;

private String path;
private String path = "";

private ShenyuRequest.HttpMethod httpMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public void testRequest() {
Assert.assertNotNull(shenyuRequest);
}

@Test
public void testRequestWithoutPath() {
RequestTemplate template = new RequestTemplate();
template.setUrl("http://gateway");
template.setHttpMethod(ShenyuRequest.HttpMethod.GET);

ShenyuRequest shenyuRequest = template.request();

Assert.assertEquals("http://gateway", shenyuRequest.getUrl());
}

public void assertNotNull(final RequestTemplate requestTemplate) {
Assert.assertNotNull(requestTemplate);
Assert.assertNotNull(requestTemplate.getReturnType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ public class SpringMvcContractTest {

private static final Method DEL;

private static final Method HEALTH;

static {
try {
FIND_BY_ID = InvocationClient.class.getDeclaredMethod("findById", String.class);
INSERT = InvocationClient.class.getDeclaredMethod("insert", MetaData.class);
UPDATE = InvocationClient.class.getDeclaredMethod("update", MetaData.class);
DEL = InvocationClient.class.getDeclaredMethod("del", String.class);
HEALTH = InvocationClient.class.getDeclaredMethod("health");
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -95,6 +98,17 @@ public void parseRequestTplTest() {
assertEquals(template.getHttpMethod(), ShenyuRequest.HttpMethod.DELETE);
}

@Test
public void parseRootMappingRequestTemplateTest() {
SpringMvcContract contract = new SpringMvcContract();

RequestTemplate template = contract.parseRequestTemplate(HEALTH, bean);

assertSame(template.getMethod(), HEALTH);
assertEquals("", template.getPath());
assertEquals(ShenyuRequest.HttpMethod.GET, template.getHttpMethod());
}

@ShenyuClient(value = "invocationClient", path = "/dev/null")
public interface InvocationClient {

Expand Down Expand Up @@ -129,6 +143,13 @@ public interface InvocationClient {
*/
@DeleteMapping("/delete")
int del(@RequestParam("id") String id);

/**
* health check mapping.
* @return status
*/
@GetMapping
String health();
}

}
Loading