harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r724594 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests: internal/net/www/protocol/http/ java/lang/ java/net/ java/util/
Date Tue, 09 Dec 2008 03:39:40 GMT
Author: qiuxx
Date: Mon Dec  8 19:39:39 2008
New Revision: 724594

URL: http://svn.apache.org/viewvc?rev=724594&view=rev
Log:
Apply for HARMONY-6012,([class] [luni] Add several test cases to luni module.)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=724594&r1=724593&r2=724594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
Mon Dec  8 19:39:39 2008
@@ -317,6 +317,23 @@
     }
 
     /**
+     * Test whether getOutputStream can work after connection
+     */
+    public void test_getOutputStream_AfterConnect() throws Exception {
+        URL url = new URL("http://www.apache.org");
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setDoOutput(true);
+        connection.connect();
+        String str_get = connection.getRequestMethod();
+        assertTrue(str_get.equalsIgnoreCase("GET"));
+
+        // call to getOutputStream should implicitly set req. method to POST
+        connection.getOutputStream();
+        String str_post = connection.getRequestMethod();
+        assertTrue(str_post.equalsIgnoreCase("POST"));
+    }
+
+    /**
      * Test checks if the proxy specified in openConnection method will be used
      * for connection to the server
      */

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=724594&r1=724593&r2=724594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
Mon Dec  8 19:39:39 2008
@@ -485,6 +485,25 @@
         assertEquals(expected[0], bytes[0]);
         assertEquals(expected[1], bytes[1]);
     }
+    
+    /*
+     * @tests java.lang.String#getBytes()
+     */
+    public void test_getBytes_NPE() throws Exception {
+        try {
+            "abc".getBytes((String) null);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        try {
+            "Hello World".getBytes(1, 2, null, 1);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
 
     /**
      * @tests java.lang.String#getChars(int, int, char[], int)

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java?rev=724594&r1=724593&r2=724594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
Mon Dec  8 19:39:39 2008
@@ -619,6 +619,26 @@
 
 	}
 
+    /*
+     * @tests java.lang.ThreadGroupt#setDaemon(boolean)
+     */
+    public void test_setDaemon_Parent_Child() {
+        ThreadGroup ptg = new ThreadGroup("Parent");
+        ThreadGroup ctg = new ThreadGroup(ptg, "Child");
+
+        ctg.setDaemon(true);
+        assertTrue(ctg.isDaemon());
+
+        ctg.setDaemon(false);
+        assertFalse(ctg.isDaemon());
+
+        ptg.setDaemon(true);
+        assertFalse(ctg.isDaemon());
+
+        ptg.setDaemon(false);
+        assertFalse(ctg.isDaemon());
+    }
+
 	/**
 	 * @tests java.lang.ThreadGroup#setMaxPriority(int)
 	 */

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java?rev=724594&r1=724593&r2=724594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
Mon Dec  8 19:39:39 2008
@@ -389,6 +389,35 @@
     }
 
     /**
+     * @tests java.net.InetAddress#getLocalHost()
+     */
+    public void test_getLocalHost_extended() throws Exception {
+        class Inet_SecurityManager extends SecurityManager {
+            @Override
+            public void checkConnect(String host, int port) {
+                super.checkConnect(host, port);
+                throw new SecurityException();
+            }
+        }
+
+        // Bogus, but we don't know the host name or ip of the machine
+        // running the test, so we can't build our own address
+        DatagramSocket dg = new DatagramSocket(0, InetAddress.getLocalHost());
+        assertEquals("Incorrect host returned", InetAddress.getLocalHost(), dg
+                .getLocalAddress());
+        dg.close();
+
+        SecurityManager oldman = System.getSecurityManager();
+        try {
+            System.setSecurityManager(new Inet_SecurityManager());
+            assertTrue("Host address should be a loop back address",
+                    InetAddress.getLocalHost().isLoopbackAddress());
+        } finally {
+            System.setSecurityManager(oldman);
+        }
+    }
+    
+    /**
      * @tests java.net.InetAddress#hashCode()
      */
     public void test_hashCode() {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java?rev=724594&r1=724593&r2=724594&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
Mon Dec  8 19:39:39 2008
@@ -230,6 +230,34 @@
 
     }
 
+    /*
+     * the class and constructor must be public so ResourceBundle has the
+     * possibility to instantiate
+     */
+    public static class GetBundleTest {
+        public GetBundleTest() {
+            // Try to load a resource with the same name as the class.
+            // getBundle() should not try to instantiate the class since
+            // its not a ResourceBundle. If a .properties file exists it
+            // would be loaded.
+            ResourceBundle
+                    .getBundle("org.apache.harmony.luni.tests.java.util.ResourceBundleTest$GetBundleTest");
+        }
+    };
+
+    /**
+     * @tests java.util.ResourceBundle#getBundle(java.lang.String)
+     */
+    public void test_getBundleLjava_lang_String() {
+        /* ResourceBundle.getBundle recursion loading class name */
+        try {
+            new GetBundleTest();
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            // expected
+        }
+    }
+
 	protected void setUp() {
 	}
 



Mime
View raw message