You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/08/23 23:39:08 UTC
svn commit: rev 36788 - in incubator/directory/ldap/trunk/common/src: java/org/apache/ldap/common/message test/org/apache/ldap/common/message
Author: akarasulu
Date: Mon Aug 23 14:39:08 2004
New Revision: 36788
Added:
incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/AbstractMessageTest.java
Modified:
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbandonRequestImpl.java
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbstractMessage.java
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/BindResponseImpl.java
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/Control.java
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseDoneImpl.java
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequest.java
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequestImpl.java
Log:
Commit changes ...
o added equals() to AbstractMessage to handle all the baseline checks for the
messageId, type and controls composition to the PDU: none of the Lockable,
nor the get()/put() based parameters are considered when evaluating equality
o with new base equals several equals() impls had the messageId test removed
and a new check for equality made using the super.equals() method
o some formatting: removed a_, m_ and space before ;
o cleaned up @author tags and licenses in some files
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbandonRequestImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbandonRequestImpl.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbandonRequestImpl.java Mon Aug 23 14:39:08 2004
@@ -14,7 +14,7 @@
* limitations under the License.
*
*/
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
/**
@@ -28,7 +28,7 @@
extends AbstractRequest implements AbandonRequest
{
/** Sequence identifier of the outstanding request message to abandon */
- private int m_abandonId ;
+ private int abandonId ;
/**
@@ -49,7 +49,7 @@
*/
public int getAbandoned()
{
- return m_abandonId ;
+ return abandonId ;
}
@@ -61,6 +61,36 @@
public void setAbandoned( int abandonId )
{
lockCheck( "Attempt to alter locked AbandonRequest!" ) ;
- m_abandonId = abandonId ;
+ this.abandonId = abandonId ;
+ }
+
+
+ /**
+ * Checks for equality first by asking the super method which should compare
+ * all but the Abandoned request's Id. It then compares this to determine
+ * equality.
+ *
+ * @param obj the object to test for equality to this AbandonRequest
+ * @return true if the obj equals this request false otherwise
+ */
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( ! super.equals( obj ) )
+ {
+ return false;
+ }
+
+ AbandonRequest req = ( AbandonRequest ) obj;
+ if ( req.getAbandoned() != abandonId )
+ {
+ return false;
+ }
+
+ return true;
}
}
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbstractMessage.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbstractMessage.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/AbstractMessage.java Mon Aug 23 14:39:08 2004
@@ -14,15 +14,12 @@
* limitations under the License.
*
*/
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
-import java.util.Map ;
-import java.util.HashMap ;
-import java.util.Collection ;
-import java.util.Collections ;
+import java.util.*;
-import org.apache.ldap.common.AbstractLockable ;
+import org.apache.ldap.common.AbstractLockable;
/**
@@ -32,36 +29,34 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class AbstractMessage
- extends AbstractLockable
- implements Message
+public class AbstractMessage extends AbstractLockable implements Message
{
/** Map of message controls using OID Strings for keys and Control values */
- private final Map m_controls ;
+ private final Map controls;
/** The session unique message sequence identifier */
- private final int m_id ;
+ private final int id;
/** The message type enumeration */
- private final MessageTypeEnum m_type ;
+ private final MessageTypeEnum type;
/** Transient Message Parameter Hash */
- private final Map m_parameters ;
+ private final Map parameters;
/**
* Completes the instantiation of a Message.
*
- * @param a_id the seq id of the message
- * @param a_type the type of the message
+ * @param id the seq id of the message
+ * @param type the type of the message
*/
- protected AbstractMessage( final int a_id,
- final MessageTypeEnum a_type )
+ protected AbstractMessage( final int id,
+ final MessageTypeEnum type )
{
- super( true ) ;
+ super( true );
- m_id = a_id ;
- m_type = a_type ;
- m_controls = new HashMap() ;
- m_parameters = new HashMap() ;
+ this.id = id;
+ this.type = type;
+ controls = new HashMap();
+ parameters = new HashMap();
}
@@ -75,7 +70,7 @@
*/
public int getMessageId()
{
- return m_id ;
+ return id;
}
@@ -87,37 +82,37 @@
*/
public Collection getControls()
{
- return Collections.unmodifiableCollection( m_controls.values() ) ;
+ return Collections.unmodifiableCollection( controls.values() );
}
/**
* Adds a control to this Message.
*
- * @param a_control the control to add.
+ * @param control the control to add.
* @throws MessageException if controls cannot be added to this Message or
* the control is not known etc.
*/
- public void add( Control a_control )
+ public void add( Control control )
throws MessageException
{
- lockCheck( "Attempt to add control to locked message envelope!" ) ;
- m_controls.put( a_control.getType(), a_control ) ;
+ lockCheck( "Attempt to add control to locked message envelope!" );
+ controls.put( control.getType(), control );
}
/**
* Deletes a control removing it from this Message.
*
- * @param a_control the control to remove.
+ * @param control the control to remove.
* @throws MessageException if controls cannot be added to this Message or
* the control is not known etc.
*/
- public void remove( Control a_control )
+ public void remove( Control control )
throws MessageException
{
- lockCheck( "Attempt to remove control from locked message envelope!" ) ;
- m_controls.remove( a_control.getType() ) ;
+ lockCheck( "Attempt to remove control from locked message envelope!" );
+ controls.remove( control.getType() );
}
@@ -130,7 +125,7 @@
*/
public MessageTypeEnum getType()
{
- return m_type ;
+ return type;
}
@@ -145,12 +140,12 @@
* without firing LockExceptions even when this Lockable is in the locked
* state.
*
- * @param a_key the key used to access a message parameter.
+ * @param key the key used to access a message parameter.
* @return the transient message parameter value.
*/
- public Object get( Object a_key )
+ public Object get( Object key )
{
- return m_parameters.get( a_key ) ;
+ return parameters.get( key );
}
@@ -161,12 +156,63 @@
* without firing LockExceptions even when this Lockable is in the locked
* state.
*
- * @param a_key the parameter key
- * @param a_value the parameter value
+ * @param key the parameter key
+ * @param value the parameter value
* @return the old value or null
*/
- public Object put( Object a_key, Object a_value )
+ public Object put( Object key, Object value )
{
- return m_parameters.put( a_key, a_value ) ;
+ return parameters.put( key, value );
+ }
+
+
+ /**
+ * Checks to see if two messages are equivalent. Messages equivalence does
+ * not factor in parameters accessible through the get() and put()
+ * operations, nor do they factor in the Lockable properties of the Message.
+ * Only the type, controls, and the messageId are evaluated for equality.
+ *
+ * @param obj the object to compare this Message to for equality
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj == this )
+ {
+ return true;
+ }
+
+ if ( ! ( obj instanceof Message ) )
+ {
+ return false;
+ }
+
+ Message msg = ( Message ) obj;
+
+ if ( msg.getMessageId() != id )
+ {
+ return false;
+ }
+
+ if ( msg.getType() != type )
+ {
+ return false;
+ }
+
+ Collection controls = msg.getControls();
+ if ( controls.size() != this.controls.size() )
+ {
+ return false;
+ }
+
+ Iterator list = this.controls.values().iterator();
+ while ( list.hasNext() )
+ {
+ if ( ! controls.contains( list.next() ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
}
}
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 14:39:08 2004
@@ -236,17 +236,12 @@
return true;
}
- if ( ! ( obj instanceof BindRequest ) )
+ if ( ! super.equals( obj ) )
{
return false;
}
BindRequest req = ( BindRequest ) obj;
-
- if ( getMessageId() != req.getMessageId() )
- {
- return false;
- }
if ( req.isSimple() != isSimple() )
{
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/BindResponseImpl.java Mon Aug 23 14:39:08 2004
@@ -99,17 +99,12 @@
return true;
}
- if ( ! ( obj instanceof BindResponse ) )
+ if ( ! super.equals( obj ) )
{
return false;
}
BindResponse response = ( BindResponse ) obj;
-
- if ( getMessageId() != response.getMessageId() )
- {
- return false;
- }
if ( getLdapResult() != null && response.getLdapResult() == null )
{
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/Control.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/Control.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/Control.java Mon Aug 23 14:39:08 2004
@@ -1,233 +1,33 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * 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.
- *
- */
-
/*
- * $Id: Control.java,v 1.4 2003/07/31 21:44:48 akarasulu Exp $
+ * 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
*
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
+ * 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 org.apache.ldap.common.Lockable ;
+import org.apache.ldap.common.Lockable;
/**
* Protocol request and response altering control interface. Any number of
* controls may be associated with a protocol message.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.4 $
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
*/
-public interface Control
- extends Lockable
+public interface Control extends Lockable
{
/**
* Gets the OID of the Control to identify the control type.
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseDoneImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseDoneImpl.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/SearchResponseDoneImpl.java Mon Aug 23 14:39:08 2004
@@ -60,17 +60,12 @@
return true;
}
- if ( ! ( obj instanceof SearchResponseDone ) )
+ if ( ! super.equals( obj ) )
{
return false;
}
LdapResult result = ( ( SearchResponseDone ) obj ).getLdapResult();
-
- if ( getMessageId() != ( ( SearchResponseDone ) obj).getMessageId() )
- {
- return false;
- }
if ( ! getLdapResult().equals( result ) )
{
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequest.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequest.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequest.java Mon Aug 23 14:39:08 2004
@@ -1,193 +1,5 @@
/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
+ * 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.
@@ -202,29 +14,17 @@
* limitations under the License.
*
*/
-
-/*
- * $Id: UnbindRequest.java,v 1.1 2003/05/09 18:13:34 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-
package org.apache.ldap.common.message ;
/**
* Unbind protocol request message used to end a client session.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.1 $
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ * Project</a> $Rev$
*/
-public interface UnbindRequest
- extends Request
+public interface UnbindRequest extends Request
{
/** Unbind request protocol message type */
- MessageTypeEnum TYPE = MessageTypeEnum.UNBINDREQUEST ;
+ MessageTypeEnum TYPE = MessageTypeEnum.UNBINDREQUEST;
}
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequestImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequestImpl.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/UnbindRequestImpl.java Mon Aug 23 14:39:08 2004
@@ -14,33 +14,26 @@
* limitations under the License.
*
*/
-package org.apache.ldap.common.message ;
+package org.apache.ldap.common.message;
/**
- * Lockable UnbindRequet implementation.
+ * Lockable UnbindRequest implementation.
*
* @author <a href="mailto:directory-dev@incubator.apache.org">
* Apache Directory Project</a>
- * @version $Rev$
*/
-public class UnbindRequestImpl
- extends AbstractRequest implements UnbindRequest
+public class UnbindRequestImpl extends AbstractRequest implements UnbindRequest
{
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
-
/**
* Creates an UnbindRequest which takes no parameter other than those in
* the outer envelope to disconnect and end a client session on the server
* without producing any response.
*
- * @param a_id the sequential message identifier.
+ * @param id the sequential message identifier.
*/
- public UnbindRequestImpl( final int a_id )
+ public UnbindRequestImpl( final int id )
{
- super( a_id, TYPE, false ) ;
+ super( id, TYPE, false );
}
}
Added: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/AbstractMessageTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/AbstractMessageTest.java Mon Aug 23 14:39:08 2004
@@ -0,0 +1,152 @@
+/*
+ * 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;
+import org.apache.ldap.common.Lockable;
+import org.apache.ldap.common.LockException;
+
+
+/**
+ * Test cases for the AbstractMessage class' methods.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ * Project</a> $Rev$
+ */
+public class AbstractMessageTest extends TestCase
+{
+ /**
+ * Tests to see the same object returns true.
+ */
+ public void testEqualsSameObj()
+ {
+ AbstractMessage msg;
+ msg = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ assertTrue( msg.equals( msg ) );
+ }
+
+
+ /**
+ * Tests to see the same exact copy returns true.
+ */
+ public void testEqualsExactCopy()
+ {
+ AbstractMessage msg0;
+ AbstractMessage msg1;
+ msg0 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ msg1 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ assertTrue( msg0.equals( msg1 ) );
+ assertTrue( msg1.equals( msg0 ) );
+ }
+
+
+ /**
+ * Tests to make sure changes in the id result in inequality.
+ */
+ public void testNotEqualsDiffId()
+ {
+ AbstractMessage msg0;
+ AbstractMessage msg1;
+ msg0 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ msg1 = new AbstractMessage( 6, MessageTypeEnum.BINDREQUEST ) {};
+ assertFalse( msg0.equals( msg1 ) );
+ assertFalse( msg1.equals( msg0 ) );
+ }
+
+
+ /**
+ * Tests to make sure changes in the type result in inequality.
+ */
+ public void testNotEqualsDiffType()
+ {
+ AbstractMessage msg0;
+ AbstractMessage msg1;
+ msg0 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ msg1 = new AbstractMessage( 5, MessageTypeEnum.UNBINDREQUEST ) {};
+ assertFalse( msg0.equals( msg1 ) );
+ assertFalse( msg1.equals( msg0 ) );
+ }
+
+
+ /**
+ * Tests to make sure changes in the controls result in inequality.
+ */
+ public void testNotEqualsDiffControls()
+ {
+ AbstractMessage msg0;
+ AbstractMessage msg1;
+ msg0 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ msg0.add( new Control() {
+ 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;
+ }
+
+ public String getType()
+ {
+ return null;
+ }
+
+ public void setType( String a_oid )
+ {
+ }
+
+ public byte[] getValue()
+ {
+ return new byte[0];
+ }
+
+ public void setValue( byte[] a_value )
+ {
+ }
+
+ public boolean isCritical()
+ {
+ return false;
+ }
+
+ public void setCritical( boolean a_isCritical )
+ {
+ }
+ });
+ msg1 = new AbstractMessage( 5, MessageTypeEnum.BINDREQUEST ) {};
+ assertFalse( msg0.equals( msg1 ) );
+ assertFalse( msg1.equals( msg0 ) );
+ }
+
+
+}