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 2005/08/09 01:57:44 UTC
svn commit: r230930 - in /directory/shared/ldap/trunk:
apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/
apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/
common/src/java/org/apache/ldap/common/ldif/ com...
Author: akarasulu
Date: Mon Aug 8 16:57:35 2005
New Revision: 230930
URL: http://svn.apache.org/viewcvs?rev=230930&view=rev
Log:
changes ...
o updated attributes implementation to now properly execute put(String, Object)
o after the change we had to alter a few tests that incorrectly depended on
this functionality
notes ...
o these changes are for http://issues.apache.org/jira/browse/DIREVE-177
o this change will have wide reaching impacts which need to be tested
o none of the apacheds test cases bombed but they are anemic at best so
I don't expect them to catch everything that could break
Modified:
directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java
directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/message/LockableAttributesImplTest.java
Modified: directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java?rev=230930&r1=230929&r2=230930&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java (original)
+++ directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java Mon Aug 8 16:57:35 2005
@@ -23,6 +23,7 @@
import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
import org.apache.ldap.common.message.AddRequestImpl;
import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.message.LockableAttributeImpl;
import javax.naming.NamingException;
@@ -38,8 +39,10 @@
AddRequestImpl request = new AddRequestImpl( 33 );
request.setName( "dc=apache,dc=org" );
LockableAttributesImpl attrs = new LockableAttributesImpl( request );
- attrs.put( "objectClass", "top" );
- attrs.put( "objectClass", "dcObject" );
+ LockableAttributeImpl objectClass = new LockableAttributeImpl( "objectClass" );
+ objectClass.add( "top" );
+ objectClass.add( "dcObject" );
+ attrs.put( objectClass );
attrs.put( "dc", "example.com" );
request.setEntry( attrs );
Modified: directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java?rev=230930&r1=230929&r2=230930&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java (original)
+++ directory/shared/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java Mon Aug 8 16:57:35 2005
@@ -23,6 +23,7 @@
import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
import org.apache.ldap.common.message.LockableAttributesImpl;
import org.apache.ldap.common.message.SearchResponseEntryImpl;
+import org.apache.ldap.common.message.LockableAttributeImpl;
/**
@@ -37,8 +38,10 @@
SearchResponseEntryImpl response = new SearchResponseEntryImpl( 45 );
response.setObjectName( "dc=example,dc=com" );
LockableAttributesImpl attrs = new LockableAttributesImpl( response );
- attrs.put( "objectClass", "top" );
- attrs.put( "objectClass", "dcObject" );
+ LockableAttributeImpl objectClass = new LockableAttributeImpl( "objectClass" );
+ objectClass.add( "top" );
+ objectClass.add( "dcObject" );
+ attrs.put( objectClass );
attrs.put( "dc", "example.com" );
response.setAttributes( attrs );
Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java?rev=230930&r1=230929&r2=230930&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java Mon Aug 8 16:57:35 2005
@@ -25,6 +25,7 @@
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
+import javax.naming.directory.Attribute;
import org.apache.ldap.common.util.Base64;
import org.apache.ldap.common.message.ResultCodeEnum;
@@ -68,7 +69,7 @@
* @throws NamingException if there any failures while parsing the LDIF and
* populating the attirubutes
*/
- public void parse( Attributes attributes, String ldif ) throws NamingException
+ public synchronized void parse( Attributes attributes, String ldif ) throws NamingException
{
boolean isBase64Encoded = false;
int lineCount = 0;
@@ -129,12 +130,30 @@
*/
if ( isBase64Encoded && ( attrValue != null ) )
{
- attributes.put( attrName, base64decode( attrValue ) );
+ byte[] value = base64decode( attrValue );
+
+ if ( attributes.get( attrName ) == null )
+ {
+ attributes.put( attrName, value );
+ }
+ else
+ {
+ Attribute attribute = attributes.get( attrName );
+ attribute.add( value );
+ }
isBase64Encoded = false;
}
else
{
- attributes.put( attrName, attrValue );
+ if ( attributes.get( attrName ) == null )
+ {
+ attributes.put( attrName, attrValue );
+ }
+ else
+ {
+ Attribute attribute = attributes.get( attrName );
+ attribute.add( attrValue );
+ }
}
}
}
Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java?rev=230930&r1=230929&r2=230930&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java Mon Aug 8 16:57:35 2005
@@ -204,17 +204,10 @@
public Attribute put( String attrId, Object val )
{
super.lockCheck( "Attempt to add value to locked Attributes" );
- Attribute l_attr = get( attrId );
-
- if ( l_attr == null )
- {
- l_attr = new LockableAttributeImpl( this, attrId );
- setUserProvidedId( attrId );
- }
-
- l_attr.add( val );
- map.put( attrId, l_attr );
- return l_attr;
+ Attribute attr = new LockableAttributeImpl( this, attrId );
+ attr.add( val );
+ map.put( attrId, attr );
+ return attr;
}
Modified: directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/message/LockableAttributesImplTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/message/LockableAttributesImplTest.java?rev=230930&r1=230929&r2=230930&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/message/LockableAttributesImplTest.java (original)
+++ directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/message/LockableAttributesImplTest.java Mon Aug 8 16:57:35 2005
@@ -149,4 +149,22 @@
assertTrue( "different implementations of the same " +
"attributes should be equal", attrs1.equals( attrs0 ) );
}
+
+
+ public void testCompareToBasicAttributes()
+ {
+ LockableAttributesImpl attrs0 = new LockableAttributesImpl();
+ attrs0.put( "attr0", "value0" );
+ attrs0.put( "attr1", "value1" );
+ attrs0.put( "attr2", "value2" );
+ attrs0.put( "attr2", "value3" );
+
+ BasicAttributes attrs1 = new BasicAttributes( true );
+ attrs1.put( "attr0", "value0" );
+ attrs1.put( "attr1", "value1" );
+ attrs1.put( "attr2", "value2" );
+ attrs1.put( "attr2", "value3" );
+
+ assertTrue( "both implementations should produce the same outcome", attrs0.equals( attrs1 ) );
+ }
}