harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r426492 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
Date Fri, 28 Jul 2006 12:46:24 GMT
Author: smishura
Date: Fri Jul 28 05:46:23 2006
New Revision: 426492

URL: http://svn.apache.org/viewvc?rev=426492&view=rev
Log:
Fix test case to make ObjectOutputStreamTest pass on RI

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java?rev=426492&r1=426491&r2=426492&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
Fri Jul 28 05:46:23 2006
@@ -31,6 +31,8 @@
 import java.io.ObjectStreamField;
 import java.io.OutputStream;
 import java.io.Serializable;
+import java.io.SerializablePermission;
+import java.security.Permission;
 import java.util.Arrays;
 
 public class ObjectOutputStreamTest extends junit.framework.TestCase implements
@@ -507,7 +509,22 @@
 	 * @tests java.io.ObjectOutputStream#ObjectOutputStream(java.io.OutputStream)
 	 */
 	public void test_ConstructorLjava_io_OutputStream_subtest0() throws IOException {
-		System.setSecurityManager(new SecurityManager());
+
+		// custom security manager
+		SecurityManager sm = new SecurityManager() {
+
+			final SerializablePermission forbidenPermission =
+				new SerializablePermission("enableSubclassImplementation");
+
+			public void checkPermission(Permission perm) {
+				if (forbidenPermission.equals(perm)) {
+					throw new SecurityException();
+				}
+			}
+		};
+
+		SecurityManager oldSm = System.getSecurityManager();
+		System.setSecurityManager(sm);
 		try {
 			ByteArrayOutputStream out = new ByteArrayOutputStream();
 			// should not cause SecurityException
@@ -551,7 +568,7 @@
 			} catch (SecurityException e) {
 			}
 		} finally {
-			System.setSecurityManager(null);
+			System.setSecurityManager(oldSm);
 		}
 	}
 



Mime
View raw message