directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36771 - incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message
Date Mon, 23 Aug 2004 18:26:58 GMT
Author: akarasulu
Date: Mon Aug 23 11:26:57 2004
New Revision: 36771

Added:
   incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
Log:
added test cases for the equals method of BindRequestImpl

Added: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
Mon Aug 23 11:26:57 2004
@@ -0,0 +1,165 @@
+/*
+ *   Copyright 2004 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.ldap.common.message;
+
+
+import junit.framework.TestCase;
+
+
+/**
+ * TestCases for the methods of the BindRequestImpl class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ *         Project</a> $Rev$
+ */
+public class BindRequestImplTest extends TestCase
+{
+    /**
+     * Tests the same object referrence for equality.
+     */
+    public void testEqualsSameObj()
+    {
+        BindRequestImpl req = new BindRequestImpl( 5 );
+        assertTrue( req.equals( req ) );
+    }
+
+
+    /**
+     * Tests for equality using exact copies.
+     */
+    public void testEqualsExactCopy()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 5 );
+        req0.setCredentials( "password".getBytes() );
+        req0.setName( "cn=admin,dc=example,dc=com" );
+        req0.setSimple( true );
+        req0.setVersion3( true );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertTrue( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Test for inequality when only the IDs are different.
+     */
+    public void testNotEqualDiffId()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 7 );
+        req0.setCredentials( "password".getBytes() );
+        req0.setName( "cn=admin,dc=example,dc=com" );
+        req0.setSimple( true );
+        req0.setVersion3( true );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertFalse( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Test for inequality when only the credentials are different.
+     */
+    public void testNotEqualDiffCreds()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 5 );
+        req0.setCredentials( "abcdefg".getBytes() );
+        req0.setName( "cn=admin,dc=example,dc=com" );
+        req0.setSimple( true );
+        req0.setVersion3( true );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertFalse( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Test for inequality when only the DN names are different.
+     */
+    public void testNotEqualDiffName()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 5 );
+        req0.setCredentials( "password".getBytes() );
+        req0.setName( "uid=akarasulu,dc=example,dc=com" );
+        req0.setSimple( true );
+        req0.setVersion3( true );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertFalse( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Test for inequality when only the auth mechanisms are different.
+     */
+    public void testNotEqualDiffSimple()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 5 );
+        req0.setCredentials( "password".getBytes() );
+        req0.setName( "cn=admin,dc=example,dc=com" );
+        req0.setSimple( false );
+        req0.setVersion3( true );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertFalse( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Test for inequality when only the bind LDAP versions are different.
+     */
+    public void testNotEqualDiffVersion()
+    {
+        BindRequestImpl req0 = new BindRequestImpl( 5 );
+        req0.setCredentials( "password".getBytes() );
+        req0.setName( "cn=admin,dc=example,dc=com" );
+        req0.setSimple( true );
+        req0.setVersion3( false );
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        req1.setCredentials( "password".getBytes() );
+        req1.setName( "cn=admin,dc=example,dc=com" );
+        req1.setSimple( true );
+        req1.setVersion3( true );
+
+        assertFalse( req0.equals( req1 ) );
+    }
+}

Mime
View raw message