directory-commits mailing list archives

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

Modified:
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindRequestImpl.java
   incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
Log:
Commit changes ...

 o formatting: removed m_ and space before ;
 o added empty string as the default name to prevent NPEs
 o added impl equality test
 


Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindRequestImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindRequestImpl.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindRequestImpl.java
Mon Aug 23 11:38:38 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
 
 import org.apache.commons.lang.ArrayUtils;
 
@@ -30,14 +30,17 @@
 public class BindRequestImpl
     extends AbstractRequest implements BindRequest
 {
-    /** Distinguished name identifying the name of the authenticating subject */
-    private String m_name ;
+    /**
+     * Distinguished name identifying the name of the authenticating subject -
+     * defaults to the empty string
+     */
+    private String name = "";
     /** The passwords, keys or tickets used to verify user identity */
-    private byte [] m_credentials ;
+    private byte [] credentials;
     /** Simple vs. SASL authentication mode flag */
-    private boolean m_isSimple = true ;
+    private boolean isSimple = true;
     /** Bind behavoir exhibity by protocol version */
-    private boolean m_isVersion3 = true ;
+    private boolean isVersion3 = true;
 
 
     // ------------------------------------------------------------------------
@@ -52,7 +55,7 @@
      */
     public BindRequestImpl( final int id )
     {
-        super( id, TYPE, true ) ;
+        super( id, TYPE, true );
     }
 
 
@@ -69,7 +72,7 @@
      */
     public boolean isSimple()
     {
-        return m_isSimple ;
+        return isSimple;
     }
 
 
@@ -81,7 +84,7 @@
      */
     public boolean getSimple()
     {
-        return m_isSimple ;
+        return isSimple;
     }
 
 
@@ -93,8 +96,8 @@
      */
     public void setSimple( boolean isSimple )
     {
-        lockCheck( "Attempt to alter auth. mode of locked BindRequest!" ) ;
-        m_isSimple = isSimple ;
+        lockCheck( "Attempt to alter auth. mode of locked BindRequest!" );
+        this.isSimple = isSimple;
     }
 
 
@@ -106,7 +109,7 @@
      */
     public byte [] getCredentials()
     {
-        return m_credentials ;
+        return credentials;
     }
 
 
@@ -119,8 +122,8 @@
      */
     public void setCredentials( byte [] credentials )
     {
-        lockCheck( "Attempt to alter auth. cred. of locked BindRequest!" ) ;
-        m_credentials = credentials ;
+        lockCheck( "Attempt to alter auth. cred. of locked BindRequest!" );
+        this.credentials = credentials;
     }
 
 
@@ -135,7 +138,7 @@
      */
     public String getName()
     {
-        return m_name ;
+        return name;
     }
 
 
@@ -151,8 +154,8 @@
      */
     public void setName( String name )
     {
-        lockCheck( "Attempt to alter auth. DN of locked BindRequest!" ) ;
-        m_name = name ;
+        lockCheck( "Attempt to alter auth. DN of locked BindRequest!" );
+        this.name = name;
     }
 
 
@@ -169,7 +172,7 @@
      */
     public boolean isVersion3()
     {
-        return m_isVersion3 ;
+        return isVersion3;
     }
 
 
@@ -186,7 +189,7 @@
      */
     public boolean getVersion3()
     {
-        return m_isVersion3 ;
+        return isVersion3;
     }
 
 
@@ -204,8 +207,8 @@
      */
     public void setVersion3( boolean isVersion3 )
     {
-        lockCheck( "Attempt to alter proto. version of locked BindRequest!" ) ;
-        m_isVersion3 = isVersion3 ;
+        lockCheck( "Attempt to alter proto. version of locked BindRequest!" );
+        this.isVersion3 = isVersion3;
     }
 
 
@@ -222,7 +225,7 @@
      */
     public MessageTypeEnum getResponseType()
     {
-        return RESP_TYPE ;
+        return RESP_TYPE;
     }
 
 

Modified: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
(original)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/BindRequestImplTest.java
Mon Aug 23 11:38:38 2004
@@ -19,6 +19,11 @@
 
 import junit.framework.TestCase;
 
+import java.util.Collection;
+
+import org.apache.ldap.common.Lockable;
+import org.apache.ldap.common.LockException;
+
 
 /**
  * TestCases for the methods of the BindRequestImpl class.
@@ -161,5 +166,131 @@
         req1.setVersion3( true );
 
         assertFalse( req0.equals( req1 ) );
+    }
+
+
+    /**
+     * Tests for equality even when another BindRequest implementation is used.
+     */
+    public void testEqualsDiffImpl()
+    {
+        BindRequest req0 = new BindRequest()
+        {
+            public boolean isSimple()
+            {
+                return true;
+            }
+
+            public boolean getSimple()
+            {
+                return true;
+            }
+
+            public void setSimple( boolean a_isSimple )
+            {
+            }
+
+            public byte[] getCredentials()
+            {
+                return null;
+            }
+
+            public void setCredentials( byte[] a_credentials )
+            {
+            }
+
+            public String getName()
+            {
+                return "";
+            }
+
+            public void setName( String a_name )
+            {
+            }
+
+            public boolean isVersion3()
+            {
+                return true;
+            }
+
+            public boolean getVersion3()
+            {
+                return true;
+            }
+
+            public void setVersion3( boolean a_isVersion3 )
+            {
+            }
+
+            public MessageTypeEnum getResponseType()
+            {
+                return null;
+            }
+
+            public boolean hasResponse()
+            {
+                return true;
+            }
+
+            public MessageTypeEnum getType()
+            {
+                return MessageTypeEnum.BINDREQUEST;
+            }
+
+            public Collection getControls()
+            {
+                return null;
+            }
+
+            public void add( Control a_control ) throws MessageException
+            {
+            }
+
+            public void remove( Control a_control ) throws MessageException
+            {
+            }
+
+            public int getMessageId()
+            {
+                return 5;
+            }
+
+            public Object get( Object a_key )
+            {
+                return null;
+            }
+
+            public Object put( Object a_key, Object a_value )
+            {
+                return null;
+            }
+
+            public Lockable getParent()
+            {
+                return null;
+            }
+
+            public boolean isLocked()
+            {
+                return false;
+            }
+
+            public boolean getLocked()
+            {
+                return false;
+            }
+
+            public void setLocked( boolean a_isLocked ) throws LockException
+            {
+            }
+
+            public boolean isUnlockable()
+            {
+                return false;
+            }
+        };
+
+        BindRequestImpl req1 = new BindRequestImpl( 5 );
+        assertTrue( req1.equals( req0 ) );
     }
 }

Mime
View raw message