harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r498561 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/CompoundName.java test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
Date Mon, 22 Jan 2007 09:13:18 GMT
Author: ayza
Date: Mon Jan 22 01:13:15 2007
New Revision: 498561

URL: http://svn.apache.org/viewvc?view=rev&rev=498561
Log:
Committing the patch from HARMONY-1171 ([classlib][jndi] no InvalidNameException for CompoundName.addAll())

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java?view=diff&rev=498561&r1=498560&r2=498561
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
Mon Jan 22 01:13:15 2007
@@ -627,9 +627,17 @@
     }
 
     public Name addAll(int index, Name name) throws InvalidNameException {
+        if (name == null) {
+            // jndi.00=name must not be null
+            throw new NullPointerException(Messages.getString("jndi.00")); //$NON-NLS-1$
+        }
         if (!(name instanceof CompoundName)) {
             // jndi.09={0} is not a compound name.
             throw new InvalidNameException(Messages.getString("jndi.09", name.toString()));
 //$NON-NLS-1$
+        }
+        if (FLAT.equals(direction) && (this.size() + name.size() > 1)) {
+            // jndi.0A=A flat name can only have a single component
+            throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$
         }
         validateIndex(index, true);
         Enumeration<String> enumeration = name.getAll();

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java?view=diff&rev=498561&r1=498560&r2=498561
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
Mon Jan 22 01:13:15 2007
@@ -1031,6 +1031,19 @@
 		}
 	}
 
+	public void testAddAll_Flat() throws InvalidNameException {
+		log.setMethod("testAddAll_Flat()");
+		CompoundName name;
+
+		name = new CompoundName("aaa", new Properties());
+		try {
+			name.addAll(new CompoundName("bbb", new Properties()));
+			fail("should throw InvalidNameException");
+		} catch (InvalidNameException e) {
+			// Expected
+		}
+	}
+
 	public void testAddAll_Indexed() throws InvalidNameException {
 		log.setMethod("testAddAll_Indexed()");
 		CompoundName name;



Mime
View raw message