@Test(expected = RoutingException.class)
 public void testPut() throws RoutingException {
   Routes.load(ResourceUtil.getResourceAsFile("routes/via.xml"));
   System.out.println(Routes.getRouteSet().toString());
   MockHttpServletRequest request = ((MockHttpServletRequest) RequestUtil.getRequest());
   request.setMethod("PUT");
   Routes.recognizePath("/methods/");
 }
Exemplo n.º 2
0
  /** AbstractInterceptorを継承する際に、実装する必要のあるメソッド。 割り込ませる処理を記述。 */
  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {

    //		Map<String, Object> sessionScope = SingletonS2Container.getComponent("sessionScope");
    //		LoginUserDto loginDto = (LoginUserDto) sessionScope.get("loginUserDto");
    //		// loginDtoがNULLだったり、NULLでなくてもコードがNULLの場合タイムアウトと見なす。
    //		if (loginDto == null || loginDto.userId == null) {
    //			// タイムアウト画面
    //			return "/";
    //		}

    String loginCookieValue = cookieService.getCookieValue("_coupon_island_login_");
    String fbLoginCookieValue = cookieService.getCookieValue("_coupon_island_fb_login_");
    IUserLogin userLogin = null;
    if (StringUtils.isEmpty(loginCookieValue) && StringUtils.isEmpty(fbLoginCookieValue)) {
      return "/";
    } else if (StringUtils.isNotEmpty(loginCookieValue)) {
      userLogin = loginService.getIUserLogin(loginCookieValue);
      if (userLogin == null) {
        Cookie c = new Cookie("_coupon_island_login_", null);
        c.setMaxAge(0); // 即死にする
        c.setPath(RequestUtil.getRequest().getContextPath());
        ResponseUtil.getResponse().addCookie(c);
      }
    } else if (StringUtils.isNotEmpty(fbLoginCookieValue)) {
      userLogin = loginService.getIUserLogin(fbLoginCookieValue);
      if (userLogin == null) {
        Cookie c = new Cookie("_coupon_island_fb_login_", null);
        c.setMaxAge(0); // 即死にする
        c.setPath(RequestUtil.getRequest().getContextPath());
        ResponseUtil.getResponse().addCookie(c);
      }
    }

    if (userLogin == null) {
      return "/";
    }

    loginUserDto.userId = userLogin.userId;

    return invocation.proceed();
  }
  @Test
  public void testPost() {
    Routes.load(ResourceUtil.getResourceAsFile("routes/via.xml"));
    System.out.println(Routes.getRouteSet().toString());
    MockHttpServletRequest request = ((MockHttpServletRequest) RequestUtil.getRequest());
    request.setMethod("POST");
    Options options = Routes.recognizePath("/methods/");
    System.out.println(options);

    assertThat(options.getString("action"), is("getAndPost"));
  }