You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/06/07 00:31:15 UTC
svn commit: r185074 -
/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java
Author: elecharny
Date: Mon Jun 6 15:31:15 2005
New Revision: 185074
URL: http://svn.apache.org/viewcvs?rev=185074&view=rev
Log:
Created the SearchResultDone test case
Added:
directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java
Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java?rev=185074&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchResultDoneTest.java Mon Jun 6 15:31:15 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 implied.
+ * 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.SearchResultDonePOJO;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Test the SearchResultDone codec
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultDoneTest extends TestCase {
+ /** Logger */
+ protected static Logger log = Logger.getLogger( SearchResultDoneTest.class );
+
+ static
+ {
+ PropertyConfigurator.configure( "conf/log4j.conf" );
+ }
+
+ /**
+ * Test the decoding of a SearchResultDone
+ */
+ public void testDecodeSearchResultDoneSuccess()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x2D );
+
+ stream.put(
+ new byte[]
+ {
+ 0x30, 0x2B, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x65, 0x26, // CHOICE { ..., delResponse DelResponse, ...
+ // SearchResultDone ::= [APPLICATION 5] LDAPResult
+ 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
+ // resultCode ENUMERATED {
+ // success (0), ...
+ // },
+ 0x04, 0x1F, // matchedDN LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
+ 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x04, 0x00 // errorMessage LDAPString,
+ // referral [3] Referral OPTIONAL }
+ // }
+ } );
+
+ stream.flip();
+
+ // Allocate a BindRequest Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ de.printStackTrace();
+ Assert.fail( de.getMessage() );
+ }
+
+ LdapMessagePOJO message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+ SearchResultDonePOJO searchResultDone = ( SearchResultDonePOJO ) ( message.getProtocolOp() );
+
+ Assert.assertEquals( 1, message.getMessageId() );
+ Assert.assertEquals( 0, searchResultDone.getLdapResult().getResultCode() );
+ Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", searchResultDone.getLdapResult().getMatchedDN() );
+ Assert.assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() );
+ }
+}