コード例 #1
0
  @Test
  public void testbatchRegardTest() {
    CaringRequest caringRequest = new CaringRequest();
    caringRequest.setCaringperson("我是客服");
    caringRequest.setCaringType("28");
    caringRequest.setContent("我是短信内容");
    caringRequest.setCustomerno("用户昵称");
    caringRequest.setDpId("654321");
    caringRequest.setGatewayId(1L);

    caringRequest.setOids(new String[] {"999999"});
    caringRequest.setTids(new String[] {"123456"});

    System.out.println(JackSonMapper.toCJsonString(caringRequest));

    DefaultRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/batch/regard");
    requestBuilder.characterEncoding("UTF-8");
    requestBuilder.body(
        JackSonMapper.toCJsonString(caringRequest).getBytes(Charset.forName("UTF-8")));
    requestBuilder.contentType(MediaType.APPLICATION_JSON);
    requestBuilder.accept(MediaType.APPLICATION_JSON);
    try {
      this.mockMvc.perform(requestBuilder).andExpect(new StatusResultMatchers().isOk());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  /**
   * Test method for {@link org.sagar.samples.controller.spring.HomeController#home()}.
   *
   * @throws Exception
   */
  @Test
  public void testHome() throws Exception {
    System.out.println("excecuting test method 1");
    HomeController homeController = new HomeController();
    ModelAndView mnv = homeController.home();
    assertEquals(mnv.getViewName(), "home");
    assertEquals((String) mnv.getModel().get("name"), "Sagar Prasad");

    // ------------MVC TESTING------------------//
    mockMvc
        .perform(MockMvcRequestBuilders.get("/home").accept(MediaType.APPLICATION_XML))
        .andExpect(MockMvcResultMatchers.status().isOk())
        .andDo(print());
    ;
  }
コード例 #3
0
 @Test
 public void testCustomerOrdersShip() {
   DefaultRequestBuilder requestBuilder =
       MockMvcRequestBuilders.get("/customerCenter/orders/customerOrdersShip");
   requestBuilder
       .contentType(MediaType.APPLICATION_JSON)
       .accept(MediaType.APPLICATION_JSON)
       .characterEncoding("UTF-8");
   try {
     ResultActions action =
         this.mockMvc.perform(requestBuilder).andExpect(new StatusResultMatchers().isOk());
     System.out.println(action.andReturn().getResponse().getContentAsString());
     System.out.println(action.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #4
0
 @Test
 public void testUrPayOrdersLogList() {
   DefaultRequestBuilder req =
       MockMvcRequestBuilders.post("/customerCenter/orders/urPayOrdersLogList")
           .param("currPage", "1")
           .param("pageSize", "10")
           .param("dpId", "a")
           .contentType(MediaType.APPLICATION_JSON)
           .accept(MediaType.APPLICATION_JSON)
           .characterEncoding("UTF-8");
   try {
     ResultActions actions =
         this.mockMvc.perform(req).andExpect(new StatusResultMatchers().isOk());
     System.out.println(actions.andReturn().getResponse().getContentAsString());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #5
0
 @Test
 public void testQuery() {
   DefaultRequestBuilder requestBuilder =
       MockMvcRequestBuilders.post("/traderate/query")
           .body(
               "{\"content\":\"内容\",\"isExplainFlag\":\"true\",\"currPage\":\"1\",\"pageSize\":\"1\"}"
                   .getBytes())
           .contentType(MediaType.APPLICATION_JSON)
           .accept(MediaType.APPLICATION_JSON)
           .characterEncoding("UTF-8");
   try {
     ResultActions action =
         this.mockMvc.perform(requestBuilder).andExpect(new StatusResultMatchers().isOk());
     action.andReturn().getResponse().setCharacterEncoding("UTF-8");
     System.out.println(action.andReturn().getResponse().getContentAsString());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #6
0
  @Test
  public void getAutoSetTest() {
    String dp_id = "100571094";
    DefaultRequestBuilder requestBuilder =
        MockMvcRequestBuilders.get("/ordermonitor/orders/orderMonitor30");
    requestBuilder.characterEncoding("UTF-8");
    requestBuilder.param("dpId", dp_id);
    requestBuilder.contentType(MediaType.APPLICATION_JSON);
    requestBuilder.accept(MediaType.APPLICATION_JSON);

    try {
      ResultActions action =
          this.mockMvc.perform(requestBuilder).andExpect(new StatusResultMatchers().isOk());
      action.andReturn().getResponse().setCharacterEncoding("UTF-8");
      System.out.println(action.andReturn().getResponse().getContentAsString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #7
0
  @Test
  public void autoSetTest() {
    TraderateAutoSetRequest traderateAutoSetRequest = new TraderateAutoSetRequest();
    traderateAutoSetRequest.setDpId("100571094");
    traderateAutoSetRequest.setType("order_success");
    traderateAutoSetRequest.setContent("非常棒的买家,收到宝贝有任何问题请立即与小店售后联系!");
    traderateAutoSetRequest.setStatus(0);

    DefaultRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/traderate/autoset");
    requestBuilder.characterEncoding("UTF-8");
    requestBuilder.body(
        JackSonMapper.toCJsonString(traderateAutoSetRequest).getBytes(Charset.forName("UTF-8")));
    requestBuilder.contentType(MediaType.APPLICATION_JSON);
    requestBuilder.accept(MediaType.APPLICATION_JSON);
    try {
      this.mockMvc.perform(requestBuilder).andExpect(new StatusResultMatchers().isOk());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }