@Test
public void testParseFromHttpServletRequest() throws Exception {

    // mock request
    X509Certificate[] certs = new X509Certificate[]{ this.readCert("valid_cn_x509.cert") };
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    Mockito.when(request.getAttribute(CertificateIdentityParser.JAVAX_CERT_ATTR)).thenReturn(certs);
    // mock instance
    CertificateIdentityParser mock = Mockito.spy(new CertificateIdentityParser(null, false));
    ArgumentCaptor<X509Certificate[]> argument = ArgumentCaptor.forClass(X509Certificate[].class);
    mock.parse(request);
    // verify
    Mockito.verify(mock, Mockito.times(1)).parse(argument.capture());
    assertSame(argument.getValue(), certs);
}