harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r526037 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang: IllegalArgumentExceptionTest.java ProcessBuilderTest.java SecurityExceptionTest.java StringBufferTest.java StringTest.java
Date Fri, 06 Apr 2007 02:45:09 GMT
Author: pyang
Date: Thu Apr  5 19:45:08 2007
New Revision: 526037

URL: http://svn.apache.org/viewvc?view=rev&rev=526037
Log:
Apply patch for HARMONAY-3580([classlib][luni] Add some test cases)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java?view=diff&rev=526037&r1=526036&r2=526037
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
Thu Apr  5 19:45:08 2007
@@ -41,6 +41,18 @@
         assertEquals("fixture", e.getMessage());
         assertNull(e.getCause());
 	}
+    
+    /**
+     * @tests java.lang.IllegalArgumentException#IllegalArgumentException(String,Throwable)
+     */
+    @SuppressWarnings("nls")
+    public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
+        NullPointerException npe = new NullPointerException();
+        IllegalArgumentException e = new IllegalArgumentException("fixture",
+                npe);
+        assertSame("fixture", e.getMessage());
+        assertSame(npe, e.getCause());
+    }
 
     /**
      * @tests serialization/deserialization.

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java?view=diff&rev=526037&r1=526036&r2=526037
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
Thu Apr  5 19:45:08 2007
@@ -17,6 +17,8 @@
 package org.apache.harmony.luni.tests.java.lang;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -138,6 +140,25 @@
         assertTrue(pb.redirectErrorStream());
     }
 
-    public void testStart() {
+    /**
+     * @throws IOException
+     * @tests {@link java.lang.ProcessBuilder#start()}
+     */
+    @SuppressWarnings("nls")
+    public void testStart() throws IOException {
+        ProcessBuilder pb = new ProcessBuilder("java", "-version");
+        pb.directory(new File(System.getProperty("java.home") + File.separator
+                + "bin"));
+
+        // Call the test target
+        Process process = pb.start();
+        InputStream in = process.getInputStream();
+        InputStream err = process.getErrorStream();
+        byte[] buf = new byte[1024];
+        if (in.available() > 0) {
+            assertTrue(in.read(buf) > 0);
+        } else {
+            assertTrue(err.read(buf) > 0);
+        }
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java?view=diff&rev=526037&r1=526036&r2=526037
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
Thu Apr  5 19:45:08 2007
@@ -41,6 +41,27 @@
         assertEquals("fixture", e.getMessage());
         assertNull(e.getCause());
     }
+    
+    /**
+     * @tests java.lang.SecurityException#SecurityException(String, Throwable)
+     */
+    @SuppressWarnings("nls")
+    public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
+        NullPointerException npe = new NullPointerException();
+        SecurityException e = new SecurityException("fixture", npe);
+        assertSame("fixture", e.getMessage());
+        assertSame(npe, e.getCause());
+    }
+
+    /**
+     * @tests java.lang.SecurityException#SecurityException(Throwable)
+     */
+    @SuppressWarnings("nls")
+    public void test_ConstructorLjava_lang_Throwable() {
+        NullPointerException npe = new NullPointerException();
+        SecurityException e = new SecurityException(npe);
+        assertSame(npe, e.getCause());
+    }
 
     /**
      * @tests serialization/deserialization.

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java?view=diff&rev=526037&r1=526036&r2=526037
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
Thu Apr  5 19:45:08 2007
@@ -457,6 +457,66 @@
             
         }
     }
+    
+    /**
+     * @tests {@link java.lang.StringBuffer#indexOf(String, int)}
+     */
+    @SuppressWarnings("nls")
+    public void test_IndexOfStringInt() {
+        final String fixture = "0123456789";
+        StringBuffer sb = new StringBuffer(fixture);
+        assertEquals(0, sb.indexOf("0"));
+        assertEquals(0, sb.indexOf("012"));
+        assertEquals(-1, sb.indexOf("02"));
+        assertEquals(8, sb.indexOf("89"));
+
+        assertEquals(0, sb.indexOf("0"), 0);
+        assertEquals(0, sb.indexOf("012"), 0);
+        assertEquals(-1, sb.indexOf("02"), 0);
+        assertEquals(8, sb.indexOf("89"), 0);
+
+        assertEquals(-1, sb.indexOf("0"), 5);
+        assertEquals(-1, sb.indexOf("012"), 5);
+        assertEquals(-1, sb.indexOf("02"), 0);
+        assertEquals(8, sb.indexOf("89"), 5);
+
+        try {
+            sb.indexOf(null, 0);
+            fail("Should throw a NullPointerExceptionE");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests {@link java.lang.StringBuffer#lastIndexOf(String, int)}
+     */
+    @SuppressWarnings("nls")
+    public void test_lastIndexOfLjava_lang_StringI() {
+        final String fixture = "0123456789";
+        StringBuffer sb = new StringBuffer(fixture);
+        assertEquals(0, sb.lastIndexOf("0"));
+        assertEquals(0, sb.lastIndexOf("012"));
+        assertEquals(-1, sb.lastIndexOf("02"));
+        assertEquals(8, sb.lastIndexOf("89"));
+
+        assertEquals(0, sb.lastIndexOf("0"), 0);
+        assertEquals(0, sb.lastIndexOf("012"), 0);
+        assertEquals(-1, sb.lastIndexOf("02"), 0);
+        assertEquals(8, sb.lastIndexOf("89"), 0);
+
+        assertEquals(-1, sb.lastIndexOf("0"), 5);
+        assertEquals(-1, sb.lastIndexOf("012"), 5);
+        assertEquals(-1, sb.lastIndexOf("02"), 0);
+        assertEquals(8, sb.lastIndexOf("89"), 5);
+
+        try {
+            sb.lastIndexOf(null, 0);
+            fail("Should throw a NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
 
     // comparator for StringBuffer objects
     private static final SerializableAssert STRING_BUFFER_COMPARATOR = new SerializableAssert()
{

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java?view=diff&rev=526037&r1=526036&r2=526037
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
Thu Apr  5 19:45:08 2007
@@ -248,6 +248,29 @@
         } catch (NullPointerException e) {
         }
     }
+    
+    /**
+     * @tests java.lang.String#contentEquals(StringBuffer)
+     */
+    @SuppressWarnings("nls")
+    public void test_boolean_contentEquals_StringBuffer() {
+        String s = "abc";
+        assertTrue(s.contentEquals(new StringBuffer("abc")));
+        assertFalse(s.contentEquals(new StringBuffer("def")));
+        assertFalse(s.contentEquals(new StringBuffer("ghij")));
+
+        s = newString(1, 3, "_abc_".toCharArray());
+        assertTrue(s.contentEquals(new StringBuffer("abc")));
+        assertFalse(s.contentEquals(new StringBuffer("def")));
+        assertFalse(s.contentEquals(new StringBuffer("ghij")));
+
+        try {
+            s.contentEquals((StringBuffer) null);
+            fail("Should throw a NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
 
     /**
      * @tests java.lang.String#contains(CharSequence)



Mime
View raw message