harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r699281 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/ test/java/org/apache/harmony/jndi/tests/javax/naming/
Date Fri, 26 Sep 2008 11:31:25 GMT
Author: tellison
Date: Fri Sep 26 04:31:25 2008
New Revision: 699281

URL: http://svn.apache.org/viewvc?rev=699281&view=rev
Log:
Apply modified version of patch for HARMONY-5990 ([classlib][jndi] - the return string of
Reference.toString() should be same with RI)


Added:
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java?rev=699281&r1=699280&r2=699281&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java Fri
Sep 26 04:31:25 2008
@@ -114,11 +114,7 @@
     @SuppressWarnings("nls")
     @Override
     public String toString() {
-        return "The type of the address is: "
-                + this.addrType
-                + "\nThe content of the address is: "
-                + (null == this.getContent() ? "null" : this.getContent()
-                        .toString()) + "\n";
+        return "Type: " + addrType + "\nContent: " + getContent() + "\n";
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java?rev=699281&r1=699280&r2=699281&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
Fri Sep 26 04:31:25 2008
@@ -337,16 +337,18 @@
      * 
      * @return the string representation of this object
      */
+    @SuppressWarnings("nls")
     @Override
     public String toString() {
-        String s = "Reference class name: " + this.className; //$NON-NLS-1$
-        Enumeration<RefAddr> e = this.addrs.elements();
+        StringBuilder s = new StringBuilder("Reference Class Name: ");
+        s.append(className);
+        s.append("\n");
 
-        s += "\nReference addresses:"; //$NON-NLS-1$
+        Enumeration<RefAddr> e = this.addrs.elements();
         while (e.hasMoreElements()) {
-            s += "\n\t" + e.nextElement(); //$NON-NLS-1$
+            s.append(e.nextElement());
         }
-        return s + "\n"; //$NON-NLS-1$
+        return s.toString();
     }
 
 }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java?rev=699281&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java
Fri Sep 26 04:31:25 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.jndi.tests.javax.naming;
+
+import javax.naming.RefAddr;
+
+import junit.framework.TestCase;
+
+public class RefAddrTest extends TestCase {
+    public static class MockRefAddr extends RefAddr {
+
+        private String contents;
+
+        public MockRefAddr(String type, String address) {
+            super(type);
+            this.contents = address;
+        }
+
+        @Override
+        public Object getContent() {
+            return contents;
+        }
+
+    }
+
+    public void testToString_Simple() {
+        MockRefAddr addr = new MockRefAddr("type", "contents");
+
+        assertNotNull(addr.toString());
+        assertEquals("Type: " + addr.getType() + "\nContent: "
+                + addr.getContent() + "\n", addr.toString());
+    }
+
+    public void testToString_AddressNull() {
+        MockRefAddr addr = new MockRefAddr("type", null);
+
+        assertNotNull(addr.toString());
+        assertEquals("Type: " + addr.getType() + "\nContent: null\n", addr
+                .toString());
+    }
+
+    public void testToString_TypeNull() {
+        MockRefAddr addr = new MockRefAddr(null, "contents");
+
+        assertNotNull(addr.toString());
+        assertEquals("Type: null\nContent: " + addr.getContent() + "\n", addr
+                .toString());
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/RefAddrTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java?rev=699281&r1=699280&r2=699281&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
Fri Sep 26 04:31:25 2008
@@ -500,7 +500,9 @@
 		 * "\n", reference.toString());
 		 */
 		assertNotNull(reference.toString());
-	}
+        assertEquals("Reference Class Name: " + reference.getClassName() + "\n"
+                + addr0.toString() + addr1.toString(), reference.toString());
+    }
 
 	public void testToString_AddressNull() {
 		String className = "java.lang.String";
@@ -510,7 +512,10 @@
 		 * addresses:\n", reference.toString());
 		 */
 		assertNotNull(reference.toString());
-	}
+        assertEquals(
+                "Reference Class Name: " + reference.getClassName() + "\n",
+                reference.toString());
+    }
 
 	public void testClone_Simple() {
 		String className = "java.lang.String";



Mime
View raw message