harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r646264 [4/13] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/build/platform/ depends/files/ modules/accessibility/ modules/annotation/ modules/applet/ modules/archive/ modules/archive/src/main/java/java/util/jar/ mo...
Date Wed, 09 Apr 2008 11:02:07 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java Wed Apr  9 04:01:14 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;
@@ -136,6 +134,10 @@
      */
     private Control[] connCtls;
 
+    private boolean isReBind = false;
+
+    private boolean isReConnect = false;
+
     private HashMap<NamingListener, List<Integer>> listeners;
 
     private List<UnsolicitedNotificationListener> unls;
@@ -199,20 +201,14 @@
             Hashtable<Object, Object> environment, String dn)
             throws NamingException {
         initial(client, environment, dn);
-
-        try {
             doBindOperation(connCtls);
-        } catch (IOException e) {
-            CommunicationException ex = new CommunicationException();
-            ex.setRootCause(e);
-            throw ex;
-        }
     }
 
     private void initial(LdapClient ldapClient,
             Hashtable<Object, Object> environment, String dn)
             throws InvalidNameException {
         this.client = ldapClient;
+        client.use();
         if (environment == null) {
             this.env = new Hashtable<Object, Object>();
         } else {
@@ -239,13 +235,16 @@
      * @throws NamingException
      * @throws ParseException
      */
-    private void doBindOperation(Control[] connCtsl) throws IOException,
-            NamingException {
+    private void doBindOperation(Control[] connCtsl) throws NamingException {
+        if (client.getReferCount() > 1) {
+            changeConnection();
+        }
 
         SaslBind saslBind = new SaslBind();
         LdapResult result = null;
 
         SaslBind.AuthMech authMech = saslBind.valueAuthMech(env);
+        try {
         if (authMech == SaslBind.AuthMech.None) {
             BindOp bind = new BindOp("", "", null, null);
             client.doOperation(bind, connCtsl);
@@ -259,6 +258,11 @@
             result = bind.getResult();
         } else if (authMech == SaslBind.AuthMech.SASL) {
             result = saslBind.doSaslBindOperation(env, client, connCtsl);
+            }
+        } catch (IOException e) {
+            CommunicationException ex = new CommunicationException();
+            ex.setRootCause(e);
+            throw ex;
         }
 
         if (LdapUtils.getExceptionFromResult(result) != null) {
@@ -316,14 +320,16 @@
     }
 
     public void reconnect(Control[] ac) throws NamingException {
-        connCtls = ac;
-        try {
-            doBindOperation(connCtls);
-        } catch (IOException e) {
-            CommunicationException ex = new CommunicationException();
-            ex.setRootCause(e);
-            throw ex;
+        connCtls = copyControls(ac);
+        if (isReConnect) {
+            try {
+                changeConnection();
+            } finally {
+                isReConnect = false;
+            }
         }
+
+        doBindOperation(connCtls);
     }
 
     public void setRequestControls(Control[] controls) throws NamingException {
@@ -426,7 +432,7 @@
 
     private Attributes convertSerialToAttribute(Serializable serializable)
             throws NamingException {
-        Attributes attrs = new BasicAttributes();
+        Attributes attrs = new BasicAttributes(true);
 
         Attribute objectClass = new BasicAttribute("objectClass");
         objectClass.add("top");
@@ -474,7 +480,7 @@
     }
 
     private Attributes convertRefToAttribute(Reference ref) {
-        Attributes attrs = new BasicAttributes();
+        Attributes attrs = new BasicAttributes(true);
 
         Attribute objectClass = new BasicAttribute("objectClass");
         objectClass.add("top");
@@ -533,7 +539,7 @@
          */
 
         if (attributes == null) {
-            attributes = new BasicAttributes();
+            attributes = new BasicAttributes(true);
             Attribute attr = new LdapAttribute("objectClass", this);
             attr.add("top");
             attr.add("javaContainer");
@@ -626,7 +632,7 @@
             return first;
         }
 
-        BasicAttributes attrs = new BasicAttributes();
+        BasicAttributes attrs = new BasicAttributes(true);
         NamingEnumeration<? extends Attribute> enu = first.getAll();
         while (enu.hasMore()) {
             attrs.put(enu.next());
@@ -741,7 +747,7 @@
         }
 
         // no attribute retrieved from server, return a empty Attributes
-        return new BasicAttributes();
+        return new BasicAttributes(true);
     }
 
     public Attributes getAttributes(String s) throws NamingException {
@@ -1276,7 +1282,7 @@
                 sr.setNameInNamespace(dn.substring(index + 1, dn.length()));
                 list.add(sr);
             } else {
-                String relativeName = convertToRelativeName(dn, baseDN);
+                String relativeName = LdapUtils.convertToRelativeName(dn, baseDN);
                 sr = new SearchResult(relativeName, null, entries.get(dn));
                 sr.setNameInNamespace(dn);
             }
@@ -1334,7 +1340,7 @@
                 sr.setNameInNamespace(dn.substring(index + 1, dn.length()));
                 list.add(sr);
             } else {
-                String relativeName = convertToRelativeName(dn, baseDN);
+                String relativeName = LdapUtils.convertToRelativeName(dn, baseDN);
                 sr = new SearchResult(relativeName, null, entries.get(dn));
                 sr.setNameInNamespace(dn);
             }
@@ -1377,6 +1383,8 @@
     }
 
     LdapSearchResult doSearch(SearchOp op) throws NamingException {
+        applyEnvChange();
+
         if (env.get(LDAP_DEREF_ALIASES) != null) {
             String derefAliases = (String) env.get(LDAP_DEREF_ALIASES);
             if (derefAliases.equals("always")) {
@@ -1480,6 +1488,16 @@
         return op.getSearchResult();
     }
 
+    private void applyEnvChange() throws NamingException {
+        if (isReBind) {
+            try {
+                reconnect(connCtls);
+            } finally {
+                isReBind = false;
+            }
+        }
+    }
+
     /**
      * Follow referrals in SearchResultReference. Referrals in
      * SearchResultReference is different with LDAPResult, which may contians
@@ -1537,6 +1555,10 @@
     }
 
     public Object addToEnvironment(String s, Object o) throws NamingException {
+        if (s == null || o == null) {
+            throw new NullPointerException();
+        }
+
         Object preValue = env.put(s, o);
 
         // if preValue equals o, do nothing
@@ -1545,7 +1567,13 @@
             return preValue;
         }
 
-        updateEnvironment(s);
+        if (connectionProperties.contains(s)) {
+            if (s.equals(Context.SECURITY_PROTOCOL)
+                    || s.equals("java.naming.ldap.factory.socket")) {
+                isReConnect = true;
+            }
+            isReBind = true;
+        }
 
         return preValue;
     }
@@ -1561,6 +1589,7 @@
     public void close() throws NamingException {
         if (!isClosed) {
             isClosed = true;
+            client.unuse();
             client = null;
         }
     }
@@ -1736,7 +1765,7 @@
         tempName.addAll(name);
         String baseDN = tempName.toString();
         for (String dn : entries.keySet()) {
-            String relativeName = convertToRelativeName(dn, baseDN);
+            String relativeName = LdapUtils.convertToRelativeName(dn, baseDN);
             Attributes attrs = entries.get(dn);
             Attribute attrClass = attrs.get("javaClassName");
             String className = null;
@@ -1760,29 +1789,6 @@
                 .getException());
     }
 
-    /**
-     * convert absolute dn to the dn relatived to the dn of
-     * <code>targetContextDN</code>.
-     * 
-     * @param dn
-     *            absolute dn
-     * @param base
-     *            base dn of the relative name
-     * @return dn relatived to the <code>dn</code> of <code>base</code>
-     */
-    protected String convertToRelativeName(String dn, String base) {
-
-        if (base.equals("")) {
-            return dn;
-        }
-
-        int index = dn.lastIndexOf(base);
-        if (index == 0) {
-            return "";
-        }
-
-        return dn.substring(0, index - 1);
-    }
 
     protected String getTargetDN(Name name, Name prefix)
             throws NamingException, InvalidNameException {
@@ -2085,6 +2091,10 @@
     }
 
     public Object removeFromEnvironment(String s) throws NamingException {
+        if (s == null) {
+            throw new NullPointerException();
+        }
+
         Object preValue = env.remove(s);
 
         // if s doesn't exist in env
@@ -2092,33 +2102,25 @@
             return preValue;
         }
 
-        updateEnvironment(s);
+        if (connectionProperties.contains(s)) {
+            if (s.equals(Context.SECURITY_PROTOCOL)
+                    || s.equals("java.naming.ldap.factory.socket")) {
+                isReConnect = true;
+            }
+            isReBind = true;
+        }
 
         return preValue;
     }
 
-    private void updateEnvironment(String propName) throws NamingException,
-            AuthenticationNotSupportedException, CommunicationException,
-            ConfigurationException {
-        if (connectionProperties.contains(propName)) {
-            if (propName.equals("java.naming.ldap.factory.socket")) {
-                // use new socket factory to connect server
-                String address = client.getAddress();
-                int port = client.getPort();
-
-                client = LdapClient.newInstance(address, port, env);
-                try {
-                    doBindOperation(connCtls);
-                } catch (IOException e) {
-                    CommunicationException ex = new CommunicationException();
-                    ex.setRootCause(e);
-                    throw ex;
-                }
-            } else {
+    private void changeConnection() throws NamingException {
 
-                reconnect(connCtls);
-            }
-        }
+        // use new socket factory to connect server
+        String address = client.getAddress();
+        int port = client.getPort();
+        client.unuse();
+        client = LdapClient.newInstance(address, port, env);
+        client.use();
     }
 
     public void rename(Name nOld, Name nNew) throws NamingException {
@@ -2199,6 +2201,8 @@
      * @throws NamingException
      */
     protected void doBasicOperation(LdapOperation op) throws NamingException {
+        applyEnvChange();
+
         LdapMessage message = null;
         try {
             message = client.doOperation(op, requestControls);
@@ -2472,7 +2476,8 @@
 
     private int doPersistentSearch(String targetDN, final String baseDN,
             Filter filter, SearchControls controls,
-            NamingListener namingListener) throws CommunicationException {
+            NamingListener namingListener) throws NamingException {
+        applyEnvChange();
 
         SearchOp op = new SearchOp(targetDN, controls, filter);
 
@@ -2485,7 +2490,11 @@
                 // construct event
                 if (obj instanceof ECNotificationControl) {
                     ECNotificationControl control = (ECNotificationControl) obj;
-                    event = constructNamingEvent(this, control, baseDN);
+                    try {
+                        event = constructNamingEvent(this, control, baseDN);
+                    } catch (NamingException e) {
+                        // FIXME may never reach
+                    }
                 }
 
                 if (obj instanceof LdapResult) {
@@ -2579,36 +2588,36 @@
     }
 
     private NamingEvent constructNamingEvent(PersistentSearchResult result,
-            ECNotificationControl control, String baseDN) {
+            ECNotificationControl control, String baseDN) throws InvalidNameException, NamingException {
         Binding newBinding = null;
         Binding oldBinding = null;
 
         switch (control.getChangeType()) {
         case ECNotificationControl.ADD:
-            String newName = convertToRelativeName(result.getDn(), baseDN);
+            String newName = LdapUtils.convertToRelativeName(result.getDn(), baseDN);
             newBinding = new Binding(newName, null);
             newBinding.setNameInNamespace(result.getDn());
             break;
         case ECNotificationControl.DELETE:
-            String deleteName = convertToRelativeName(result.getDn(), baseDN);
+            String deleteName = LdapUtils.convertToRelativeName(result.getDn(), baseDN);
             oldBinding = new Binding(deleteName, null);
             oldBinding.setNameInNamespace(result.getDn());
             break;
         case ECNotificationControl.MODIFY_DN:
             if (result.getDn() != null) {
-                newBinding = new Binding(convertToRelativeName(result.getDn(),
+                newBinding = new Binding(LdapUtils.convertToRelativeName(result.getDn(),
                         baseDN), null);
                 newBinding.setNameInNamespace(result.getDn());
             }
 
             if (control.getPreviousDN() != null) {
-                oldBinding = new Binding(convertToRelativeName(control
+                oldBinding = new Binding(LdapUtils.convertToRelativeName(control
                         .getPreviousDN(), baseDN), null);
                 oldBinding.setNameInNamespace(control.getPreviousDN());
             }
             break;
         case ECNotificationControl.MODIFY:
-            String relativeName = convertToRelativeName(result.getDn(), baseDN);
+            String relativeName = LdapUtils.convertToRelativeName(result.getDn(), baseDN);
             newBinding = new Binding(relativeName, null);
             newBinding.setNameInNamespace(result.getDn());
             // FIXME: how to get old binding?

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java Wed Apr  9 04:01:14 2008
@@ -47,7 +47,7 @@
 
     public Attributes getAttributes(Name name, String[] as)
             throws NamingException {
-        BasicAttributes attributes = new BasicAttributes();
+        BasicAttributes attributes = new BasicAttributes(true);
         Set<String> keySet = attrTree.keySet();
         Iterator<String> iter = keySet.iterator();
         while (iter.hasNext()) {

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java Wed Apr  9 04:01:14 2008
@@ -57,7 +57,7 @@
                         .findSchemaDefInfo(
                                 LdapSchemaContextImpl.OBJECT_CLASSES, className
                                         .toLowerCase());
-                as = new BasicAttributes();
+                as = new BasicAttributes(true);
                 Set<String> keySet = classDefInfo.keySet();
                 for (Iterator<String> iterator = keySet.iterator(); iterator
                         .hasNext();) {

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java Wed Apr  9 04:01:14 2008
@@ -188,7 +188,7 @@
     public Attributes getAttributes(Name name) throws NamingException {
         Name targetDN = (rdn.size() != 0) ? name.addAll(rdn) : name;
 
-        BasicAttributes schemaAttributes = new BasicAttributes();
+        BasicAttributes schemaAttributes = new BasicAttributes(true);
 
         Set<String> keyset = null;
         int size = targetDN.size();
@@ -209,7 +209,7 @@
             if (null == classDef) {
                 throw new NameNotFoundException(name.toString());
             }
-            schemaAttributes = new BasicAttributes();
+            schemaAttributes = new BasicAttributes(true);
             keyset = classDef.keySet();
             for (Iterator<String> i = keyset.iterator(); i.hasNext();) {
                 String id = i.next();
@@ -228,7 +228,7 @@
             throws NamingException {
         Attributes attrs = getAttributes(name);
         Attribute attr = null;
-        Attributes filteredAttrs = new BasicAttributes();
+        Attributes filteredAttrs = new BasicAttributes(true);
         for (int i = 0; i < as.length; i++) {
             attr = attrs.get(as[i]);
             if (attr != null) {
@@ -543,7 +543,7 @@
         boolean hasAttributes2Return = (null != as && 0 != as.length);
 
         // Attribute matcher
-        BasicAttributes attrMatcher = new BasicAttributes();
+        BasicAttributes attrMatcher = new BasicAttributes(true);
         if (hasMatchingAttributes) {
             NamingEnumeration<? extends Attribute> attrEnum = attributes
                     .getAll();
@@ -611,7 +611,7 @@
                      * encountered attribute value,
                      */
                     if (attribute.contains(schemaType)) {
-                        BasicAttributes basicAttributes = new BasicAttributes();
+                        BasicAttributes basicAttributes = new BasicAttributes(true);
                         /*
                          * if(objectclassIndex == -1), then No name was choose,
                          * which means SearchResult will have empty
@@ -629,7 +629,7 @@
             } else {
                 for (int i = 0; i < attrValues.size(); i++) {
                     schemaType = schemaLdap2Jndi.get(attrValues.get(i));
-                    BasicAttributes basicAttributes = new BasicAttributes();
+                    BasicAttributes basicAttributes = new BasicAttributes(true);
                     /*
                      * if(objectclassIndex == -1), then No name was choose,
                      * which means SearchResult will have empty BasicAttributes.
@@ -674,7 +674,7 @@
                         }
                     }
                     if (matched) {
-                        basicAttributes = new BasicAttributes();
+                        basicAttributes = new BasicAttributes(true);
                         for (Iterator<String> iterator = schemaDef.keySet()
                                 .iterator(); iterator.hasNext();) {
                             String key = iterator.next();
@@ -695,7 +695,7 @@
                 for (int i = 0; i < attrValues.size(); i++) {
                     Hashtable<String, Object> schemaDef = schemas
                             .get(attrValues.get(i));
-                    basicAttributes = new BasicAttributes();
+                    basicAttributes = new BasicAttributes(true);
                     for (Iterator<String> iterator = schemaDef.keySet()
                             .iterator(); iterator.hasNext();) {
                         String key = iterator.next();
@@ -782,7 +782,7 @@
             throw ex;
         }
 
-        BasicAttributes matchingAttrs = new BasicAttributes();
+        BasicAttributes matchingAttrs = new BasicAttributes(true);
         extractMatchingAttributes(f, matchingAttrs);
 
         return search(name, matchingAttrs, searchControls

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java Wed Apr  9 04:01:14 2008
@@ -101,7 +101,7 @@
         if (entries.containsKey(name)) {
             attrs = entries.get(name);
         } else {
-            attrs = new BasicAttributes();
+            attrs = new BasicAttributes(true);
             entries.put(name, attrs);
         }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapUtils.java Wed Apr  9 04:01:14 2008
@@ -19,13 +19,17 @@
 
 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;
+import javax.naming.Name;
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
@@ -41,6 +45,9 @@
 import javax.naming.directory.InvalidSearchFilterException;
 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;
@@ -178,5 +185,113 @@
             return new NamingException(Messages.getString("ldap.35", //$NON-NLS-1$
                     new Object[] { errorCode }));
         }
+    }
+
+    /**
+     * convert absolute dn to the dn relatived to the dn of
+     * <code>targetContextDN</code>.
+     * 
+     * @param dn
+     *            absolute dn
+     * @param base
+     *            base dn of the relative name
+     * @return dn relatived to the <code>dn</code> of <code>base</code>
+     * @throws NamingException
+     * @throws InvalidNameException
+     */
+    public static String convertToRelativeName(String dn, String base)
+            throws InvalidNameException, NamingException {
+        return convertToRelativeName(new LdapName(dn), new LdapName(base))
+                .toString();
+    }
+
+    public static LdapName convertToRelativeName(LdapName dn, LdapName base)
+            throws NamingException {
+        if (base.size() == 0) {
+            return dn;
+        }
+
+        if (dn.size() < base.size()) {
+            // TODO add error message
+            throw new NamingException("");
+        }
+
+        Name prefix = dn.getPrefix(base.size());
+        if (!prefix.equals(base)) {
+            // TODO add error message
+            throw new NamingException("");
+        }
+
+        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/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionImpl.java Wed Apr  9 04:01:14 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/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java Wed Apr  9 04:01:14 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/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java Wed Apr  9 04:01:14 2008
@@ -27,6 +27,7 @@
 import javax.naming.ldap.Control;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.PagedResultsControl;
 import javax.naming.ldap.SortControl;
 
 import junit.framework.TestCase;
@@ -42,7 +43,7 @@
     private Hashtable<Object, Object> env = new Hashtable<Object, Object>();
 
     @Override
-    public void setUp() {
+    public void setUp() throws Exception {
         server = new MockLdapServer();
         server.start();
         env.put(Context.INITIAL_CONTEXT_FACTORY,
@@ -132,8 +133,11 @@
 
         assertNull(context.getConnectControls());
 
+        server = new MockLdapServer(server);
+        server.start();
         server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                 LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+
         context.reconnect(new Control[] { new SortControl("",
                 Control.NONCRITICAL) });
 
@@ -325,6 +329,140 @@
         context.getAttributes("cn=test");
 
         referralServer.stop();
+    }
+
+    public void testAddToEnvironment() throws Exception {
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+
+        assertNull(env.get(Context.REFERRAL));
+
+        InitialDirContext initialDirContext = new InitialDirContext(env);
+
+        // Context.REFERRAL changed doesn't cause re-bind operation
+        initialDirContext.addToEnvironment(Context.REFERRAL, "ignore");
+
+        assertEquals("ignore", initialDirContext.getEnvironment().get(
+                Context.REFERRAL));
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_DEL_RESPONSE, new EncodableLdapResult(),
+                null) });
+
+        initialDirContext.destroySubcontext("cn=test");
+
+        /*
+         * Context.SECURITY_AUTHENTICATION will case re-bind when invoke context
+         * methods at first time
+         */
+        Object preValue = initialDirContext.addToEnvironment(
+                Context.SECURITY_AUTHENTICATION, "none");
+        assertFalse("none".equals(preValue));
+
+        server.setResponseSeq(new LdapMessage[] {
+                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
+                        new BindResponse(), null),
+                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                        new EncodableLdapResult(), null) });
+
+        initialDirContext.lookup("");
+
+        preValue = initialDirContext.addToEnvironment(
+                Context.SECURITY_AUTHENTICATION, "simple");
+        assertFalse("simple".equals(preValue));
+
+        // initialDirContext is shared connection, will create new connection
+        server = new MockLdapServer(server);
+        server.start();
+        server.setResponseSeq(new LdapMessage[] {
+                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
+                        new BindResponse(), null),
+                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                        new EncodableLdapResult(), null) });
+
+        initialDirContext.lookup("");
+
+    }
+
+    public void testReconnect() throws Exception {
+        Control[] expected = new Control[] { new PagedResultsControl(10,
+                Control.NONCRITICAL) };
+        env.put("java.naming.ldap.control.connect", expected);
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        LdapContext context = new InitialLdapContext(env, null);
+
+        Control[] controls = context.getConnectControls();
+        assertNotNull(controls);
+        assertNotSame(expected, controls);
+
+        Control c = controls[0];
+        assertTrue(c instanceof PagedResultsControl);
+        assertEquals(Control.NONCRITICAL, ((PagedResultsControl) c)
+                .isCritical());
+        assertEquals(expected[0], c);
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+
+        expected = new Control[] { new SortControl("", Control.NONCRITICAL) };
+        context.reconnect(expected);
+
+        controls = context.getConnectControls();
+        assertNotNull(controls);
+        assertEquals(1, controls.length);
+        c = controls[0];
+        assertTrue(c instanceof SortControl);
+        assertEquals(Control.NONCRITICAL, ((SortControl) c).isCritical());
+        assertNotSame(expected, controls);
+        assertEquals(expected[0], c);
+
+        expected[0] = new PagedResultsControl(10, Control.NONCRITICAL);
+        controls = context.getConnectControls();
+        assertNotNull(controls);
+        assertEquals(1, controls.length);
+        c = controls[0];
+        assertTrue(c instanceof SortControl);
+        assertEquals(Control.NONCRITICAL, ((SortControl) c).isCritical());
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        context.reconnect(null);
+
+        assertNull(context.getConnectControls());
+    }
+
+    public void testReconnect_share_connection() throws Exception {
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        LdapContext context = new InitialLdapContext(env, null);
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+
+        // doesn't create new connection
+        context.reconnect(null);
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                new EncodableLdapResult(), null) });
+        // another and context share the same connection now
+        LdapContext another = (LdapContext) context.lookup("");
+
+        MockLdapServer one = new MockLdapServer(server);
+        one.start();
+
+        one.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        // create new connection
+        context.reconnect(null);
+
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        // use original connection
+        another.reconnect(null);
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapUtilsTest.java Wed Apr  9 04:01:14 2008
@@ -17,10 +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;
 
@@ -85,11 +93,238 @@
         assertEquals("test", pair.getValue());
     }
 
-    private LdapResult getLdapResult(int errorCode, String message) {
-        LdapResult result = new LdapResult();
-        if (message == null) {
+    public void test_convertToRelativeName() throws Exception {
+        LdapName base = new LdapName("");
+        LdapName dn = new LdapName("cn=test,o=harmony");
+
+        LdapName relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals(dn, relative);
+
+        base = new LdapName("o=harmony");
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals(new LdapName("cn=test"), relative);
+
+        base = new LdapName("o=harmony");
+        dn = new LdapName("cn=test,o=apache,o=harmony");
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals(new LdapName("cn=test,o=apache"), relative);
+
+        base = new LdapName("o=harmony");
+        dn = new LdapName("o=harmony");
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals(new LdapName(""), relative);
+    }
+
+    public void test_convertToRelativeName_String() throws Exception {
+        String base = "";
+        String dn = "cn=test,o=harmony";
+
+        String relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals(dn, relative);
+
+        base = "o=harmony";
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals("cn=test", relative);
+
+        base = "o=harmony";
+        dn = "cn=test,o=apache,o=harmony";
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals("cn=test,o=apache", relative);
+
+        base = "o=harmony";
+        dn = "o=harmony";
+        relative = LdapUtils.convertToRelativeName(dn, base);
+        assertEquals("", relative);
+    }
+
+    public void test_convertToRelativeName_String_Exception() throws Exception {
+        String base = "cn=test,o=harmony";
+        String dn = "";
+
+        try {
+            LdapUtils.convertToRelativeName(dn, base);
+            fail("Should throw NamingException");
+        } catch (NamingException e) {
+            // expected
+        }
+
+        base = "o=harmony";
+        dn = "cn=test,o=apache";
+
+        try {
+            LdapUtils.convertToRelativeName(dn, base);
+            fail("Should throw NamingException");
+        } catch (NamingException e) {
+            // expected
+        }
+        try {
+            LdapUtils.convertToRelativeName("o+harmony", "");
+            fail("Should throw InvalidNameException");
+        } catch (InvalidNameException e) {
+            // expected
+        }
+    }
+
+    public void test_convertToRelativeName_Exception() throws Exception {
+        LdapName base = new LdapName("cn=test,o=harmony");
+        LdapName dn = new LdapName("");
+
+        try {
+            LdapUtils.convertToRelativeName(dn, base);
+            fail("Should throw NamingException");
+        } catch (NamingException e) {
+            // expected
+        }
+
+        base = new LdapName("o=harmony");
+        dn = new LdapName("cn=test,o=apache");
+
+        try {
+            LdapUtils.convertToRelativeName(dn, base);
+            fail("Should throw NamingException");
+        } 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();
         Object[] values = new Object[] { ASN1Integer.fromIntValue(errorCode),
                 Utils.getBytes(""), Utils.getBytes(message), null };
         result.decodeValues(values);

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/MockLdapClient.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/MockLdapClient.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/MockLdapClient.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/MockLdapClient.java Wed Apr  9 04:01:14 2008
@@ -86,6 +86,16 @@
         request = op;
     }
 
+    @Override
+    public void use() {
+        // do nothing
+    }
+
+    @Override
+    public void unuse() {
+        // do nothing
+    }
+
     public ASN1Encodable getRequest() {
         return request;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java Wed Apr  9 04:01:14 2008
@@ -30,7 +30,7 @@
 public class ReferralExceptionTest extends TestCase {
 	private MockLdapServer server;
 
-	public void setUp() {
+	public void setUp() throws Exception {
 		server = new MockLdapServer();
 		server.start();
 	}

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextTest.java Wed Apr  9 04:01:14 2008
@@ -34,7 +34,7 @@
     private MockLdapServer server;
 
     @Override
-    public void setUp() {
+    public void setUp() throws Exception {
         server = new MockLdapServer();
         server.start();
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java Wed Apr  9 04:01:14 2008
@@ -51,15 +51,19 @@
 
     private static int DEFAULT_PORT = 1024;
 
-    public void start() {
-        port = DEFAULT_PORT;
-        while (true) {
-            try {
-                server = new ServerSocket(port);
-                break;
-            } catch (IOException e) {
-                ++port;
-            }
+    public MockLdapServer() {
+        // do nothing
+    }
+
+    public MockLdapServer(MockLdapServer mockServer) {
+        this.server = mockServer.server;
+        port = mockServer.port;
+    }
+
+    public void start() throws IOException {
+        if (server == null) {
+            server = new ServerSocket(0);
+            port = server.getLocalPort();
         }
 
         isStopped = false;

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java Wed Apr  9 04:01:14 2008
@@ -968,7 +968,8 @@
 		assertNameEquals(name.getSuffix(0), "a", "b", "c");
 		assertNameEquals(name.getSuffix(1), "b", "c");
 		assertNameEquals(name.getSuffix(2), "c");
-		// assertNameEmpty(name.getSuffix(3)); // worth debate
+        // Follow spec: If posn is equal to size(), an empty compound name is returned.
+        assertNameEmpty(name.getSuffix(3));
 		try {
 			name.getPrefix(-1);
 			fail();

Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml Wed Apr  9 04:01:14 2008
@@ -88,7 +88,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.lang-management.packaging.jarname}.jar"
-             manifest="${hy.lang-management}/META-INF/MANIFEST.MF">
+             manifest="${hy.lang-management}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}" />

Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/lang-management/src/main/java/java/lang/management/MemoryUsage.java Wed Apr  9 04:01:14 2008
@@ -111,7 +111,9 @@
 
     @Override
     public String toString() {
-        return "MemoryUsage: init=" + init + "used=" + used + "committed=" + committed + "max="
-                + max;
+        return "init = " + init + " (" + (init >> 10)
+          + "K) used = " + used + " (" + (used >> 10)
+          + "K) committed = " + committed + " (" + (committed >> 10)
+          + "K) max = " + max + " (" + (max >> 10) + "K)";
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/logging/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/logging/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/logging/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/logging/build.xml Wed Apr  9 04:01:14 2008
@@ -90,7 +90,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/logging.jar"
-             manifest="${hy.logging}/META-INF/MANIFEST.MF">
+             manifest="${hy.logging}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/build.xml Wed Apr  9 04:01:14 2008
@@ -281,7 +281,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/luni.jar"
-             manifest="${hy.luni}/META-INF/MANIFEST.MF">
+             manifest="${hy.luni}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/>

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectInputStream.java Wed Apr  9 04:01:14 2008
@@ -27,7 +27,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Iterator;
 
 import org.apache.harmony.kernel.vm.VM;
@@ -49,7 +49,7 @@
 public class ObjectInputStream extends InputStream implements ObjectInput,
         ObjectStreamConstants {
 
-    private static InputStream emptyStream = new ByteArrayInputStream(
+    private InputStream emptyStream = new ByteArrayInputStream(
             new byte[0]);
 
     // To put into objectsRead when reading unsharedObject
@@ -81,7 +81,7 @@
     private boolean enableResolve;
 
     // Table mapping Integer (handle) -> Object
-    private Hashtable<Integer, Object> objectsRead;
+    private HashMap<Integer, Object> objectsRead;
 
     // Used by defaultReadObject
     private Object currentObject;
@@ -105,7 +105,8 @@
     // Handle for the current class descriptor
     private Integer descriptorHandle;
 
-    private static final Hashtable<String, Class<?>> PRIMITIVE_CLASSES = new Hashtable<String, Class<?>>();
+    private static final HashMap<String, Class<?>> PRIMITIVE_CLASSES =
+        new HashMap<String, Class<?>>();
 
     static {
         PRIMITIVE_CLASSES.put("byte", byte.class); //$NON-NLS-1$
@@ -2358,7 +2359,7 @@
      * Reset the collection of objects already loaded by the receiver.
      */
     private void resetSeenObjects() {
-        objectsRead = new Hashtable<Integer, Object>();
+        objectsRead = new HashMap<Integer, Object>();
         currentHandle = baseWireHandle;
         primitiveData = emptyStream;
     }
@@ -2390,14 +2391,23 @@
      */
     protected Class<?> resolveClass(ObjectStreamClass osClass)
             throws IOException, ClassNotFoundException {
-        String className = osClass.getName();
-        // if it is primitive class, for example, long.class
-        Class<?> cls = PRIMITIVE_CLASSES.get(className);
+        // fastpath: obtain cached value
+        Class<?> cls = osClass.forClass();
         if (null == cls) {
-            // not primitive class
-            // Use the first non-null ClassLoader on the stack. If null, use the
-            // system class loader
-            return Class.forName(className, true, callerClassLoader);
+            // slowpath: resolve the class
+            String className = osClass.getName();
+
+            // if it is primitive class, for example, long.class
+            cls = PRIMITIVE_CLASSES.get(className);
+
+            if (null == cls) {
+                // not primitive class
+                // Use the first non-null ClassLoader on the stack. If null, use
+                // the system class loader
+                cls = Class.forName(className, true, callerClassLoader);
+                // save the value
+                osClass.setClass(cls);
+            }
         }
         return cls;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ResourceBundle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ResourceBundle.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ResourceBundle.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ResourceBundle.java Wed Apr  9 04:01:14 2008
@@ -26,6 +26,7 @@
 import java.security.PrivilegedAction;
 
 import org.apache.harmony.kernel.vm.VM;
+import org.apache.harmony.luni.util.Msg;
 
 /**
  * ResourceBundle is an abstract class which is the superclass of classes which
@@ -143,7 +144,7 @@
                     + Locale.getDefault(), true, loader)) != null) {
                 return bundle;
             }
-            throw new MissingResourceException(null, bundleName + '_' + locale,
+            throw new MissingResourceException(Msg.getString("KA029", bundleName, locale), bundleName + '_' + locale, //$NON-NLS-1$
                     EMPTY_STRING);
         }
         throw new NullPointerException();
@@ -347,7 +348,7 @@
             if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null) {
                 return bundle;
             }
-            throw new MissingResourceException(null, bundleName + '_' + locale,
+            throw new MissingResourceException(Msg.getString("KA029", bundleName, locale), bundleName + '_' + locale, //$NON-NLS-1$
                     EMPTY_STRING);
         }
         throw new NullPointerException();
@@ -389,7 +390,7 @@
             last = theParent;
             theParent = theParent.parent;
         } while (theParent != null);
-        throw new MissingResourceException(null, last.getClass().getName(), key);
+        throw new MissingResourceException(Msg.getString("KA029", last.getClass().getName(), key), last.getClass().getName(), key); //$NON-NLS-1$
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Wed Apr  9 04:01:14 2008
@@ -321,3 +321,4 @@
 KA026=JAR entry {0} not found in {1}
 KA027=Inputstream of the JarURLConnection has been closed
 KA028=Cannot set protocol version when stream in use
+KA029=Can't find resource for bundle {0}, key {1}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c Wed Apr  9 04:01:14 2008
@@ -47,7 +47,7 @@
 #define HARMONY_JARRUNNER_CLASSNAME  "org.apache.harmony.vm.JarRunner"
 
 #if defined(WIN32)
-#define PLATFORM_STRNICMP strnicmp
+#define PLATFORM_STRNICMP _strnicmp
 #endif
 
 #if defined(LINUX) || defined(FREEBSD) || defined(AIX) || defined(MACOSX) || defined(ZOS)

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c Wed Apr  9 04:01:14 2008
@@ -423,7 +423,6 @@
 {
   PORT_ACCESS_FROM_ENV(env);
   jbyte *message;
-  I_32 sent = 0;
   jint result = 0;
 
 /* TODO: ARRAY PINNING */
@@ -750,7 +749,6 @@
   char message[MSGLEN];
 
   I_32 result, flags = 0;
-  I_32 loopFlag = 1;
 
   hysocketP = getJavaIoFileDescriptorContentsAsAPointer(env, fileDescriptor);
   if (!hysock_socketIsValid(hysocketP)) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c Wed Apr  9 04:01:14 2008
@@ -283,13 +283,10 @@
 platformReadLink (char *link)
 {
 
-  int size = readlink (link, link, HyMaxPath);
+  int size = readlink (link, link, HyMaxPath-1);
   if (size <= 0)
     return FALSE;
-  if (size >= HyMaxPath)
-    link[HyMaxPath - 1] = 0;
-  else
-    link[size] = 0;
+  link[size] = 0;
   return TRUE;
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c Wed Apr  9 04:01:14 2008
@@ -37,6 +37,8 @@
 
 #include "procimpl.h"
 
+int setCloseOnExec(int fd);
+
 void
 sleepFor(unsigned int nanoseconds)
 {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java Wed Apr  9 04:01:14 2008
@@ -73,6 +73,38 @@
     private static final Control DEFAULT_CONTROL = Control
             .getControl(FORMAT_DEFAULT);
 
+    /**
+     * @tests java.util.ResourceBundle#getString(java.lang.String)
+     */
+    public void test_getStringLjava_lang_String() {
+        ResourceBundle bundle;
+        String name = "tests.support.Support_TestResource";
+        Locale.setDefault(new Locale("en", "US"));
+        bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
+        assertEquals("Wrong value parent4", "frFRVARValue4", bundle
+                .getString("parent4"));
+        assertEquals("Wrong value parent3", "frFRValue3", bundle
+                .getString("parent3"));
+        assertEquals("Wrong value parent2", "frValue2", bundle
+                .getString("parent2"));
+        assertEquals("Wrong value parent1", "parentValue1", bundle
+                .getString("parent1"));
+        assertEquals("Wrong value child3", "frFRVARChildValue3", bundle
+                .getString("child3"));
+        assertEquals("Wrong value child2", "frFRVARChildValue2", bundle
+                .getString("child2"));
+        assertEquals("Wrong value child1", "frFRVARChildValue1", bundle
+                .getString("child1"));
+
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist");
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
+    }
+
     @SuppressWarnings("nls")
     private static final Locale LOCALE_FRFR = new Locale("fr", "FR");
 
@@ -124,6 +156,14 @@
         assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle
                 .getString("parent4"));
 
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist", Locale.getDefault());
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
+
         // Test with a security manager
         Locale.setDefault(new Locale("en", "US"));
         System.setSecurityManager(new SecurityManager());
@@ -162,11 +202,50 @@
         assertEquals("Wrong cached value", "en_resource", bundle
                 .getString("property"));
 
+        String classPath = System.getProperty("java.class.path");
+        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
+        Vector urlVec = new Vector();
+        String resPackage = Support_Resources.RESOURCE_PACKAGE;
+        try {
+            while (tok.hasMoreTokens()) {
+                String path = (String) tok.nextToken();
+                String url;
+                if (new File(path).isDirectory())
+                    url = "file:" + path + resPackage + "subfolder/";
+                else
+                    url = "jar:file:" + path + "!" + resPackage + "subfolder/";
+                urlVec.addElement(new URL(url));
+            }
+        } catch (MalformedURLException e) {
+        }
+        URL[] urls = new URL[urlVec.size()];
+        for (int i = 0; i < urlVec.size(); i++)
+            urls[i] = (URL) urlVec.elementAt(i);
+        URLClassLoader loader = new URLClassLoader(urls, null);
+
+        String name = Support_Resources.RESOURCE_PACKAGE_NAME
+                + ".hyts_resource";
+        ResourceBundle bundle = ResourceBundle.getBundle(name, Locale
+                .getDefault());
+        assertEquals("Wrong value read", "parent", bundle.getString("property"));
+        bundle = ResourceBundle.getBundle(name, Locale.getDefault(), loader);
+        assertEquals("Wrong cached value", "resource", bundle
+                .getString("property"));
+
         // Regression test for Harmony-3823
         B bb = new B();
         String s = bb.find("nonexistent");
         s = bb.find("name");
         assertEquals("Wrong property got", "Name", s);
+
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist", Locale.getDefault(),
+                    loader);
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
     }
 
     @SuppressWarnings("nls")
@@ -207,32 +286,23 @@
     }
 
     /**
-     * @tests java.util.ResourceBundle#getString(java.lang.String)
+     * @tests java.util.ResourceBundle#getObject(java.lang.String)
      */
-    @SuppressWarnings("nls")
-    public void test_getStringLjava_lang_String() {
-        bundle = ResourceBundle.getBundle(CLASS_NAME, new Locale("fr", "FR",
-                "VAR"));
-        assertEquals("Wrong value parent4", "frFRVARValue4", bundle
-                .getString("parent4"));
-        assertEquals("Wrong value parent3", "frFRValue3", bundle
-                .getString("parent3"));
-        assertEquals("Wrong value parent2", "frValue2", bundle
-                .getString("parent2"));
-        assertEquals("Wrong value parent1", "parentValue1", bundle
-                .getString("parent1"));
-        assertEquals("Wrong value child3", "frFRVARChildValue3", bundle
-                .getString("child3"));
-        assertEquals("Wrong value child2", "frFRVARChildValue2", bundle
-                .getString("child2"));
-        assertEquals("Wrong value child1", "frFRVARChildValue1", bundle
-                .getString("child1"));
+    public void test_getObjectLjava_lang_String() {
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle bundle;
+            String name = "tests.support.Support_TestResource";
+            Locale.setDefault(new Locale("en", "US"));
+            bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR",
+                    "VAR"));
+            bundle.getObject("not exist");
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
     }
 
-    /**
-     * @tests {@link java.util.ResourceBundle#getBundle(String, Locale, ClassLoader)}
-     */
-    @SuppressWarnings("nls")
     public void test_getBundle_getClassName() {
         // Regression test for Harmony-1759
         Locale locale = Locale.GERMAN;

Modified: harmony/enhanced/classlib/branches/java6/modules/math/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/math/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/math/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/math/build.xml Wed Apr  9 04:01:14 2008
@@ -99,7 +99,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/math.jar"
-             manifest="${hy.math}/META-INF/MANIFEST.MF">
+             manifest="${hy.math}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/misc/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/misc/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/misc/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/misc/build.xml Wed Apr  9 04:01:14 2008
@@ -101,7 +101,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.misc.packaging.jarname}.jar"
-             manifest="${hy.misc}/META-INF/MANIFEST.MF">
+             manifest="${hy.misc}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/build.xml Wed Apr  9 04:01:14 2008
@@ -142,7 +142,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
-             manifest="${hy.nio}/META-INF/MANIFEST.MF">
+             manifest="${hy.nio}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}" />

Modified: harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio_char/build.xml Wed Apr  9 04:01:14 2008
@@ -121,7 +121,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.nio_char.packaging.jarname}.jar"
-             manifest="${hy.nio_char}/META-INF/MANIFEST.MF">
+             manifest="${hy.nio_char}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <metainf prefix="META-INF/services"
                 dir="${hy.nio_char.src.main.java}/org/apache/harmony/niochar"
                 includes="java.nio.charset.spi.CharsetProvider"/>



Mime
View raw message