Skip to content

Commit

Permalink
GEODE-10375: improve test to catch doc link update (apache#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmeiliao authored Jun 29, 2022
1 parent b97a7d1 commit b9ac14d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.jayway.jsonpath.JsonPath;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -32,6 +33,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.web.context.WebApplicationContext;

import org.apache.geode.test.dunit.rules.ClusterStartupRule;
Expand Down Expand Up @@ -66,12 +68,19 @@ public void before() {

@Test
public void getDocumentationLinks() throws Exception {
webContext.perform(get("/"))
MvcResult mvcResult = webContext.perform(get("/"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(header().doesNotExist("server"))
.andExpect(jsonPath("$.latest", is(basePath + "/v3/api-docs")))
.andExpect(jsonPath("$.supported", hasSize(1)))
.andExpect(jsonPath("$.supported[0]", is(basePath + "/v3/api-docs")));
.andReturn();

String content = mvcResult.getResponse().getContentAsString();
String latestLink = JsonPath.read(content, "$.latest");
webContext.perform(get(latestLink))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.info.title", is("Apache Geode Management REST API")));
}
}

0 comments on commit b9ac14d

Please sign in to comment.