Package org.springframework.test.web

Examples of org.springframework.test.web.Person


  private MockMvc mockMvc;

  @Before
  public void setup() {

    SampleController controller = new SampleController("a string value", 3, new Person("a name"));

    this.mockMvc = standaloneSetup(controller)
        .defaultRequest(get("/"))
        .alwaysExpect(status().isOk())
        .build();
View Full Code Here


    @RequestMapping(value="/music/people")
    public @ResponseBody PeopleWrapper getPeople() {

      List<Person> composers = Arrays.asList(
          new Person("Johann Sebastian Bach").setSomeDouble(21),
          new Person("Johannes Brahms").setSomeDouble(.0025),
          new Person("Edvard Grieg").setSomeDouble(1.6035),
          new Person("Robert Schumann").setSomeDouble(Double.NaN));

      return new PeopleWrapper(composers);
    }
View Full Code Here

    @RequestMapping(value="/music/people")
    public @ResponseBody MultiValueMap<String, Person> get() {
      MultiValueMap<String, Person> map = new LinkedMultiValueMap<String, Person>();

      map.add("composers", new Person("Johann Sebastian Bach"));
      map.add("composers", new Person("Johannes Brahms"));
      map.add("composers", new Person("Edvard Grieg"));
      map.add("composers", new Person("Robert Schumann"));

      map.add("performers", new Person("Vladimir Ashkenazy"));
      map.add("performers", new Person("Yehudi Menuhin"));

      return map;
    }
View Full Code Here

    @RequestMapping(value="/music/people")
    public @ResponseBody PeopleWrapper getPeople() {

      List<Person> composers = Arrays.asList(
          new Person("Johann Sebastian Bach").setSomeDouble(21),
          new Person("Johannes Brahms").setSomeDouble(.0025),
          new Person("Edvard Grieg").setSomeDouble(1.6035),
          new Person("Robert Schumann").setSomeDouble(Double.NaN));

      List<Person> performers = Arrays.asList(
          new Person("Vladimir Ashkenazy").setSomeBoolean(false),
          new Person("Yehudi Menuhin").setSomeBoolean(true));

      return new PeopleWrapper(composers, performers);
    }
View Full Code Here


  @Before
  public void setup() {
    this.people = new LinkedMultiValueMap<String, Person>();
    this.people.add("composers", new Person("Johann Sebastian Bach"));
    this.people.add("composers", new Person("Johannes Brahms"));
    this.people.add("composers", new Person("Edvard Grieg"));
    this.people.add("composers", new Person("Robert Schumann"));
    this.people.add("performers", new Person("Vladimir Ashkenazy"));
    this.people.add("performers", new Person("Yehudi Menuhin"));

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new MappingJackson2HttpMessageConverter());

    this.restTemplate = new RestTemplate();
View Full Code Here

  @Before
  public void setup() {

    List<Person> composers = Arrays.asList(
        new Person("Johann Sebastian Bach").setSomeDouble(21),
        new Person("Johannes Brahms").setSomeDouble(.0025),
        new Person("Edvard Grieg").setSomeDouble(1.6035),
        new Person("Robert Schumann").setSomeDouble(Double.NaN));

    List<Person> performers = Arrays.asList(
        new Person("Vladimir Ashkenazy").setSomeBoolean(false),
        new Person("Yehudi Menuhin").setSomeBoolean(true));

    this.people = new PeopleWrapper(composers, performers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());
View Full Code Here

  @Before
  public void setup() {

    List<Person> composers = Arrays.asList(
        new Person("Johann Sebastian Bach").setSomeDouble(21),
        new Person("Johannes Brahms").setSomeDouble(.0025),
        new Person("Edvard Grieg").setSomeDouble(1.6035),
        new Person("Robert Schumann").setSomeDouble(Double.NaN));

    this.people = new PeopleWrapper(composers);

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new Jaxb2RootElementHttpMessageConverter());
View Full Code Here

  }

  @Test
  public void contentType() throws Exception {
    this.mockServer.expect(content().contentType("application/json;charset=UTF-8")).andRespond(withSuccess());
    this.restTemplate.put(new URI("/foo"), new Person());
    this.mockServer.verify();
  }
View Full Code Here

    String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}";

    this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET))
      .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));

    @SuppressWarnings("unused")
    Person ludwig = restTemplate.getForObject("/composers/{id}", Person.class, 42);

    // We are only validating the request. The response is mocked out.
    // hotel.getId() == 42
    // hotel.getName().equals("Holiday Inn")
View Full Code Here

    Resource responseBody = new ClassPathResource("ludwig.json", this.getClass());

    this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET))
      .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));

    @SuppressWarnings("unused")
    Person ludwig = restTemplate.getForObject("/composers/{id}", Person.class, 42);

    // hotel.getId() == 42
    // hotel.getName().equals("Holiday Inn")
View Full Code Here

TOP

Related Classes of org.springframework.test.web.Person

Copyright © 2018 www.massapicom. 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.