Package org.springframework.test.web.servlet

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()


   
    @Test
    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here


    @Test
    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here

    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here

        // WHEN - circuit viewed
        ResultActions result = mockMvc.perform(get("/circuit/{id}", id));

        // THEN - circuit should be in the model
        result.andExpect(status().isOk()).andExpect(model().attribute("receivedId", is(id)));

    }

    @Test
    public void voidTestEncodingInTestCase() throws Exception {
View Full Code Here

        // WHEN - circuit viewed
        ResultActions result = mockMvc.perform(get("/circuit/{id}", id));

        // THEN - circuit should be in the model
        result.andExpect(status().isOk()).andExpect(model().attribute("receivedId", is("a/b")));

    }

}
View Full Code Here

  public void exposesRootResource() throws Exception {

    ResultActions actions = mvc.perform(get("/").accept(DEFAULT_MEDIA_TYPE)).andExpect(status().isOk());

    for (String rel : expectedRootLinkRels()) {
      actions.andExpect(hasLinkWithRel(rel));
    }
  }

  /**
   * @see DATAREST-113
View Full Code Here

    public void containsBlogPostFields() throws Exception {
        Post post = PostBuilder.post().category(PostCategory.ENGINEERING).isBroadcast().build();
        postRepository.save(post);

        ResultActions resultActions = mockMvc.perform(get("/blog.atom"));
        MvcResult mvcResult = resultActions
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("application/atom+xml"))
                .andReturn();

        assertThat(mvcResult.getResponse().getCharacterEncoding(), equalTo("utf-8"));
View Full Code Here

  @Test
  public void test() throws Exception {
    String id = "a/b";
    URI url = UriComponentsBuilder.fromUriString("/circuit").pathSegment(id).build().encode().toUri();
    ResultActions result = mockMvc.perform(get(url));
    result.andExpect(status().isOk()).andExpect(model().attribute("receivedId", is(id)));
  }


  @Configuration
  @EnableWebMvc
View Full Code Here

  @Test
  public void testGettingPatient() throws Exception {
    ResultActions resultActions = this.mockMvc.perform(get("/patients/" + createdPatientId)
        .accept(MediaType.APPLICATION_JSON));
    LOG.debug("RestultActons: " + resultActions.andReturn().getResponse().getContentAsString()) ;
    resultActions.andExpect(status().isOk())
    .andExpect(content().string(containsString(String.valueOf(createdPatientId))));
 
 
  @Test
  public void testInsertingPatient() throws Exception {
View Full Code Here

    ResultActions resultActions = null;
    ApiResponse<Patient> retrievedPatient = null;
    try {
      resultActions = this.mockMvc.perform(post("/patients").content(convertObjectToBytes(testPatientToInsert)).contentType(MediaType.APPLICATION_JSON));
      LOG.debug("RestultActons: " + resultActions.andReturn().getResponse().getContentAsString()) ;
      resultActions.andExpect(status().isOk())
             .andExpect(content().string(notNullValue()));
     
    } finally {
      if (resultActions != null) {
        retrievedPatient = this.jsonToObject(resultActions.andReturn().getResponse().getContentAsString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.