Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 3217 invoked from network); 6 Jun 2005 22:32:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jun 2005 22:32:00 -0000 Received: (qmail 28106 invoked by uid 500); 6 Jun 2005 22:32:00 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 28057 invoked by uid 500); 6 Jun 2005 22:31:59 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 28044 invoked by uid 99); 6 Jun 2005 22:31:59 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 06 Jun 2005 15:31:54 -0700 Received: (qmail 3133 invoked by uid 65534); 6 Jun 2005 22:31:38 -0000 Message-ID: <20050606223138.3132.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r185075 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/ModifyDNResponseTest.java Date: Mon, 06 Jun 2005 22:31:38 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Mon Jun 6 15:31:37 2005 New Revision: 185075 URL: http://svn.apache.org/viewcvs?rev=3D185075&view=3Drev Log: Created the ModifyDNResponse test case Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/co= dec/ModifyDNResponseTest.java Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap= /codec/ModifyDNResponseTest.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/test/org/apache/asn1/ldap/codec/ModifyDNResponseTest.java?rev=3D185075&v= iew=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/co= dec/ModifyDNResponseTest.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/co= dec/ModifyDNResponseTest.java Mon Jun 6 15:31:37 2005 @@ -0,0 +1,97 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.asn1.ldap.codec; + +import java.nio.ByteBuffer; + +import org.apache.asn1.DecoderException; +import org.apache.asn1.ber.Asn1Decoder; +import org.apache.asn1.ber.containers.IAsn1Container; +import org.apache.asn1.ldap.pojo.LdapMessagePOJO; +import org.apache.asn1.ldap.pojo.ModifyDNResponsePOJO; +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * Test the ModifyDNResponse codec + *=20 + * @author Apache Directory Pr= oject + */ +public class ModifyDNResponseTest extends TestCase { + /** Logger */ + protected static Logger log =3D Logger.getLogger( ModifyDNResponseTest= .class ); + + static + { + PropertyConfigurator.configure( "conf/log4j.conf" ); + } + + /** + * Test the decoding of a ModifyDNResponse + */ + public void testDecodeModifyResponseSuccess() + { + Asn1Decoder ldapDecoder =3D new LdapDecoder(); + + ByteBuffer stream =3D ByteBuffer.allocate( 0x2D ); + =20 + stream.put( + new byte[] + { + 0x30, 0x2B, // LDAPMessage ::=3DSEQUENCE { + 0x02, 0x01, 0x01, // messageID MessageID + 0x6D, 0x26, // CHOICE { ..., modifyDNResponse ModifyDNRespons= e, ... + // ModifyDNResponse ::=3D [APPLICATION 13] LDAP= Result + 0x0A, 0x01, 0x00, // LDAPResult ::=3D SEQUENCE { + // resultCode ENUMERATED { + // success (0), ... + // }, + 0x04, 0x1F, // matchedDN LDAPDN, + 'u', 'i', 'd', '=3D', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ','= , 'd', 'c', '=3D', + 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=3D', '= c', 'o', 'm', + 0x04, 0x00 // errorMessage LDAPString, + // referral [3] Referral OPTIONAL } + // } + } ); + + stream.flip(); + + // Allocate a BindRequest Container + IAsn1Container ldapMessageContainer =3D new LdapMessageContainer(); + + try + { + ldapDecoder.decode( stream, ldapMessageContainer ); + } + catch ( DecoderException de ) + { + de.printStackTrace(); + Assert.fail( de.getMessage() ); + } + =09 + LdapMessagePOJO message =3D ( ( LdapMessageContainer ) ldapMessage= Container ).getLdapMessage(); + ModifyDNResponsePOJO modifyDNResponse =3D ( ModifyDNResponseP= OJO ) ( message.getProtocolOp() ); + + Assert.assertEquals( 1, message.getMessageId() ); + Assert.assertEquals( 0, modifyDNResponse.getLdapResult().getResult= Code() ); + Assert.assertEquals( "uid=3Dakarasulu,dc=3Dexample,dc=3Dcom", modi= fyDNResponse.getLdapResult().getMatchedDN() ); + Assert.assertEquals( "", modifyDNResponse.getLdapResult().getError= Message() ); + } +}