directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r690676 - in /directory/studio/trunk/studio-dsml-parser/src: main/java/org/apache/directory/studio/dsmlv2/reponse/ main/java/org/apache/directory/studio/dsmlv2/request/ test/java/org/apache/directory/studio/dsmlv2/addRequest/ test/java/org/...
Date Sun, 31 Aug 2008 11:17:26 GMT
Author: seelmann
Date: Sun Aug 31 04:17:25 2008
New Revision: 690676

URL: http://svn.apache.org/viewvc?rev=690676&view=rev
Log:
Fixed compilation errors

Modified:
    directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
    directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
    directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/Dsmlv2Grammar.java
    directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/SearchRequestDsml.java
    directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/addRequest/AddRequestTest.java
    directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchRequest/SearchRequestTest.java
    directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java

Modified: directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
Sun Aug 31 04:17:25 2008
@@ -21,12 +21,10 @@
 package org.apache.directory.studio.dsmlv2.reponse;
 
 
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.dsmlv2.DsmlDecorator;
 import org.apache.directory.studio.dsmlv2.ParserUtils;
@@ -82,46 +80,31 @@
         SearchResultEntry searchResultEntry = ( SearchResultEntry ) instance;
         element.addAttribute( "dn", searchResultEntry.getObjectName().toString() );
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-        NamingEnumeration ne = attributes.getAll();
-
-        // Looping on Attributes Enumeration
-        while ( ne.hasMoreElements() )
+        Entry entry = searchResultEntry.getEntry();
+        for ( EntryAttribute attribute : entry )
         {
-            Attribute attribute = ( Attribute ) ne.nextElement();
 
             Element attributeElement = element.addElement( "attr" );
-            attributeElement.addAttribute( "name", attribute.getID() );
+            attributeElement.addAttribute( "name", attribute.getId() );
 
-            // Looping on Values Enumeration
-            try
+            for ( Value<?> value : attribute )
             {
-                NamingEnumeration ne2 = attribute.getAll();
-
-                while ( ne2.hasMoreElements() )
+                if ( ParserUtils.needsBase64Encoding( value.get() ) )
                 {
-                    Object value = ne2.nextElement();
-
-                    if ( ParserUtils.needsBase64Encoding( value ) )
-                    {
-                        Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI
);
-                        Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI
);
-                        attributeElement.getDocument().getRootElement().add( xsdNamespace
);
-                        attributeElement.getDocument().getRootElement().add( xsiNamespace
);
-
-                        Element valueElement = attributeElement.addElement( "value" ).addText(
-                            ParserUtils.base64Encode( value ) );
-                        valueElement.addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD
+ ":"
-                            + ParserUtils.BASE64BINARY );
-                    }
-                    else
-                    {
-                        attributeElement.addElement( "value" ).addText( value.toString()
);
-                    }
+                    Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI
);
+                    Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI
);
+                    attributeElement.getDocument().getRootElement().add( xsdNamespace );
+                    attributeElement.getDocument().getRootElement().add( xsiNamespace );
+
+                    Element valueElement = attributeElement.addElement( "value" ).addText(
+                        ParserUtils.base64Encode( value.get() ) );
+                    valueElement.addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD
+ ":"
+                        + ParserUtils.BASE64BINARY );
+                }
+                else
+                {
+                    attributeElement.addElement( "value" ).addText( value.get().toString()
);
                 }
-            }
-            catch ( NamingException e )
-            {
             }
         }
 
@@ -152,22 +135,24 @@
 
 
     /**
-     * Get the entry's attributes
+     * Get the entry.
      * 
-     * @return Returns the partialAttributeList.
+     * @return Returns the entry.
      */
-    public Attributes getPartialAttributeList()
+    public Entry getEntry()
     {
-        return ( ( SearchResultEntry ) instance ).getPartialAttributeList();
+        return ( ( SearchResultEntry ) instance ).getEntry();
     }
 
 
     /**
-     * Initialize the partial Attribute list.
+     * Initialize the entry.
+     * 
+     * @param entry the entry
      */
-    public void setPartialAttributeList( Attributes partialAttributeList )
+    public void setEntry( Entry entry )
     {
-        ( ( SearchResultEntry ) instance ).setPartialAttributeList( partialAttributeList
);
+        ( ( SearchResultEntry ) instance ).setEntry( entry );
     }
 
 

Modified: directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
Sun Aug 31 04:17:25 2008
@@ -20,12 +20,12 @@
 package org.apache.directory.studio.dsmlv2.request;
 
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
 import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.dsmlv2.ParserUtils;
 import org.dom4j.Element;
@@ -87,45 +87,32 @@
         }
 
         // Attributes
-        Attributes attributes = request.getAttributes();
-        if ( attributes != null )
+        Entry entry = request.getEntry();
+        if ( entry != null )
         {
-            NamingEnumeration ne = attributes.getAll();
-            while ( ne.hasMoreElements() )
+            for ( EntryAttribute attribute : entry )
             {
-                Attribute attribute = ( Attribute ) ne.nextElement();
                 Element attributeElement = element.addElement( "attr" );
-                attributeElement.addAttribute( "name", attribute.getID() );
-
-                // Looping on Values Enumeration
-                try
+                attributeElement.addAttribute( "name", attribute.getId() );
+                // Looping on Values
+                for ( Value<?> value : attribute )
                 {
-                    NamingEnumeration ne2 = attribute.getAll();
-
-                    while ( ne2.hasMoreElements() )
+                    if ( ParserUtils.needsBase64Encoding( value.get() ) )
                     {
-                        Object value = ne2.nextElement();
-
-                        if ( ParserUtils.needsBase64Encoding( value ) )
-                        {
-                            Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI
);
-                            Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI
);
-                            attributeElement.getDocument().getRootElement().add( xsdNamespace
);
-                            attributeElement.getDocument().getRootElement().add( xsiNamespace
);
-
-                            Element valueElement = attributeElement.addElement( "value" ).addText(
-                                ParserUtils.base64Encode( value ) );
-                            valueElement.addAttribute( new QName( "type", xsiNamespace ),
"xsd:"
-                                + ParserUtils.BASE64BINARY );
-                        }
-                        else
-                        {
-                            attributeElement.addElement( "value" ).addText( value.toString()
);
-                        }
+                        Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI
);
+                        Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI
);
+                        attributeElement.getDocument().getRootElement().add( xsdNamespace
);
+                        attributeElement.getDocument().getRootElement().add( xsiNamespace
);
+
+                        Element valueElement = attributeElement.addElement( "value" ).addText(
+                            ParserUtils.base64Encode( value.get() ) );
+                        valueElement
+                            .addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY
);
+                    }
+                    else
+                    {
+                        attributeElement.addElement( "value" ).addText( value.get().toString()
);
                     }
-                }
-                catch ( NamingException e )
-                {
                 }
             }
         }
@@ -135,22 +122,22 @@
 
 
     /**
-     * Initialize the ArrayList for attributes.
+     * Initialize the Entry.
      */
-    public void initAttributes()
+    public void initEntry()
     {
-        ( ( AddRequest ) instance ).initAttributes();
+        ( ( AddRequest ) instance ).initEntry();
     }
 
 
     /**
-     * Get the entry's attributes to be added
+     * Get the entry with its attributes.
      * 
-     * @return Returns the attributes.
+     * @return Returns the entry.
      */
-    public Attributes getAttributes()
+    public Entry getEntry()
     {
-        return ( ( AddRequest ) instance ).getAttributes();
+        return ( ( AddRequest ) instance ).getEntry();
     }
 
 
@@ -158,8 +145,9 @@
      * Create a new attributeValue
      * 
      * @param type The attribute's name (called 'type' in the grammar)
+     * @throws NamingException 
      */
-    public void addAttributeType( String type )
+    public void addAttributeType( String type ) throws NamingException
     {
         ( ( AddRequest ) instance ).addAttributeType( type );
     }
@@ -179,22 +167,22 @@
     /**
      * Get the added DN
      * 
-     * @return Returns the entry.
+     * @return Returns the entry DN.
      */
-    public LdapDN getEntry()
+    public LdapDN getEntryDn()
     {
-        return ( ( AddRequest ) instance ).getEntry();
+        return ( ( AddRequest ) instance ).getEntryDn();
     }
 
 
     /**
      * Set the added DN.
      * 
-     * @param entry The entry to set.
+     * @param entry The entry DN to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntryDn( LdapDN entryDn )
     {
-        ( ( AddRequest ) instance ).setEntry( entry );
+        ( ( AddRequest ) instance ).setEntryDn( entryDn );
     }
 
 

Modified: directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/Dsmlv2Grammar.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/Dsmlv2Grammar.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/Dsmlv2Grammar.java
Sun Aug 31 04:17:25 2008
@@ -26,6 +26,7 @@
 import java.util.HashMap;
 
 import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -1179,7 +1180,7 @@
         {
             AddRequest addRequest = new AddRequest();
             container.getBatchRequest().addRequest( addRequest );
-            addRequest.initAttributes(); // TODO maybe delay that to the first attribute
discovery
+            addRequest.initEntry(); // TODO maybe delay that to the first attribute discovery
 
             XmlPullParser xpp = container.getParser();
 
@@ -1204,7 +1205,7 @@
             {
                 try
                 {
-                    addRequest.setEntry( new LdapDN( attributeValue ) );
+                    addRequest.setEntryDn( new LdapDN( attributeValue ) );
                 }
                 catch ( InvalidNameException e )
                 {
@@ -1235,7 +1236,14 @@
             attributeValue = xpp.getAttributeValue( "", "name" );
             if ( attributeValue != null )
             {
-                addRequest.addAttributeType( attributeValue );
+                try
+                {
+                    addRequest.addAttributeType( attributeValue );
+                }
+                catch ( NamingException e )
+                {
+                    throw new XmlPullParserException( "can not add attribute value", xpp,
e );
+                }
             }
             else
             {

Modified: directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/SearchRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/SearchRequestDsml.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/SearchRequestDsml.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/SearchRequestDsml.java
Sun Aug 31 04:17:25 2008
@@ -22,9 +22,6 @@
 
 import java.util.List;
 
-import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attributes;
-
 import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.search.AndFilter;
@@ -36,6 +33,7 @@
 import org.apache.directory.shared.ldap.codec.search.PresentFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.studio.dsmlv2.ParserUtils;
 import org.dom4j.Element;
@@ -156,15 +154,14 @@
         toDsml( filterElement, request.getFilter() );
 
         // Attributes
-        Attributes attributes = request.getAttributes();
+        List<EntryAttribute> attributes = request.getAttributes();
         if ( attributes.size() > 0 )
         {
             Element attributesElement = element.addElement( "attributes" );
 
-            NamingEnumeration<String> ids = attributes.getIDs();
-            while ( ids.hasMoreElements() )
+            for ( EntryAttribute entryAttribute : attributes )
             {
-                attributesElement.addElement( "attribute" ).addAttribute( "name", ids.nextElement()
);
+                attributesElement.addElement( "attribute" ).addAttribute( "name", entryAttribute.getId()
);
             }
         }
 

Modified: directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/addRequest/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/addRequest/AddRequestTest.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/addRequest/AddRequestTest.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/addRequest/AddRequestTest.java
Sun Aug 31 04:17:25 2008
@@ -21,13 +21,13 @@
 package org.apache.directory.studio.dsmlv2.addRequest;
 
 
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
+import java.util.Iterator;
 
 import org.apache.directory.shared.ldap.codec.Control;
 import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.studio.dsmlv2.AbstractTest;
 import org.apache.directory.studio.dsmlv2.Dsmlv2Parser;
@@ -71,7 +71,7 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", addRequest.getEntry().toString()
);
+        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", addRequest.getEntryDn().toString()
);
     }
 
 
@@ -284,37 +284,17 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
-        assertEquals( 1, attributes.size() );
-
-        // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        // Getting the Attribute  
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertFalse( ne2.hasMoreElements() );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertFalse( valueIterator.hasNext() );
     }
 
 
@@ -340,37 +320,17 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
-
-        assertEquals( 1, attributes.size() );
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
         // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertFalse( ne2.hasMoreElements() );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertFalse( valueIterator.hasNext() );
     }
 
 
@@ -396,47 +356,19 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
-
-        assertEquals( 1, attributes.size() );
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
         // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        String value = null;
-        try
-        {
-            value = ( String ) ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "top", value );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "top", value.get() );
     }
 
 
@@ -462,47 +394,20 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
-
-        assertEquals( 1, attributes.size() );
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
         // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        Object value = null;
-        try
-        {
-            value = ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "DSMLv2.0 rocks!!", new String( ( byte[] ) value ) );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertTrue( value.isBinary() );
+        assertEquals( "DSMLv2.0 rocks!!", new String( ( byte[] ) value.get() ) );
     }
 
 
@@ -528,58 +433,23 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
-
-        assertEquals( 1, attributes.size() );
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
         // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        String value = null;
-        try
-        {
-            value = ( String ) ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "top", value );
-
-        try
-        {
-            value = ( String ) ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "person", value );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "top", value.get() );
+        assertTrue( valueIterator.hasNext() );
+        value = valueIterator.next();
+        assertEquals( "person", value.get() );
+        assertFalse( valueIterator.hasNext() );
     }
 
 
@@ -614,58 +484,23 @@
 
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = addRequest.getAttributes();
-
-        assertEquals( 1, attributes.size() );
+        Entry entry = addRequest.getEntry();
+        assertEquals( 1, entry.size() );
 
         // Getting the Attribute       
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = null;
-        try
-        {
-            attribute = ( Attribute ) ne.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "objectclass", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
 
         // Getting the Value
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        String value = null;
-        try
-        {
-            value = ( String ) ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "top", value );
-
-        try
-        {
-            value = ( String ) ne2.next();
-        }
-        catch ( NamingException e )
-        {
-            fail( e.getMessage() );
-        }
-
-        assertEquals( "person", value );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "top", value.get() );
+        assertTrue( valueIterator.hasNext() );
+        value = valueIterator.next();
+        assertEquals( "person", value.get() );
+        assertFalse( valueIterator.hasNext() );
     }
 
 

Modified: directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchRequest/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchRequest/SearchRequestTest.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchRequest/SearchRequestTest.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchRequest/SearchRequestTest.java
Sun Aug 31 04:17:25 2008
@@ -23,10 +23,7 @@
 
 import java.util.List;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
 import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
 import org.apache.directory.shared.ldap.codec.Control;
@@ -40,6 +37,7 @@
 import org.apache.directory.shared.ldap.codec.search.PresentFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.studio.dsmlv2.AbstractTest;
@@ -760,15 +758,11 @@
 
         SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = searchRequest.getAttributes();
-
+        List<EntryAttribute> attributes = searchRequest.getAttributes();
         assertEquals( 1, attributes.size() );
 
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = ( Attribute ) ne.next();
-
-        assertEquals( "sn", attribute.getID() );
+        EntryAttribute attribute = attributes.get( 0 );
+        assertEquals( "sn", attribute.getUpId() );
     }
 
 
@@ -795,19 +789,14 @@
 
         SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
 
-        Attributes attributes = searchRequest.getAttributes();
-
+        List<EntryAttribute> attributes = searchRequest.getAttributes();
         assertEquals( 2, attributes.size() );
 
-        NamingEnumeration ne = attributes.getAll();
+        EntryAttribute attribute1 = attributes.get( 0 );
+        assertEquals( "sn", attribute1.getUpId() );
 
-        Attribute attribute = ( Attribute ) ne.next();
-
-        assertEquals( "sn", attribute.getID() );
-
-        attribute = ( Attribute ) ne.next();
-
-        assertEquals( "givenName", attribute.getID() );
+        EntryAttribute attribute2 = attributes.get( 1 );
+        assertEquals( "givenName", attribute2.getUpId() );
     }
 
 
@@ -993,7 +982,7 @@
         AttributeValueAssertion assertion = approxMatchFilter.getAssertion();
 
         assertEquals( "sn", assertion.getAttributeDesc() );
-        
+
         assertEquals( "DSMLv2.0 rocks!!", new String( ( byte[] ) assertion.getAssertionValue().get()
) );
     }
 

Modified: directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java?rev=690676&r1=690675&r2=690676&view=diff
==============================================================================
--- directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java
(original)
+++ directory/studio/trunk/studio-dsml-parser/src/test/java/org/apache/directory/studio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java
Sun Aug 31 04:17:25 2008
@@ -22,14 +22,13 @@
 
 
 import java.io.UnsupportedEncodingException;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
+import java.util.Iterator;
 
 import org.apache.directory.shared.ldap.codec.Control;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.studio.dsmlv2.AbstractResponseTest;
 import org.apache.directory.studio.dsmlv2.Dsmlv2ResponseParser;
@@ -308,15 +307,12 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 1, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 1, entry.size() );
 
-        Attribute attribute = ( Attribute ) ne.nextElement();
-
-        assertEquals( "dc", attribute.getID() );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "dc", attribute.getUpId() );
     }
 
 
@@ -343,31 +339,17 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 1, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = ( Attribute ) ne.nextElement();
-
-        assertEquals( "dc", attribute.getID() );
-
-        assertEquals( 1, attribute.size() );
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 1, entry.size() );
 
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        String value = ( String ) ne2.nextElement();
-
-        assertEquals( "example", value );
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "dc", attribute.getUpId() );
+
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "example", value.get() );
     }
 
 
@@ -395,35 +377,22 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 1, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = ( Attribute ) ne.nextElement();
-
-        assertEquals( "cn", attribute.getID() );
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 1, entry.size() );
 
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "cn", attribute.getUpId() );
         assertEquals( 1, attribute.size() );
 
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        Object value = ne2.nextElement();
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
 
         String expected = new String( new byte[]
             { 'E', 'm', 'm', 'a', 'n', 'u', 'e', 'l', ' ', 'L', ( byte ) 0xc3, ( byte ) 0xa9,
'c', 'h', 'a', 'r', 'n',
                 'y' }, "UTF-8" );
-
-        assertEquals( expected, new String( ( byte[] ) value, "UTF-8" ) );
+        assertEquals( expected, new String( ( byte[] ) value.get(), "UTF-8" ) );
     }
 
 
@@ -450,31 +419,18 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 1, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = ( Attribute ) ne.nextElement();
-
-        assertEquals( "dc", attribute.getID() );
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 1, entry.size() );
 
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "dc", attribute.getUpId() );
         assertEquals( 1, attribute.size() );
 
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        String value = ( String ) ne2.nextElement();
-
-        assertEquals( "", value );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "", value.get() );
     }
 
 
@@ -501,35 +457,22 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 1, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute attribute = ( Attribute ) ne.nextElement();
-
-        assertEquals( "objectclass", attribute.getID() );
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 1, entry.size() );
 
+        Iterator<EntryAttribute> attributeIterator = entry.iterator();
+        EntryAttribute attribute = attributeIterator.next();
+        assertEquals( "objectclass", attribute.getUpId() );
         assertEquals( 2, attribute.size() );
 
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = attribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        String value = ( String ) ne2.nextElement();
-
-        assertEquals( "top", value );
-
-        value = ( String ) ne2.nextElement();
-
-        assertEquals( "domain", value );
+        Iterator<Value<?>> valueIterator = attribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "top", value.get() );
+        assertTrue( valueIterator.hasNext() );
+        value = valueIterator.next();
+        assertEquals( "domain", value.get() );
+        assertFalse( valueIterator.hasNext() );
     }
 
 
@@ -556,47 +499,26 @@
         SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
)
             .getCurrentSearchResultEntry();
 
-        Attributes attributes = searchResultEntry.getPartialAttributeList();
-
-        assertEquals( 2, attributes.size() );
-
-        NamingEnumeration ne = attributes.getAll();
-
-        Attribute objectClassAttribute = attributes.get( "objectclass" );
+        Entry entry = searchResultEntry.getEntry();
+        assertEquals( 2, entry.size() );
 
+        EntryAttribute objectClassAttribute = entry.get( "objectclass" );
         assertEquals( 1, objectClassAttribute.size() );
 
-        NamingEnumeration ne2 = null;
-        try
-        {
-            ne2 = objectClassAttribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        String value = ( String ) ne2.nextElement();
-
-        assertEquals( "top", value );
-
-        Attribute dcAttribute = attributes.get( "dc" );
+        Iterator<Value<?>> valueIterator = objectClassAttribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        Value<?> value = valueIterator.next();
+        assertEquals( "top", value.get() );
+        assertFalse( valueIterator.hasNext() );
 
-        assertEquals( 1, dcAttribute.size() );
-
-        ne2 = null;
-        try
-        {
-            ne2 = dcAttribute.getAll();
-        }
-        catch ( NamingException e )
-        {
-            fail();
-        }
-
-        value = ( String ) ne2.nextElement();
+        EntryAttribute dcAttribute = entry.get( "dc" );
+        assertEquals( 1, objectClassAttribute.size() );
 
-        assertEquals( "example", value );
+        valueIterator = dcAttribute.iterator();
+        assertTrue( valueIterator.hasNext() );
+        value = valueIterator.next();
+        assertEquals( "example", value.get() );
+        assertFalse( valueIterator.hasNext() );
     }
 
 



Mime
View raw message