harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r498567 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/ main/java/org/apache/harmony/jndi/internal/nls/ test/java/org/apache/harmony/jndi/tests/javax/naming/
Date Mon, 22 Jan 2007 09:54:52 GMT
Author: ayza
Date: Mon Jan 22 01:54:51 2007
New Revision: 498567

URL: http://svn.apache.org/viewvc?view=rev&rev=498567
Log:
Applying patch from HARMONY-2525 ([classlib][jndi] javax.naming.CompoundName add(String),
add(int, String) methods should follow exception throwing compatibility) 

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
    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=498567&r1=498566&r2=498567
==============================================================================
--- 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:54:51 2007
@@ -649,6 +649,10 @@
 
     public Name add(String element) throws InvalidNameException {
         if (element == null) {
+            // jndi.8C=component must not be null
+            throw new IllegalArgumentException(Messages.getString("jndi.8C")); //$NON-NLS-1$
+        }
+        if (FLAT.equals(direction) && (size() > 0)) {
             // jndi.0A=A flat name can only have a single component
             throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$
         }
@@ -670,8 +674,12 @@
      */
     public Name add(int index, String element) throws InvalidNameException {
         if (element == null) {
-            // jndi.0B=A flat name can only zero or one component
-            throw new InvalidNameException(Messages.getString("jndi.0B")); //$NON-NLS-1$
+            // jndi.8C=component must not be null
+            throw new IllegalArgumentException(Messages.getString("jndi.8C")); //$NON-NLS-1$
+        }
+        if (FLAT.equals(direction) && (size() > 0)) {
+            // jndi.0A=A flat name can only have a single component
+            throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$
         }
         validateIndex(index, true);
         elem.add(index, element);

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties?view=diff&rev=498567&r1=498566&r2=498567
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
Mon Jan 22 01:54:51 2007
@@ -155,5 +155,6 @@
 jndi.89=Error marshalling return
 jndi.8A=Invalid method number: {0}
 jndi.8B=attrs must not be null
+jndi.8C=component must not be null
 
 jndi.err.00=. The stack trace of the root exception is: 

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=498567&r1=498566&r2=498567
==============================================================================
--- 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:54:51 2007
@@ -1108,17 +1108,35 @@
 		assertNameEquals(name, "a", "'<b>/'");
 		name.add("'c");
 		assertNameEquals(name, "a", "'<b>/'", "'c");
+
+        // regression for HARMONY-2525
+        name = new CompoundName("a", new Properties());
+		try {
+			name.add("b");
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
 	}
 
+    // regression for HARMONY-2525
 	public void testAdd_Null() throws InvalidNameException {
 		log.setMethod("testAdd_Null()");
 		CompoundName name;
 
-		name = new CompoundName("", props);
+        name = new CompoundName("", props);
 		try {
 			name.add(null);
-			fail("InvalidNameException expected");
-		} catch (InvalidNameException e) {
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException e) {
+			//expected
+		}
+
+		name = new CompoundName("", new Properties());
+		try {
+			name.add(null);
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException e) {
 			//expected
 		}
 	}
@@ -1139,23 +1157,47 @@
 			name.addAll(-1, new CompoundName("d", props));
 			fail();
 		} catch (ArrayIndexOutOfBoundsException e) {
+			//expected
 		}
 		try {
 			name.addAll(5, new CompoundName("d", props));
 			fail();
 		} catch (ArrayIndexOutOfBoundsException e) {
+			//expected
+		}
+
+        // regression for HARMONY-2525
+		name = new CompoundName("a", new Properties());
+		try {
+			name.add(0, "b");
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
+		try {
+			name.add(1, "b");
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
+		try {
+			name.add(-1, "b");
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
 		}
 	}
 
-	public void testAdd_Indexed_Null() throws InvalidNameException {
+    // regression for HARMONY-2525
+    public void testAdd_Indexed_Null() throws InvalidNameException {
 		log.setMethod("testAdd_Indexed_Null()");
 		CompoundName name;
 
 		name = new CompoundName("", props);
 		try {
 			name.add(0, null);
-			fail("InvalidNameException expected");
-		} catch (InvalidNameException e) {
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException e) {
 			//expected
 		}
 
@@ -1163,8 +1205,16 @@
 		name = new CompoundName("", props);
 		try {
 			name.add(11, null);
-			fail("InvalidNameException expected");
-		} catch (InvalidNameException e) {
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException e) {
+			//expected
+		}
+
+		name = new CompoundName("", new Properties());
+		try {
+			name.add(0, null);
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException e) {
 			//expected
 		}
 	}



Mime
View raw message