harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r644225 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/org/apache/harmony/jndi/provider/ldap/ test/java/org/apache/harmony/jndi/provider/ldap/ test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/
Date Thu, 03 Apr 2008 08:48:19 GMT
Author: tonywu
Date: Thu Apr  3 01:48:17 2008
New Revision: 644225

URL: http://svn.apache.org/viewvc?rev=644225&view=rev
Log:
Apply patch for HARMONY-5681 ([classlib][jndi][ldap] - move getSocketFactory function from
LdapClient to LdapUtils)

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextFactory.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java
Thu Apr  3 01:48:17 2008
@@ -27,13 +27,10 @@
 import java.util.List;
 
 import javax.naming.CommunicationException;
-import javax.naming.ConfigurationException;
-import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.ldap.Control;
 import javax.naming.ldap.StartTlsRequest;
 import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 import org.apache.harmony.jndi.provider.ldap.LdapContextImpl.UnsolicitedListener;
@@ -94,6 +91,10 @@
      * registered UnsolicitedListener
      */
     private List<UnsolicitedListener> unls = new ArrayList<UnsolicitedListener>();
+
+    /**
+     * how may references point to this client
+     */
     private int referCount = 0;
 
     // constructor for test
@@ -521,66 +522,22 @@
      */
     public static LdapClient newInstance(String host, int port,
             Hashtable<?, ?> envmt) throws NamingException {
-        String factoryName = (String) envmt
-                .get("java.naming.ldap.factory.socket");
+        return newInstance(host, port, envmt, false);
+    }
 
-        SocketFactory factory = null;
-        if (factoryName == null || "".equals(factoryName)) {
-            if ("ssl".equalsIgnoreCase((String) envmt
-                    .get(Context.SECURITY_PROTOCOL))) {
-                factory = SSLSocketFactory.getDefault();
-            } else {
-                factory = SocketFactory.getDefault();
-            }
-        } else {
+    public static LdapClient newInstance(String host, int port,
+            Hashtable<?, ?> envmt, boolean isLdaps) throws NamingException {
+        SocketFactory factory = LdapUtils.getSocketFactory(envmt, isLdaps);
 
-            try {
-                factory = (SocketFactory) classForName(factoryName)
-                        .newInstance();
-            } catch (Exception e) {
-                ConfigurationException ex = new ConfigurationException();
-                ex.setRootCause(e);
-                throw ex;
-            }
-        }
         // TODO: get LdapClient from pool first.
 
         try {
             return new LdapClient(factory, host, port);
-
         } catch (IOException e) {
             CommunicationException ex = new CommunicationException();
             ex.setRootCause(e);
             throw ex;
         }
-    }
-
-    private static Class<?> classForName(final String className)
-            throws ClassNotFoundException {
-
-        Class<?> cls = null;
-        // try thread context class loader first
-        try {
-            cls = Class.forName(className, true, Thread.currentThread()
-                    .getContextClassLoader());
-        } catch (ClassNotFoundException e) {
-            // Ignored.
-        }
-        // try system class loader second
-        try {
-            cls = Class.forName(className, true, ClassLoader
-                    .getSystemClassLoader());
-        } catch (ClassNotFoundException e1) {
-            // Ignored.
-        }
-
-        if (cls == null) {
-            // jndi.1C=class {0} not found
-            throw new ClassNotFoundException(Messages.getString(
-                    "jndi.1C", className)); //$NON-NLS-1$
-        }
-
-        return cls;
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextFactory.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextFactory.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextFactory.java
Thu Apr  3 01:48:17 2008
@@ -49,7 +49,8 @@
         int port = parser.getPort();
         String dn = parser.getBaseObject();
 
-        LdapClient client = LdapClient.newInstance(host, port, myEnv);
+        LdapClient client = LdapClient.newInstance(host, port, myEnv, LdapUtils
+                .isLdapsURL(url));
 
         LdapContextImpl context = new LdapContextImpl(client, myEnv, dn);
 

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
Thu Apr  3 01:48:17 2008
@@ -36,12 +36,10 @@
 import java.util.StringTokenizer;
 import java.util.TreeMap;
 
-import javax.naming.AuthenticationNotSupportedException;
 import javax.naming.Binding;
 import javax.naming.CannotProceedException;
 import javax.naming.CommunicationException;
 import javax.naming.CompositeName;
-import javax.naming.ConfigurationException;
 import javax.naming.Context;
 import javax.naming.InvalidNameException;
 import javax.naming.LimitExceededException;

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java
Thu Apr  3 01:48:17 2008
@@ -19,10 +19,13 @@
 
 import java.lang.reflect.Constructor;
 import java.util.HashMap;
+import java.util.Hashtable;
 
 import javax.naming.AuthenticationException;
 import javax.naming.AuthenticationNotSupportedException;
 import javax.naming.CommunicationException;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
 import javax.naming.ContextNotEmptyException;
 import javax.naming.InvalidNameException;
 import javax.naming.LimitExceededException;
@@ -43,6 +46,8 @@
 import javax.naming.directory.NoSuchAttributeException;
 import javax.naming.directory.SchemaViolationException;
 import javax.naming.ldap.LdapName;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 import org.apache.harmony.jndi.provider.ldap.parser.FilterParser;
@@ -219,5 +224,74 @@
 
         return (LdapName) dn.getSuffix(base.size());
 
+    }
+    /**
+     * Get SocketFactory according three properties:
+     * "java.naming.ldap.factory.socket", "java.naming.security.protocol" and
+     * protocol defined in URL. If "java.naming.ldap.factory.socket" set, then
+     * use it. otherwise check protocol defined in URL: "ldaps" use
+     * <code>SSLSocketFactory.getDefault()</code> to retrieve factory; If is
+     * "ldap", check whether "java.naming.security.protocol" is set to "ssl", if
+     * set, use <code>SSLSocketFactory.getDefault()</code> get factory.
+     * 
+     * @param envmt
+     * @param isLdaps
+     * @return
+     * @throws ConfigurationException
+     */
+    public static SocketFactory getSocketFactory(Hashtable<?, ?> envmt,
+            boolean isLdaps) throws ConfigurationException {
+        String factoryName = (String) envmt
+                .get("java.naming.ldap.factory.socket");
+
+        SocketFactory factory = null;
+
+        // if "java.naming.ldap.factory.socket" set, use it
+        if (factoryName != null && !("".equals(factoryName))) {
+            try {
+                factory = (SocketFactory) classForName(factoryName)
+                        .newInstance();
+            } catch (Exception e) {
+                ConfigurationException ex = new ConfigurationException();
+                ex.setRootCause(e);
+                throw ex;
+            }
+        }
+
+        // factory name not set
+        if (factory == null) {
+            if (isLdaps) {
+                factory = SSLSocketFactory.getDefault();
+            }
+            // It's case sensitive in RI
+            else if ("ssl".equalsIgnoreCase((String) envmt
+                    .get(Context.SECURITY_PROTOCOL))) {
+                factory = SSLSocketFactory.getDefault();
+            } else {
+                factory = SocketFactory.getDefault();
+            }
+        }
+
+        return factory;
+    }
+
+    public static boolean isLdapsURL(String url) {
+        return url.toLowerCase().startsWith("ldaps://");
+    }
+
+    private static Class<?> classForName(final String className)
+            throws ClassNotFoundException {
+        Class<?> cls = null;
+        // try thread context class loader first
+        try {
+            cls = Class.forName(className, true, Thread.currentThread()
+                    .getContextClassLoader());
+        } catch (ClassNotFoundException e) {
+            // try system class loader second
+            cls = Class.forName(className, true, ClassLoader
+                    .getSystemClassLoader());
+        }
+
+        return cls;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java
Thu Apr  3 01:48:17 2008
@@ -60,7 +60,8 @@
         String host = parser.getHost();
         int port = parser.getPort();
 
-        LdapClient client = LdapClient.newInstance(host, port, env);
+        LdapClient client = LdapClient.newInstance(host, port, env, LdapUtils
+                .isLdapsURL(referrals[index]));
 
         LdapContextImpl context = new LdapContextImpl(client,
                 (Hashtable<Object, Object>) env, targetDN);
@@ -84,7 +85,8 @@
         String host = parser.getHost();
         int port = parser.getPort();
 
-        LdapClient client = LdapClient.newInstance(host, port, myEnv);
+        LdapClient client = LdapClient.newInstance(host, port, myEnv, LdapUtils
+                .isLdapsURL(referrals[index]));
 
         LdapContextImpl context = new LdapContextImpl(client, myEnv, targetDN);
 

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
Thu Apr  3 01:48:17 2008
@@ -76,7 +76,8 @@
         int port = parser.getPort();
         String dn = parser.getBaseObject();
 
-        LdapClient client = LdapClient.newInstance(host, port, myEnv);
+        LdapClient client = LdapClient.newInstance(host, port, myEnv, LdapUtils
+                .isLdapsURL(url));
 
         LdapContextImpl context = new LdapContextImpl(client,
                 (Hashtable<Object, Object>) myEnv, dn);
@@ -490,7 +491,8 @@
         String host = parser.getHost();
         int port = parser.getPort();
 
-        LdapClient client = LdapClient.newInstance(host, port, environment);
+        LdapClient client = LdapClient.newInstance(host, port, environment,
+                LdapUtils.isLdapsURL(url));
         LdapContextImpl context = null;
         try {
             context = new LdapContextImpl(client,
@@ -564,7 +566,8 @@
         String host = parser.getHost();
         int port = parser.getPort();
 
-        LdapClient client = LdapClient.newInstance(host, port, environment);
+        LdapClient client = LdapClient.newInstance(host, port, environment,
+                LdapUtils.isLdapsURL(url));
         LdapContextImpl context = null;
 
         try {

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java
Thu Apr  3 01:48:17 2008
@@ -17,12 +17,18 @@
 
 package org.apache.harmony.jndi.provider.ldap;
 
+import java.net.Socket;
+import java.util.Hashtable;
 import javax.naming.CommunicationException;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
 import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 import javax.naming.TimeLimitExceededException;
 import javax.naming.directory.InvalidSearchFilterException;
 import javax.naming.ldap.LdapName;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
 
 import junit.framework.TestCase;
 
@@ -179,6 +185,143 @@
         } catch (NamingException e) {
             // expected
         }
+    }
+
+    /*
+     * @Test
+     * org.apache.harmony.jndi.provider.ldap.LdapUtils.getSocketFactory(Hashtable<?,
+     * ?>)
+     * 
+     * There are three properties determine the SocketFactory to be used:
+     * "java.naming.ldap.factory.socket", "java.naming.security.protocol" and
+     * protocol defined in URL
+     * 
+     */
+    public void test_getSocketFactory() throws Exception {
+
+        SocketFactory factory = null;
+        String painSocketFactoryName = SocketFactory.getDefault().getClass()
+                .getName();
+        String sslSocketFactoryName = SSLSocketFactory.getDefault().getClass()
+                .getName();
+
+        /*
+         * Ldaps=false
+         */
+        Hashtable<Object, Object> env = new Hashtable<Object, Object>();
+        factory = LdapUtils.getSocketFactory(env, false);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(painSocketFactoryName));
+
+        /*
+         * Ldaps=true
+         */
+        factory = LdapUtils.getSocketFactory(env, true);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=true java.naming.security.protocol=ssl
+         */
+        env = new Hashtable<Object, Object>();
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        factory = LdapUtils.getSocketFactory(env, true);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=false java.naming.security.protocol=ssl
+         */
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        factory = LdapUtils.getSocketFactory(env, false);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=true java.naming.ldap.factory.socket=pain socket factory
+         */
+        env = new Hashtable<Object, Object>();
+        env.put("java.naming.ldap.factory.socket", painSocketFactoryName);
+        try {
+            factory = LdapUtils.getSocketFactory(env, true);
+            fail("Should throw IllegalAccessException");
+        } catch (ConfigurationException e) {
+            assertTrue(e.getCause() instanceof IllegalAccessException);
+        }
+
+        /*
+         * Ldaps=false java.naming.ldap.factory.socket=pain socket factory
+         */
+        env.put("java.naming.ldap.factory.socket", painSocketFactoryName);
+        try {
+            factory = LdapUtils.getSocketFactory(env, false);
+            fail("Should throw IllegalAccessException");
+        } catch (ConfigurationException e) {
+            assertTrue(e.getCause() instanceof IllegalAccessException);
+        }
+
+        /*
+         * Ldaps=true java.naming.ldap.factory.socket=ssl socket factory
+         */
+        env = new Hashtable<Object, Object>();
+        env.put("java.naming.ldap.factory.socket", sslSocketFactoryName);
+        factory = LdapUtils.getSocketFactory(env, true);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=false java.naming.ldap.factory.socket=ssl socket factory
+         */
+        env.put("java.naming.ldap.factory.socket", sslSocketFactoryName);
+        factory = LdapUtils.getSocketFactory(env, false);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=false java.naming.ldap.factory.socket=ssl socket factory
+         * java.naming.security.protocol=ssl
+         */
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        env.put("java.naming.ldap.factory.socket", sslSocketFactoryName);
+        factory = LdapUtils.getSocketFactory(env, false);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
+
+        /*
+         * Ldaps=false java.naming.ldap.factory.socket=pain socket factory
+         * java.naming.security.protocol=ssl
+         */
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        env.put("java.naming.ldap.factory.socket", painSocketFactoryName);
+        try {
+            factory = LdapUtils.getSocketFactory(env, false);
+            fail("Should throw IllegalAccessException");
+        } catch (ConfigurationException e) {
+            assertTrue(e.getCause() instanceof IllegalAccessException);
+        }
+
+        /*
+         * Ldaps=true java.naming.ldap.factory.socket=pain socket factory
+         * java.naming.security.protocol=ssl
+         */
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        env.put("java.naming.ldap.factory.socket", painSocketFactoryName);
+        try {
+            factory = LdapUtils.getSocketFactory(env, true);
+            fail("Should throw IllegalAccessException");
+        } catch (ConfigurationException e) {
+            assertTrue(e.getCause() instanceof IllegalAccessException);
+        }
+
+        /*
+         * Ldaps=true java.naming.ldap.factory.socket=ssl socket factory
+         * java.naming.security.protocol=ssl
+         */
+        env.put(Context.SECURITY_PROTOCOL, "ssl");
+        env.put("java.naming.ldap.factory.socket", sslSocketFactoryName);
+        factory = LdapUtils.getSocketFactory(env, true);
+        assertNotNull(factory);
+        assertTrue(factory.getClass().getName().equals(sslSocketFactoryName));
     }
     private LdapResult getLdapResult(int errorCode, String message) {
         LdapResult result = new LdapResult();

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java?rev=644225&r1=644224&r2=644225&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
Thu Apr  3 01:48:17 2008
@@ -424,12 +424,39 @@
 		}
 	}
 
+    /**
+     * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String,
boolean, byte[])'</p>
+     */
+    public void testSortResponseControl019() throws IOException{
 
-	/**
-	 * <p>Test method for 'javax.naming.ldap.SortResponseControl.isSorted()'</p>
-	 * <p>Here we are testing if the isSorted method returns the correct answer for sorted
results.</p>
-	 * <p>The expected result in this case is true.</p>
-	 */
+        String Id="test";
+        boolean crit=false;
+        byte[] ber1={48,1,10,1,0};
+        byte[] ber2={48,5,10,1,3};
+        byte[] ber3={48,3,10,2,3,3};
+        byte[] ber4={48,4,10,1,3,3,3};
+        byte[] ber5={48,8,10,1,3,(byte)128,3,'T','e','s','t'};
+        SortResponseControl src=null;
+        src = new SortResponseControl(Id, crit, ber1);
+        assertEquals(Id, src.getID());
+        assertEquals(src.getResultCode(), 0);
+        src = new SortResponseControl(Id, crit, ber2);
+        assertEquals(src.getResultCode(), 3);
+        src = new SortResponseControl(Id, crit, ber3);
+        assertEquals(src.getResultCode(), 771);
+        src = new SortResponseControl(Id, crit, ber4);
+        assertEquals(src.getResultCode(), 3);
+        src = new SortResponseControl(Id, crit, ber5);
+        assertEquals(src.getResultCode(), 3);
+        assertEquals("Tes", src.getAttributeID());
+    }    
+
+
+    /**
+     * <p>Test method for 'javax.naming.ldap.SortResponseControl.isSorted()'</p>
+     * <p>Here we are testing if the isSorted method returns the correct answer for
sorted results.</p>
+     * <p>The expected result in this case is true.</p>
+     */
 	public void testIsSorted001() {
 
 		SortResponseControl src=null;



Mime
View raw message