/** Test method for {@link X509Authenticator#startAuthentication(Credential, Connection)} . */
  @Test
  public void testStartAuthentication() {
    final Credential credential = Credential.builder().userName("CN=foo").build();
    final Connection mockConnection = createMock(Connection.class);
    final Capture<ReplyCallback> capture = new Capture<ReplyCallback>();

    final DocumentBuilder b = BuilderFactory.start();
    b.add("authenticate", 1);
    b.add("user", "CN=foo");
    b.add("mechanism", X509Authenticator.MECHANISM);

    mockConnection.send(
        eq(new Command(X509Authenticator.EXTERNAL, Command.COMMAND_COLLECTION, b.build())),
        capture(capture));
    expectLastCall();

    replay(mockConnection);

    final X509Authenticator auth = new X509Authenticator();

    auth.startAuthentication(credential, mockConnection);

    verify(mockConnection);

    assertThat(capture.getValue(), instanceOf(X509ResponseCallback.class));
  }
  /** Test method for {@link X509Authenticator#clone()} . */
  @Test
  public void testClone() {
    final X509Authenticator auth = new X509Authenticator();

    final X509Authenticator clone = auth.clone();

    assertThat(clone, not(sameInstance(auth)));
    assertThat(clone.myResults, not(sameInstance(auth.myResults)));
  }