org.hamcrest.beans.HasPropertyWithValue Java Examples

The following examples show how to use org.hamcrest.beans.HasPropertyWithValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveStateSameSiteCookieAndFallbackCookie() {
    Cookie cookie1 = new Cookie("com.auth0.state", "123456");
    Cookie cookie2 = new Cookie("_com.auth0.state", "123456");

    request.setCookies(cookie1, cookie2);

    String state = TransientCookieStore.getState(request, response, true);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(2));

    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #2
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveStateSameSiteCookie() {
    Cookie cookie1 = new Cookie("com.auth0.state", "123456");

    request.setCookies(cookie1);

    String state = TransientCookieStore.getState(request, response, false);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(1));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #3
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveStateFallbackCookie() {
    Cookie cookie1 = new Cookie("_com.auth0.state", "123456");

    request.setCookies(cookie1);

    String state = TransientCookieStore.getState(request, response, true);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(1));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #4
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveNonceSameSiteCookieAndFallbackCookie() {
    Cookie cookie1 = new Cookie("com.auth0.nonce", "123456");
    Cookie cookie2 = new Cookie("_com.auth0.nonce", "123456");

    request.setCookies(cookie1, cookie2);

    String state = TransientCookieStore.getNonce(request, response, true);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(2));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #5
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveNonceSameSiteCookie() {
    Cookie cookie1 = new Cookie("com.auth0.nonce", "123456");

    request.setCookies(cookie1);

    String state = TransientCookieStore.getNonce(request, response, true);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(1));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #6
Source File: TransientCookieStoreTest.java    From auth0-java-mvc-common with MIT License 6 votes vote down vote up
@Test
public void shouldRemoveNonceFallbackCookie() {
    Cookie cookie1 = new Cookie("_com.auth0.nonce", "123456");

    request.setCookies(cookie1);

    String state = TransientCookieStore.getNonce(request, response, true);
    assertThat(state, is("123456"));

    Cookie[] cookies = response.getCookies();
    assertThat(cookies, is(notNullValue()));

    List<Cookie> cookieList = Arrays.asList(cookies);
    assertThat(cookieList.size(), is(1));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("value", is(""))));
    assertThat(Arrays.asList(cookies), everyItem(HasPropertyWithValue.hasProperty("maxAge", is(0))));
}
 
Example #7
Source File: AbstractErrorControllerTest.java    From find with MIT License 5 votes vote down vote up
@Test
public void serverErrorPageWithUUID() {
    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, mock(Exception.class));

    assertNotNull(errorController.serverErrorPage(request, response));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("mainMessageCode", is(CustomErrorController.MESSAGE_CODE_INTERNAL_SERVER_ERROR_MAIN))));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("subMessageCode", is(CustomErrorController.MESSAGE_CODE_INTERNAL_SERVER_ERROR_SUB))));
}
 
Example #8
Source File: VoltronReadWriteLockActiveEntityTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteUnlockNotifiesListeners() throws MessageCodecException {
  ActiveInvokeContext<LockTransition> locker = newContext();
  ActiveInvokeContext<LockTransition> waiter = newContext();

  ClientDescriptor waiterDescriptor = () -> null;
  when(waiter.getClientDescriptor()).thenReturn(waiterDescriptor);

  entity.invokeActive(locker, LockMessaging.lock(WRITE));
  entity.invokeActive(waiter, LockMessaging.lock(WRITE));
  entity.invokeActive(locker, LockMessaging.unlock(WRITE));

  verify(communicator).sendNoResponse(same(waiterDescriptor), argThat(
          HasPropertyWithValue.<EntityResponse>hasProperty("released", is(true))));
}
 
Example #9
Source File: VoltronReadWriteLockActiveEntityTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadUnlockNotifiesListeners() throws MessageCodecException {
  ActiveInvokeContext<LockTransition> locker = newContext();
  ActiveInvokeContext<LockTransition> waiter = newContext();

  ClientDescriptor waiterDescriptor = () -> null;
  when(waiter.getClientDescriptor()).thenReturn(waiterDescriptor);

  entity.invokeActive(locker, LockMessaging.lock(READ));
  entity.invokeActive(waiter, LockMessaging.lock(WRITE));
  entity.invokeActive(locker, LockMessaging.unlock(READ));

  verify(communicator).sendNoResponse(same(waiterDescriptor), argThat(
          HasPropertyWithValue.<EntityResponse>hasProperty("released", is(true))));
}
 
Example #10
Source File: HodErrorControllerTest.java    From find with MIT License 4 votes vote down vote up
@Test
public void clientAuthenticationErrorPage() {
    assertNotNull(errorController.clientAuthenticationErrorPage(request));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("mainMessageCode", is(HodErrorController.MESSAGE_CODE_CLIENT_AUTHENTICATION_ERROR_MAIN))));
}
 
Example #11
Source File: AbstractErrorControllerTest.java    From find with MIT License 4 votes vote down vote up
@Test
public void authenticationErrorPage() {
    assertNotNull(errorController.authenticationErrorPage(request, response));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("mainMessageCode", is(CustomErrorController.MESSAGE_CODE_AUTHENTICATION_ERROR_MAIN))));
}
 
Example #12
Source File: AbstractErrorControllerTest.java    From find with MIT License 4 votes vote down vote up
@Test
public void serverErrorPageWithoutUUID() {
    assertNotNull(errorController.serverErrorPage(request, response));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("mainMessageCode", is(CustomErrorController.MESSAGE_CODE_INTERNAL_SERVER_ERROR_MAIN))));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("subMessageCode", is(CustomErrorController.MESSAGE_CODE_INTERNAL_SERVER_ERROR_SUB))));
}
 
Example #13
Source File: AbstractErrorControllerTest.java    From find with MIT License 4 votes vote down vote up
@Test
public void notFoundError() {
    assertNotNull(errorController.notFoundError(request, response));
    verify(controllerUtils).buildErrorModelAndView(argThat(new HasPropertyWithValue<>("mainMessageCode", is(CustomErrorController.MESSAGE_CODE_NOT_FOUND_MAIN))));
}