harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r495579 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/directory/ main/java/org/apache/harmony/jndi/internal/nls/ test/java/org/apache/harmony/jndi/tests/javax/naming/directory/
Date Fri, 12 Jan 2007 14:23:25 GMT
Author: ayza
Date: Fri Jan 12 06:23:24 2007
New Revision: 495579

URL: http://svn.apache.org/viewvc?view=rev&rev=495579
Log:
Applying patches from HARMONY-1232 ([classlib][jndi] compatibility: SearchResult(null, ...)
throws IllegalArgumentException on Harmony and creates object on RI)

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.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/directory/SearchResultTest.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java?view=diff&rev=495579&r1=495578&r2=495579
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java
Fri Jan 12 06:23:24 2007
@@ -19,6 +19,8 @@
 
 import javax.naming.Binding;
 
+import org.apache.harmony.jndi.internal.nls.Messages;
+
 /**
  * <code>SearchResult</code> returned from a search on a directory context
  * and is provided by a <code>NamingEnumeration</code>.
@@ -176,7 +178,13 @@
         Attributes attributes,
         boolean flag) {
         super(s, s1, o, flag);
-        this.attrs = attributes;
+
+        if (attributes == null) {
+            // jndi.8B=attrs must not be null
+            throw new IllegalArgumentException(Messages.getString("jndi.8B")); //$NON-NLS-1$
+        } else {
+            this.attrs = attributes;
+        }
     }
 
     /*
@@ -200,7 +208,12 @@
      * @param attributes	an attributes. It should not be null.	
      */
     public void setAttributes(Attributes attributes) {
-        attrs = attributes;
+        if (attributes == null) {
+            // jndi.8B=attrs must not be null
+            throw new IllegalArgumentException(Messages.getString("jndi.8B")); //$NON-NLS-1$
+        } else {
+            this.attrs = attributes;
+        }
     }
 
     /*
@@ -223,7 +236,5 @@
             .append(attrs.toString())
             .toString();
     }
-
 }
-
 

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=495579&r1=495578&r2=495579
==============================================================================
--- 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
Fri Jan 12 06:23:24 2007
@@ -154,5 +154,6 @@
 jndi.88=Interface hash mismatch, expected: {0}, received: {1}
 jndi.89=Error marshalling return
 jndi.8A=Invalid method number: {0}
+jndi.8B=attrs 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/directory/SearchResultTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/SearchResultTest.java?view=diff&rev=495579&r1=495578&r2=495579
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/SearchResultTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/SearchResultTest.java
Fri Jan 12 06:23:24 2007
@@ -26,6 +26,7 @@
 
 	static Log log = new Log(SearchResultTest.class);
 
+	BasicAttributes emptyAttrs = new BasicAttributes();
 	BasicAttributes attrs = new BasicAttributes("id_sample", "value_sample");
 
 	/*
@@ -36,11 +37,18 @@
 		SearchResult r;
 
 		r = new SearchResult("name", "obj", attrs);
-		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("name", r.getName());
+		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("obj", r.getObject());
 		assertEquals(attrs, r.getAttributes());
 		assertTrue(r.isRelative());
+
+		r = new SearchResult("name", null, attrs);
+		assertEquals("name", r.getName());
+		assertEquals(null, r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertTrue(r.isRelative());
 	}
 
 	/*
@@ -51,11 +59,18 @@
 		SearchResult r;
 
 		r = new SearchResult("name", "obj", attrs, false);
-		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("name", r.getName());
+		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("obj", r.getObject());
 		assertEquals(attrs, r.getAttributes());
 		assertFalse(r.isRelative());
+
+		r = new SearchResult("name", null, attrs, false);
+		assertEquals("name", r.getName());
+		assertEquals(null, r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertFalse(r.isRelative());
 	}
 
 	/*
@@ -66,11 +81,32 @@
 		SearchResult r;
 
 		r = new SearchResult("name", "classname", "obj", attrs);
+		assertEquals("name", r.getName());
 		assertEquals("classname", r.getClassName());
+		assertEquals("obj", r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertTrue(r.isRelative());
+
+		r = new SearchResult("name", null, "obj", attrs);
 		assertEquals("name", r.getName());
+		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("obj", r.getObject());
 		assertEquals(attrs, r.getAttributes());
 		assertTrue(r.isRelative());
+
+		r = new SearchResult("name", "classname", null, attrs);
+		assertEquals("name", r.getName());
+		assertEquals("classname", r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertTrue(r.isRelative());
+
+		r = new SearchResult("name", null, null, attrs);
+		assertEquals("name", r.getName());
+		assertEquals(null, r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertTrue(r.isRelative());
 	}
 
 	/*
@@ -81,21 +117,118 @@
 		SearchResult r;
 
 		r = new SearchResult("name", "classname", "obj", attrs, false);
+		assertEquals("name", r.getName());
 		assertEquals("classname", r.getClassName());
+		assertEquals("obj", r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertFalse(r.isRelative());
+
+		r = new SearchResult("name", null, "obj", attrs, false);
 		assertEquals("name", r.getName());
+		assertEquals("java.lang.String", r.getClassName());
 		assertEquals("obj", r.getObject());
 		assertEquals(attrs, r.getAttributes());
 		assertFalse(r.isRelative());
+
+		r = new SearchResult("name", "classname", null, attrs, false);
+		assertEquals("name", r.getName());
+		assertEquals("classname", r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertFalse(r.isRelative());
+
+		r = new SearchResult("name", null, null, attrs, false);
+		assertEquals("name", r.getName());
+		assertEquals(null, r.getClassName());
+		assertEquals(null, r.getObject());
+		assertEquals(attrs, r.getAttributes());
+		assertFalse(r.isRelative());
 	}
 
-	public void testSearchResult_NullAttributes() {
-		log.setMethod("testSearchResult_NullAttributes()");
+	public void testSearchResult_NullParameters() {
+		log.setMethod("testSearchResult_NullParameters()");
+
+		try {
+			new SearchResult(null, "obj", attrs);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult("name", "obj", null);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "obj", null);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "obj", attrs, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult("name", "obj", null, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "obj", null, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "classname", "obj", attrs);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult("name", "classname", "obj", null);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "classname", "obj", null);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult(null, "classname", "obj", attrs, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
+
+		try {
+			new SearchResult("name", "classname", "obj", null, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
+			// Expected, name cannot be null
+		}
 
 		try {
-			 new SearchResult(null, null, null);
-             fail("no illegal argument exception");
-		} 
-		catch (IllegalArgumentException e) {
+			new SearchResult(null, "classname", "obj", null, false);
+			fail("no illegal argument exception");
+		} catch (IllegalArgumentException e) {
 			// Expected, name cannot be null
 		}
 	}
@@ -104,8 +237,8 @@
 		log.setMethod("testGetterAndSetter()");
 		SearchResult r;
 
-		r = new SearchResult("name", "obj", null);
-		assertNull(r.getAttributes());
+		r = new SearchResult("name", "obj", emptyAttrs);
+		assertEquals(emptyAttrs, r.getAttributes());
 		r.setAttributes(attrs);
 		assertEquals(attrs, r.getAttributes());
 	}



Mime
View raw message