Java Code Examples for org.apache.directory.api.ldap.model.message.AddResponse#getLdapResult()

The following examples show how to use org.apache.directory.api.ldap.model.message.AddResponse#getLdapResult() . 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: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test parsing of a response with Result Code
 */
@Test
public void testResponseWithResultCode()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser
            .setInput( AddResponseTest.class.getResource( "response_with_result_code.xml" ).openStream(), "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    assertEquals( ResultCodeEnum.PROTOCOL_ERROR, ldapResult.getResultCode() );
}
 
Example 2
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test parsing of a response with Error Message
 */
@Test
public void testResponseWithErrorMessage()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AddResponseTest.class.getResource( "response_with_error_message.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
        .getDiagnosticMessage() );
}
 
Example 3
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test parsing of a response with empty Error Message
 */
@Test
public void testResponseWithEmptyErrorMessage()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AddResponseTest.class.getResource( "response_with_empty_error_message.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    assertNull( ldapResult.getDiagnosticMessage() );
}
 
Example 4
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test parsing of a response with MatchedDN attribute
 */
@Test
public void testResponseWithMatchedDNAttribute()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AddResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    assertTrue( ldapResult.getMatchedDn().equals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM" ) );
}
 
Example 5
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Test parsing of a response with a Referral
 */
@Test
public void testResponseWith1Referral()
{
    Dsmlv2ResponseParser parser = null;

    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AddResponseTest.class.getResource( "response_with_1_referral.xml" ).openStream(), "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();

    assertEquals( 1, referrals.size() );

    assertTrue( referrals.contains( "ldap://www.apache.org/" ) );
}
 
Example 6
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Test parsing of a response with an empty Referral
 */
@Test
public void testResponseWith1EmptyReferral()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AddResponseTest.class.getResource( "response_with_1_empty_referral.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();

    assertEquals( 0, referrals.size() );
}
 
Example 7
Source File: AddResponseTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Test parsing of a response with 2 Referral elements
 */
@Test
public void testResponseWith2Referrals()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser
            .setInput( AddResponseTest.class.getResource( "response_with_2_referrals.xml" ).openStream(), "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = addResponse.getLdapResult();

    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();

    assertEquals( 2, referrals.size() );

    assertTrue( referrals.contains( "ldap://www.apache.org/" ) );
    assertTrue( referrals.contains( "ldap://www.apple.com/" ) );
}