当前位置: 首页>>代码示例>>Java>>正文


Java Strings.dumpBytes方法代码示例

本文整理汇总了Java中org.apache.directory.api.util.Strings.dumpBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.dumpBytes方法的具体用法?Java Strings.dumpBytes怎么用?Java Strings.dumpBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.api.util.Strings的用法示例。


在下文中一共展示了Strings.dumpBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDecodeSubEntryVisibilityFalse

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a SubEntryControl with a false visibility
 */
@Test
public void testDecodeSubEntryVisibilityFalse() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 0x03 );
    bb.put( new byte[]
        {
            0x01, 0x01, 0x00 // Visibility ::= BOOLEAN
    } );
    bb.flip();

    SubentriesDecorator decorator = new SubentriesDecorator( codec );

    Subentries subentries = ( Subentries ) decorator.decode( bb.array() );

    assertFalse( subentries.isVisible() );

    // test encoding
    try
    {
        ByteBuffer buffer = decorator.encode( ByteBuffer.allocate( decorator.computeLength() ) );
        String expected = Strings.dumpBytes( bb.array() );
        String decoded = Strings.dumpBytes( buffer.array() );
        assertEquals( expected, decoded );
    }
    catch ( EncoderException e )
    {
        fail( e.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:33,代码来源:SubEntryControlTest.java

示例2: testSyncDoneValueControlWithEmptyCookie

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
@Test
public void testSyncDoneValueControlWithEmptyCookie() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 7 );

    bb.put( new byte[]
        {
            0x30, 0x05,
            0x04, 0x00, // empty cookie
            0x01,
            0x01,
            0x00 // refreshDeletes flag FALSE
    } );

    bb.flip();

    SyncDoneValue decorator = new SyncDoneValueDecorator( codec );

    SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );

    assertEquals( "", Strings.utf8ToString( control.getCookie() ) );
    assertFalse( control.isRefreshDeletes() );

    // test encoding
    try
    {
        ByteBuffer buffer = ( ( SyncDoneValueDecorator ) control ).encode( ByteBuffer
            .allocate( ( ( SyncDoneValueDecorator ) control ).computeLength() ) );
        String decoded = Strings.dumpBytes( buffer.array() );
        assertEquals( "0x30 0x00 ", decoded );
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:SyncDoneValueControlTest.java

示例3: testSyncDoneValueControl

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
@Test
public void testSyncDoneValueControl() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 11 );

    bb.put( new byte[]
        {
            0x30, 0x09,
            0x04, 0x04, 'x', 'k', 'c', 'd', // the cookie 
            0x01,
            0x01,
            ( byte ) 0xFF // refreshDeletes flag TRUE
    } );

    bb.flip();

    SyncDoneValue decorator = new SyncDoneValueDecorator( codec );

    SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );

    assertEquals( "xkcd", Strings.utf8ToString( control.getCookie() ) );
    assertTrue( control.isRefreshDeletes() );

    // test encoding
    try
    {
        ByteBuffer buffer = ( ( SyncDoneValueDecorator ) control ).encode( ByteBuffer
            .allocate( ( ( SyncDoneValueDecorator ) control ).computeLength() ) );
        String expected = Strings.dumpBytes( bb.array() );
        String decoded = Strings.dumpBytes( buffer.array() );
        assertEquals( expected, decoded );
    }
    catch ( EncoderException e )
    {
        fail( e.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:SyncDoneValueControlTest.java

示例4: testEncodePagedSearchControlNegativeSize

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test encoding of a PagedSearchControl with a negative size
 */
@Test
public void testEncodePagedSearchControlNegativeSize() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 0x0b );
    bb.put( new byte[]
        {
            0x30, 0x09, // realSearchControlValue ::= SEQUENCE {
            0x02,
            0x01,
            ( byte ) 0xFF, // size INTEGER,
            0x04,
            0x04,
            't',
            'e',
            's',
            't' // cookie OCTET STRING,
    } );
    bb.flip();

    PagedResultsDecorator decorator = new PagedResultsDecorator( codec );

    PagedResults pagedSearch = ( PagedResults ) decorator.decode( bb.array() );

    assertEquals( Integer.MAX_VALUE, pagedSearch.getSize() );
    assertTrue( Arrays.equals( Strings.getBytesUtf8( "test" ),
        pagedSearch.getCookie() ) );

    bb.flip();

    PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
    ctrl.setSize( -1 );
    ctrl.setCookie( Strings.getBytesUtf8( "test" ) );

    ByteBuffer buffer = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) );
    String decoded = Strings.dumpBytes( buffer.array() );
    String expected = Strings.dumpBytes( bb.array() );
    assertEquals( expected, decoded );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:42,代码来源:PagedSearchControlTest.java

示例5: testDecodePasswordModifyResponseUserIdentityNull

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a PasswordModifyResponse with an empty genPassword
 */
@Test
public void testDecodePasswordModifyResponseUserIdentityNull()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x04 );
    bb.put( new byte[]
        { 0x30, 0x02, // PasswordModifyResponse ::= SEQUENCE {
            ( byte ) 0x80,
            0x00 // genPassword    [0]  OCTET STRING OPTIONAL
    } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    PasswordModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
    assertNotNull( pwdModifyResponse.getGenPassword() );
    assertEquals( 0, pwdModifyResponse.getGenPassword().length );

    // Check the length
    assertEquals( 0x04, ( ( PasswordModifyResponseDecorator ) pwdModifyResponse ).computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = ( ( PasswordModifyResponseDecorator ) pwdModifyResponse ).encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:52,代码来源:PasswordModifyResponseTest.java

示例6: testDecodePasswordModifyRequestUserIdentityValueOldPasswordValue

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a PasswordModifyRequest with a user identity
 */
@Test
public void testDecodePasswordModifyRequestUserIdentityValueOldPasswordValue()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x0E );
    bb.put( new byte[]
        { 0x30, 0x0C, // PasswordModifyRequest ::= SEQUENCE {
            ( byte ) 0x80,
            0x04, // userIdentity    [0]  OCTET STRING OPTIONAL
            'a',
            'b',
            'c',
            'd',
            ( byte ) 0x81,
            0x04, // oldPassword    [1]  OCTET STRING OPTIONAL
            'e',
            'f',
            'g',
            'h'
    } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    PasswordModifyRequestContainer container = new PasswordModifyRequestContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    PasswordModifyRequest pwdModifyRequest = container.getPwdModifyRequest();
    assertNotNull( pwdModifyRequest.getUserIdentity() );
    assertEquals( "abcd", Strings.utf8ToString( pwdModifyRequest.getUserIdentity() ) );
    assertNotNull( pwdModifyRequest.getOldPassword() );
    assertEquals( "efgh", Strings.utf8ToString( pwdModifyRequest.getOldPassword() ) );
    assertNull( pwdModifyRequest.getNewPassword() );

    // Check the length
    assertEquals( 0x0E, ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:65,代码来源:PasswordModifyRequestTest.java

示例7: testEncodeEntryChangeControlLong

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test encoding of a EntryChangeControl with a long changeNumber.
 */
@Test
public void testEncodeEntryChangeControlLong() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 0x13 );
    bb.put( new byte[]
        {
            0x30, 0x11, // EntryChangeNotification ::= SEQUENCE {
            0x0A,
            0x01,
            0x08, //     changeType ENUMERATED {
                  //         modDN (8)
                  //     }
            0x04,
            0x03,
            'a',
            '=',
            'b', //     previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
            0x02,
            0x07, //     changeNumber INTEGER OPTIONAL -- if supported
            0x12,
            0x34,
            0x56,
            0x78,
            ( byte ) 0x9a,
            ( byte ) 0xbc,
            ( byte ) 0xde
    } );

    String expected = Strings.dumpBytes( bb.array() );
    bb.flip();

    EntryChangeDecorator decorator = new EntryChangeDecorator( codec );

    EntryChange entryChange = ( EntryChange ) decorator.getDecorated();

    entryChange.setChangeType( ChangeType.MODDN );
    entryChange.setChangeNumber( 5124095576030430L );
    entryChange.setPreviousDn( new Dn( "a=b" ) );
    bb = decorator.encode( ByteBuffer.allocate( decorator.computeLength() ) );
    String decoded = Strings.dumpBytes( bb.array() );
    assertEquals( expected, decoded );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:46,代码来源:EntryChangeControlTest.java

示例8: testDecodeAbandonRequestNoControlsHighMessageId

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a AbandonRequest with no controls
 */
@Test
public void testDecodeAbandonRequestNoControlsHighMessageId()
{
    Asn1Decoder ldapDecoder = new Asn1Decoder();

    ByteBuffer stream = ByteBuffer.allocate( 0x0A );
    stream.put( new byte[]
        { 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
            // messageID MessageID
            0x02,
            0x03,
            0x00,
            ( byte ) 0x80,
            0x13,
            0x50,
            0x01,
            0x02 // CHOICE { ..., abandonRequest
        // AbandonRequest,...
        // AbandonRequest ::= [APPLICATION 16] MessageID
    } );

    String decodedPdu = Strings.dumpBytes( stream.array() );
    stream.flip();

    // Allocate a LdapMessageContainer Container
    LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
        new LdapMessageContainer<AbandonRequestDecorator>( codec );

    // Decode the PDU
    try
    {
        ldapDecoder.decode( stream, ldapMessageContainer );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    // Check that everything is OK
    AbandonRequest abandonRequest = ldapMessageContainer.getMessage();

    assertEquals( 32787, abandonRequest.getMessageId() );
    assertEquals( 2, abandonRequest.getAbandoned() );

    // Check the length
    AbandonRequest internalAbandonRequest = new AbandonRequestImpl( abandonRequest.getAbandoned() );
    internalAbandonRequest.setMessageId( abandonRequest.getMessageId() );

    // Check the encoding
    try
    {
        ByteBuffer bb = encoder.encodeMessage( internalAbandonRequest );

        // Check the length
        assertEquals( 0x0A, bb.limit() );

        String encodedPdu = Strings.dumpBytes( bb.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:71,代码来源:AbandonRequestTest.java

示例9: testDecodeModifyResponseSuccess

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a ModifyResponse
 */
@Test
public void testDecodeModifyResponseSuccess()
{
    Asn1Decoder ldapDecoder = new Asn1Decoder();

    ByteBuffer stream = ByteBuffer.allocate( 0x0E );

    stream.put( new byte[]
        { 0x30, 0x0C, // LDAPMessage ::=SEQUENCE {
            0x02,
            0x01,
            0x01, // messageID MessageID
            0x67,
            0x07, // CHOICE { ..., modifyResponse ModifyResponse, ...
            // ModifyResponse ::= [APPLICATION 7] LDAPResult
            0x0A,
            0x01,
            0x00, // LDAPResult ::= SEQUENCE {
            // resultCode ENUMERATED {
            // success (0), ...
            // },
            0x04,
            0x00, // matchedDN LDAPDN,
            0x04,
            0x00 // errorMessage LDAPString,
        // referral [3] Referral OPTIONAL }
        // }
    } );

    String decodedPdu = Strings.dumpBytes( stream.array() );
    stream.flip();

    // Allocate a LdapMessage Container
    LdapMessageContainer<ModifyResponseDecorator> ldapMessageContainer =
        new LdapMessageContainer<ModifyResponseDecorator>( codec );

    // Decode a ModifyResponse PDU
    try
    {
        ldapDecoder.decode( stream, ldapMessageContainer );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    // Check the decoded ModifyResponse PDU
    ModifyResponse modifyResponse = ldapMessageContainer.getMessage();

    assertEquals( 1, modifyResponse.getMessageId() );
    assertEquals( ResultCodeEnum.SUCCESS, modifyResponse.getLdapResult().getResultCode() );
    assertEquals( "", modifyResponse.getLdapResult().getMatchedDn().getName() );
    assertEquals( "", modifyResponse.getLdapResult().getDiagnosticMessage() );

    // Check the encoding
    try
    {
        ByteBuffer bb = encoder.encodeMessage( modifyResponse );

        // Check the length
        assertEquals( 0x0E, bb.limit() );

        String encodedPdu = Strings.dumpBytes( bb.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:77,代码来源:ModifyResponseTest.java

示例10: testDecodeGracefulShutdownDelay32767

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a GracefulShutdown with a delay equals 32767
 */
@Test
public void testDecodeGracefulShutdownDelay32767()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x06 );
    bb.put( new byte[]
        { 0x30, 0x04, // GracefulShutdown ::= SEQUENCE {
            ( byte ) 0x80,
            0x02,
            0x7F,
            ( byte ) 0xFF // delay INTEGER
                          // (0..86400)
                          // DEFAULT 0
    } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    GracefulShutdownContainer container = new GracefulShutdownContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    GracefulShutdownRequestDecorator gracefulShutdownRequest = container.getGracefulShutdownRequest();
    assertEquals( 0, gracefulShutdownRequest.getTimeOffline() );
    assertEquals( 32767, gracefulShutdownRequest.getDelay() );

    // Check the length
    assertEquals( 0x06, gracefulShutdownRequest.computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = gracefulShutdownRequest.encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:56,代码来源:GracefulShutdownTest.java

示例11: testDecodePasswordModifyRequestEmpty

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a PasswordModifyRequest with nothing in it
 */
@Test
public void testDecodePasswordModifyRequestEmpty()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x02 );
    bb.put( new byte[]
        { 0x30, 0x00, // PasswordModifyRequest ::= SEQUENCE {
        } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    PasswordModifyRequestContainer container = new PasswordModifyRequestContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    PasswordModifyRequest pwdModifyRequest = container.getPwdModifyRequest();
    assertNull( pwdModifyRequest.getUserIdentity() );
    assertNull( pwdModifyRequest.getOldPassword() );
    assertNull( pwdModifyRequest.getNewPassword() );

    // Check the length
    assertEquals( 0x02, ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:51,代码来源:PasswordModifyRequestTest.java

示例12: testDecodeSyncRequestValueControlRefreshAndPersistSuccess

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a SyncRequestValue control with a refreshAndPersist mode
 */
@Test
public void testDecodeSyncRequestValueControlRefreshAndPersistSuccess() throws Exception
{
    ByteBuffer bb = ByteBuffer.allocate( 0x0D );
    bb.put( new byte[]
        {
            0x30, 0x0B, // syncRequestValue ::= SEQUENCE {
            0x0A,
            0x01,
            0x03, //     mode ENUMERATED {
                  //         refreshAndPersist (3)
                  //     }
            0x04,
            0x03,
            'a',
            'b',
            'c', //     cookie syncCookie OPTIONAL,
            0x01,
            0x01,
            0x00 //     reloadHint BOOLEAN DEFAULT FALSE
    } );
    bb.flip();

    SyncRequestValue decorator = new SyncRequestValueDecorator( codec );

    SyncRequestValue syncRequestValue = ( SyncRequestValue ) ( ( SyncRequestValueDecorator ) decorator ).decode( bb
        .array() );

    assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode() );
    assertEquals( "abc", Strings.utf8ToString( syncRequestValue.getCookie() ) );
    assertEquals( false, syncRequestValue.isReloadHint() );

    // Check the encoding
    try
    {
        ByteBuffer buffer = ByteBuffer.allocate( 0x0A );
        buffer.put( new byte[]
            {
                0x30, 0x08, // syncRequestValue ::= SEQUENCE {
                0x0A,
                0x01,
                0x03, //     mode ENUMERATED {
                      //         refreshAndPersist (3)
                      //     }
                0x04,
                0x03,
                'a',
                'b',
                'c' //     cookie syncCookie OPTIONAL,
        } );
        buffer.flip();

        bb = ( ( SyncRequestValueDecorator ) syncRequestValue ).encode( ByteBuffer
            .allocate( ( ( SyncRequestValueDecorator ) syncRequestValue ).computeLength() ) );
        String decoded = Strings.dumpBytes( bb.array() );
        String expected = Strings.dumpBytes( buffer.array() );
        assertEquals( expected, decoded );
    }
    catch ( EncoderException ee )
    {
        fail();
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:67,代码来源:SyncRequestValueControlTest.java

示例13: testDecodePasswordModifyRequestOldPasswordValueNewPasswordValue

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a PasswordModifyRequest with an oldPassword and an
 * newPassword
 */
@Test
public void testDecodePasswordModifyRequestOldPasswordValueNewPasswordValue()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x0E );
    bb.put( new byte[]
        { 0x30, 0x0C, // PasswordModifyRequest ::= SEQUENCE {
            ( byte ) 0x81,
            0x04, // oldPassword    [1]  OCTET STRING OPTIONAL
            'a',
            'b',
            'c',
            'd',
            ( byte ) 0x82, // newPassword    [2]  OCTET STRING OPTIONAL
            0x04,
            'e',
            'f',
            'g',
            'h'
    } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    PasswordModifyRequestContainer container = new PasswordModifyRequestContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    PasswordModifyRequest pwdModifyRequest = container.getPwdModifyRequest();
    assertNull( pwdModifyRequest.getUserIdentity() );
    assertNotNull( pwdModifyRequest.getOldPassword() );
    assertEquals( "abcd", Strings.utf8ToString( pwdModifyRequest.getOldPassword() ) );
    assertNotNull( pwdModifyRequest.getNewPassword() );
    assertEquals( "efgh", Strings.utf8ToString( pwdModifyRequest.getNewPassword() ) );

    // Check the length
    assertEquals( 0x0E, ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = ( ( PasswordModifyRequestDecorator ) pwdModifyRequest ).encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:66,代码来源:PasswordModifyRequestTest.java

示例14: testDecodeGracefulShutdownDelay

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a GracefulShutdown with a delay only
 */
@Test
public void testDecodeGracefulShutdownDelay()
{
    Asn1Decoder decoder = new Asn1Decoder();
    ByteBuffer bb = ByteBuffer.allocate( 0x05 );
    bb.put( new byte[]
        { 0x30, 0x03, // GracefulShutdown ::= SEQUENCE {
            ( byte ) 0x80,
            0x01,
            0x01 // delay INTEGER (0..86400) DEFAULT
                 // 0
    } );

    String decodedPdu = Strings.dumpBytes( bb.array() );
    bb.flip();

    GracefulShutdownContainer container = new GracefulShutdownContainer();

    try
    {
        decoder.decode( bb, container );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    GracefulShutdownRequestDecorator gracefulShutdownRequest = container.getGracefulShutdownRequest();
    assertEquals( 0, gracefulShutdownRequest.getTimeOffline() );
    assertEquals( 1, gracefulShutdownRequest.getDelay() );

    // Check the length
    assertEquals( 0x05, gracefulShutdownRequest.computeLengthInternal() );

    // Check the encoding
    try
    {
        ByteBuffer bb1 = gracefulShutdownRequest.encodeInternal();

        String encodedPdu = Strings.dumpBytes( bb1.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:54,代码来源:GracefulShutdownTest.java

示例15: testDecodeIntermediateResponseName

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Test the decoding of a name only IntermediateResponse
 */
@Test
public void testDecodeIntermediateResponseName()
{
    Asn1Decoder ldapDecoder = new Asn1Decoder();

    ByteBuffer stream = ByteBuffer.allocate( 0x16 );

    stream.put( new byte[]
        { 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
            0x02,
            0x01,
            0x01, // messageID MessageID
            // CHOICE { ..., intermediateResponse IntermediateResponse, ...
            0x79,
            0x0F, // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
            // responseName [0] LDAPOID,
            ( byte ) 0x80,
            0x0D,
            '1',
            '.',
            '3',
            '.',
            '6',
            '.',
            '1',
            '.',
            '5',
            '.',
            '5',
            '.',
            '2', } );

    String decodedPdu = Strings.dumpBytes( stream.array() );
    stream.flip();

    // Allocate a LdapMessage Container
    LdapMessageContainer<IntermediateResponseDecorator> ldapMessageContainer =
        new LdapMessageContainer<IntermediateResponseDecorator>( codec );

    // Decode the IntermediateResponse PDU
    try
    {
        ldapDecoder.decode( stream, ldapMessageContainer );
    }
    catch ( DecoderException de )
    {
        de.printStackTrace();
        fail( de.getMessage() );
    }

    // Check the decoded IntermediateResponse PDU
    IntermediateResponse intermediateResponse = ldapMessageContainer.getMessage();

    assertEquals( 1, intermediateResponse.getMessageId() );
    assertEquals( "1.3.6.1.5.5.2", intermediateResponse.getResponseName() );

    // Check the encoding
    try
    {
        ByteBuffer bb = encoder.encodeMessage( intermediateResponse );

        // Check the length
        assertEquals( 0x16, bb.limit() );

        String encodedPdu = Strings.dumpBytes( bb.array() );

        assertEquals( encodedPdu, decodedPdu );
    }
    catch ( EncoderException ee )
    {
        ee.printStackTrace();
        fail( ee.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:78,代码来源:IntermediateResponseTest.java


注:本文中的org.apache.directory.api.util.Strings.dumpBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。