@Override
  public Statement apply(final Statement statement, FrameworkMethod method,
    Object target)
  {
    LDAP ldap = method.getAnnotation(LDAP.class);

    if (ldap != null)
    {
      try
      {
        port = ldap.port();
        baseDN = ldap.baseDN();
        additionalBindDN = ldap.additionalBindDN();
        additionalBindPassword = ldap.additionalBindPassword();
        directoryServer = createDirectoryServer();

        importLdif(ldap.ldif(), target);
      }
      catch (LDAPException ex)
      {
        throw new RuntimeException(
          "could not start in memory directory server", ex);
      }

      return new Statement()
      {

        @Override
        public void evaluate() throws Throwable
        {
          try
          {
            directoryServer.startListening();
            statement.evaluate();
          }
          finally
          {
            directoryServer.shutDown(true);
          }
        }
      };
    }

    return statement;
  }
@ Override public Statement apply ( final Statement statement , FrameworkMethod method , Object target ) { LDAP ldap = method . getAnnotation ( LDAP . class ) ; if ( ldap != null ) { try { port = ldap . port ( ) ; baseDN = ldap . baseDN ( ) ; additionalBindDN = ldap . additionalBindDN ( ) ; additionalBindPassword = ldap . additionalBindPassword ( ) ; directoryServer = createDirectoryServer ( ) ; importLdif ( ldap . ldif ( ) , target ) ; } catch ( LDAPException ex ) { throw new RuntimeException ( "could not start in memory directory server" , ex ) ; } return new Statement ( ) { @ Override public void evaluate ( ) throws Throwable { try { directoryServer . startListening ( ) ; statement . evaluate ( ) ; } finally { directoryServer . shutDown ( true ) ; } } } ; } return statement ; }
{@inheritDoc}