You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/08/29 07:40:47 UTC
svn commit: r437974 [12/19] -
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java Mon Aug 28 22:40:44 2006
@@ -1,44 +1,44 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-public class OutOfMemoryErrorTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.OutOfMemoryError#OutOfMemoryError()
- */
- public void test_Constructor() {
- // Test for method java.lang.OutOfMemoryError()
- Error e = new OutOfMemoryError();
- assertEquals(null, e.getCause());
- assertEquals(null, e.getMessage());
- }
-
- /**
- * @tests java.lang.OutOfMemoryError#OutOfMemoryError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.OutOfMemoryError(java.lang.String)
- Error e = new OutOfMemoryError(null);
- assertEquals(null, e.getMessage());
- assertEquals(null, e.getCause());
-
- e= new OutOfMemoryError("msg");
- assertEquals("msg", e.getMessage());
- assertEquals(null, e.getCause());
- }
-
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+public class OutOfMemoryErrorTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.lang.OutOfMemoryError#OutOfMemoryError()
+ */
+ public void test_Constructor() {
+ // Test for method java.lang.OutOfMemoryError()
+ Error e = new OutOfMemoryError();
+ assertEquals(null, e.getCause());
+ assertEquals(null, e.getMessage());
+ }
+
+ /**
+ * @tests java.lang.OutOfMemoryError#OutOfMemoryError(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method java.lang.OutOfMemoryError(java.lang.String)
+ Error e = new OutOfMemoryError(null);
+ assertEquals(null, e.getMessage());
+ assertEquals(null, e.getCause());
+
+ e= new OutOfMemoryError("msg");
+ assertEquals("msg", e.getMessage());
+ assertEquals(null, e.getCause());
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java Mon Aug 28 22:40:44 2006
@@ -1,427 +1,427 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.URL;
-
-import tests.support.resource.Support_Resources;
-
-public class PackageTest extends junit.framework.TestCase {
-
- private File resources;
-
- private String resPath;
-
- /**
- * There is a newer version of this class with some actual tests but since
- * the class is not implemented they all fail. For now use the stub test
- * methods.
- */
-
- /**
- * @tests java.lang.Package#getImplementationVendor()
- * @tests java.lang.Package#getImplementationVersion()
- * @tests java.lang.Package#getSpecificationTitle()
- * @tests java.lang.Package#getSpecificationVendor()
- * @tests java.lang.Package#getSpecificationVersion()
- * @tests java.lang.Package#getImplementationTitle()
- */
- public void test_helper_Attributes() {
-
- // All attributes in the package entry
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package",
- "hyts_all_attributes.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_all_attributes.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertEquals("Package getImplementationTitle returns a wrong string (1)",
-
- "p Implementation-Title", c.getPackage().getImplementationTitle());
- assertEquals("Package getImplementationVendor returns a wrong string (1)",
-
- "p Implementation-Vendor", c.getPackage().getImplementationVendor());
- assertEquals("Package getImplementationVersion returns a wrong string (1)",
- "2.2.2", c.getPackage().getImplementationVersion());
- assertEquals("Package getSpecificationTitle returns a wrong string (1)",
-
- "p Specification-Title", c.getPackage().getSpecificationTitle());
- assertEquals("Package getSpecificationVendor returns a wrong string (1)",
-
- "p Specification-Vendor", c.getPackage().getSpecificationVendor());
- assertEquals("Package getSpecificationVersion returns a wrong string (1)",
- "2.2.2", c.getPackage().getSpecificationVersion());
- } catch (Exception e) {
- fail("Exception during helperAttributes test : " + e.getMessage());
- }
-
- // No entry for the package
- Support_Resources.copyFile(resources, "Package", "hyts_no_entry.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_no_entry.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertEquals("Package getImplementationTitle returns a wrong string (2)",
-
- "MF Implementation-Title", c.getPackage().getImplementationTitle());
- assertEquals("Package getImplementationVendor returns a wrong string (2)",
-
- "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
- assertEquals("Package getImplementationVersion returns a wrong string (2)",
- "5.3.b1", c.getPackage().getImplementationVersion());
- assertEquals("Package getSpecificationTitle returns a wrong string (2)",
-
- "MF Specification-Title", c.getPackage().getSpecificationTitle());
- assertEquals("Package getSpecificationVendor returns a wrong string (2)",
-
- "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
- assertEquals("Package getSpecificationVersion returns a wrong string (2)",
- "1.2.3", c.getPackage().getSpecificationVersion());
- } catch (Exception e) {
- fail("Exception in helperAttributes test : " + e.getMessage());
- }
-
- // No attributes in the package entry
- Support_Resources.copyFile(resources, "Package",
- "hyts_no_attributes.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_no_attributes.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertEquals("Package getImplementationTitle returns a wrong string (3)",
-
- "MF Implementation-Title", c.getPackage().getImplementationTitle());
- assertEquals("Package getImplementationVendor returns a wrong string (3)",
-
- "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
- assertEquals("Package getImplementationVersion returns a wrong string (3)",
- "5.3.b1", c.getPackage().getImplementationVersion());
- assertEquals("Package getSpecificationTitle returns a wrong string (3)",
-
- "MF Specification-Title", c.getPackage().getSpecificationTitle());
- assertEquals("Package getSpecificationVendor returns a wrong string (3)",
-
- "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
- assertEquals("Package getSpecificationVersion returns a wrong string (3)",
- "1.2.3", c.getPackage().getSpecificationVersion());
- } catch (Exception e) {
- fail("Exception during helperAttributes test : " + e.getMessage());
- }
-
- // Some attributes in the package entry
- Support_Resources.copyFile(resources, "Package",
- "hyts_some_attributes.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_some_attributes.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertEquals("Package getImplementationTitle returns a wrong string (4)",
-
- "p Implementation-Title", c.getPackage().getImplementationTitle());
- assertEquals("Package getImplementationVendor returns a wrong string (4)",
-
- "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
- assertEquals("Package getImplementationVersion returns a wrong string (4)",
- "2.2.2", c.getPackage().getImplementationVersion());
- assertEquals("Package getSpecificationTitle returns a wrong string (4)",
-
- "MF Specification-Title", c.getPackage().getSpecificationTitle());
- assertEquals("Package getSpecificationVendor returns a wrong string (4)",
-
- "p Specification-Vendor", c.getPackage().getSpecificationVendor());
- assertEquals("Package getSpecificationVersion returns a wrong string (4)",
- "2.2.2", c.getPackage().getSpecificationVersion());
- } catch (Exception e) {
- fail("Exception during helperAttributes test : " + e.getMessage());
- }
-
- // subdirectory Package
- Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_pq.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.q.C", true, ucl);
- assertEquals("Package getImplementationTitle returns a wrong string (5)",
-
- "p Implementation-Title", c.getPackage().getImplementationTitle());
- assertEquals("Package getImplementationVendor returns a wrong string (5)",
-
- "p Implementation-Vendor", c.getPackage().getImplementationVendor());
- assertEquals("Package getImplementationVersion returns a wrong string (5)",
- "1.1.3", c.getPackage().getImplementationVersion());
- assertEquals("Package getSpecificationTitle returns a wrong string (5)",
-
- "p Specification-Title", c.getPackage().getSpecificationTitle());
- assertEquals("Package getSpecificationVendor returns a wrong string (5)",
-
- "p Specification-Vendor", c.getPackage().getSpecificationVendor());
- assertEquals("Package getSpecificationVersion returns a wrong string (5)",
-
- "2.2.0.0.0.0.0.0.0.0.0", c.getPackage().getSpecificationVersion());
-
- } catch (Exception e) {
- fail("Exception during helperAttributes test : " + e.getMessage());
- }
- }
-
- private static Object invokeMethod(Object obj, String name,
- Object[] parameters) {
-
- Class[] types = new Class[parameters.length];
- for (int i = 0; i < parameters.length; i++) {
- types[i] = parameters[i].getClass();
- }
- Class c = null;
- if (obj instanceof Class)
- c = (Class) obj;
- else
- c = obj.getClass();
- while (c != null) {
- try {
- Method m = c.getDeclaredMethod(name, types);
- m.setAccessible(true);
- return m.invoke(obj, parameters);
- } catch (NoSuchMethodException e) {
- c = c.getSuperclass();
- } catch (Exception e) {
- break;
- }
- }
- return null;
- }
-
- /**
- * @tests java.lang.Package#getName()
- */
- public void test_getName() {
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_pq.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.q.C", true, ucl);
- assertEquals("Package getName returns a wrong string", "p.q", c.getPackage()
- .getName());
-
- } catch (Exception e) {
- fail("Exception during getName test : " + e.getMessage());
- }
-
- }
-
- /**
- * @tests java.lang.Package#getPackage(java.lang.String)
- */
- public void test_getPackageLjava_lang_String() {
- // Test for method java.lang.Package
- // java.lang.Package.getPackage(java.lang.String)
- Package.getPackage("java.lang");
- try {
- assertTrue("Package getPackage failed for java.lang", Package
- .getPackage("java.lang") == java.lang.Object.class
- .getPackage());
- } catch (Exception e) {
- fail("Unexpected exception " + e
- + " in Package.getPackage(java.lang.String)");
- }
-
- }
-
- /**
- * @tests java.lang.Package#getPackages()
- */
- public void test_getPackages() {
- // Test for method java.lang.Package [] java.lang.Package.getPackages()
- java.net.URL[] urls = new java.net.URL[1];
-
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_pq.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- Class.forName("p.q.C", true, ucl);
- Package[] pckgs = (Package[]) invokeMethod(ucl, "getPackages",
- new Object[0]);
- boolean found = false;
- for (int i = 0; i < pckgs.length; i++)
- if (pckgs[i].getName().equals("p.q")) {
- found = true;
- break;
- }
- assertTrue("Package getPackages failed to retrieve a package",
- found);
- } catch (Exception e) {
- fail("Unexpected exception " + e
- + " in Package.getPackages()");
- }
- }
-
- /**
- * @tests java.lang.Package#hashCode()
- */
- public void test_hashCode() {
- // Test for method int java.lang.Package.hashCode()
- Package p1 = Package.getPackage("java.lang");
- Package p2 = Package.getPackage("java.lang");
- if (p1 != null)
- assertTrue(
- "Package hashCode does not return the same hashcode for 2 packages with the same name",
- p1.hashCode() == p2.hashCode());
- }
-
- /**
- * @tests java.lang.Package#isCompatibleWith(java.lang.String)
- */
- public void test_isCompatibleWithLjava_lang_String() {
- // Test for method boolean
- // java.lang.Package.isCompatibleWith(java.lang.String)
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_c.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- Package p = c.getPackage();
- assertTrue("Package isCompatibleWith fails with lower version", p
- .isCompatibleWith("2.1.9.") == true);
- assertTrue("Package isCompatibleWith fails with same version (1)",
- p.isCompatibleWith("2.2.0") == true);
- assertTrue("Package isCompatibleWith fails with same version (2)",
- p.isCompatibleWith("2.2") == true);
- assertTrue("Package isCompatibleWith fails with higher version", p
- .isCompatibleWith("2.2.0.0.1") == false);
- } catch (Exception e) {
- fail("Exception during isCompatibleWith test : " + e.getMessage());
- }
- }
-
- /**
- * @tests java.lang.Package#isSealed()
- */
- public void test_isSealed() {
- // Test for method boolean java.lang.Package.isSealed()
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_pq.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.q.C", true, ucl);
- assertTrue("Package isSealed returns wrong boolean", c.getPackage()
- .isSealed() == true);
-
- } catch (Exception e) {
- fail("Exception during isSealed test : " + e.getMessage());
- }
-
- }
-
- /**
- * @tests java.lang.Package#isSealed(java.net.URL)
- */
- public void test_isSealedLjava_net_URL() {
- // Test for method boolean java.lang.Package.isSealed(java.net.URL)
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_c.jar");
- urls[0] = resourceURL;
- ucl = new java.net.URLClassLoader(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertTrue(
- "Package isSealed returns wrong boolean (1)",
- c.getPackage().isSealed(new URL("file:/" + resPath + "/")) == false);
- assertTrue("Package isSealed returns wrong boolean (2)",
- c.getPackage()
- .isSealed(
- new URL("file:/" + resPath
- + "/Package/hyts_c.jar")) == true);
- } catch (Exception e) {
- fail("Exception during isSealed test : " + e.getMessage());
- }
- }
-
- /**
- * @tests java.lang.Package#toString()
- */
- public void test_toString() {
- // Test for method java.lang.String java.lang.Package.toString()
- java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
- java.net.URLClassLoader ucl = null;
- Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
- try {
- java.net.URL resourceURL = new URL("file:/" + resPath
- + "/Package/hyts_c.jar");
- urls[0] = resourceURL;
- ucl = java.net.URLClassLoader.newInstance(urls, null);
- c = Class.forName("p.C", true, ucl);
- assertTrue("Package toString returns wrong string", c.getPackage()
- .toString().length() > 0);
- } catch (Exception e) {
- fail("Exception during isSealed test : " + e.getMessage());
- }
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- resources = Support_Resources.createTempFolder();
- resPath = resources.toString();
- if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\')
- resPath = resPath.substring(1);
-
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import tests.support.resource.Support_Resources;
+
+public class PackageTest extends junit.framework.TestCase {
+
+ private File resources;
+
+ private String resPath;
+
+ /**
+ * There is a newer version of this class with some actual tests but since
+ * the class is not implemented they all fail. For now use the stub test
+ * methods.
+ */
+
+ /**
+ * @tests java.lang.Package#getImplementationVendor()
+ * @tests java.lang.Package#getImplementationVersion()
+ * @tests java.lang.Package#getSpecificationTitle()
+ * @tests java.lang.Package#getSpecificationVendor()
+ * @tests java.lang.Package#getSpecificationVersion()
+ * @tests java.lang.Package#getImplementationTitle()
+ */
+ public void test_helper_Attributes() {
+
+ // All attributes in the package entry
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package",
+ "hyts_all_attributes.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_all_attributes.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertEquals("Package getImplementationTitle returns a wrong string (1)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (1)",
+
+ "p Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (1)",
+ "2.2.2", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (1)",
+
+ "p Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (1)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (1)",
+ "2.2.2", c.getPackage().getSpecificationVersion());
+ } catch (Exception e) {
+ fail("Exception during helperAttributes test : " + e.getMessage());
+ }
+
+ // No entry for the package
+ Support_Resources.copyFile(resources, "Package", "hyts_no_entry.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_no_entry.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertEquals("Package getImplementationTitle returns a wrong string (2)",
+
+ "MF Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (2)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (2)",
+ "5.3.b1", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (2)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (2)",
+
+ "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (2)",
+ "1.2.3", c.getPackage().getSpecificationVersion());
+ } catch (Exception e) {
+ fail("Exception in helperAttributes test : " + e.getMessage());
+ }
+
+ // No attributes in the package entry
+ Support_Resources.copyFile(resources, "Package",
+ "hyts_no_attributes.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_no_attributes.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertEquals("Package getImplementationTitle returns a wrong string (3)",
+
+ "MF Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (3)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (3)",
+ "5.3.b1", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (3)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (3)",
+
+ "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (3)",
+ "1.2.3", c.getPackage().getSpecificationVersion());
+ } catch (Exception e) {
+ fail("Exception during helperAttributes test : " + e.getMessage());
+ }
+
+ // Some attributes in the package entry
+ Support_Resources.copyFile(resources, "Package",
+ "hyts_some_attributes.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_some_attributes.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertEquals("Package getImplementationTitle returns a wrong string (4)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (4)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (4)",
+ "2.2.2", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (4)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (4)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (4)",
+ "2.2.2", c.getPackage().getSpecificationVersion());
+ } catch (Exception e) {
+ fail("Exception during helperAttributes test : " + e.getMessage());
+ }
+
+ // subdirectory Package
+ Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_pq.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.q.C", true, ucl);
+ assertEquals("Package getImplementationTitle returns a wrong string (5)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (5)",
+
+ "p Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (5)",
+ "1.1.3", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (5)",
+
+ "p Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (5)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (5)",
+
+ "2.2.0.0.0.0.0.0.0.0.0", c.getPackage().getSpecificationVersion());
+
+ } catch (Exception e) {
+ fail("Exception during helperAttributes test : " + e.getMessage());
+ }
+ }
+
+ private static Object invokeMethod(Object obj, String name,
+ Object[] parameters) {
+
+ Class[] types = new Class[parameters.length];
+ for (int i = 0; i < parameters.length; i++) {
+ types[i] = parameters[i].getClass();
+ }
+ Class c = null;
+ if (obj instanceof Class)
+ c = (Class) obj;
+ else
+ c = obj.getClass();
+ while (c != null) {
+ try {
+ Method m = c.getDeclaredMethod(name, types);
+ m.setAccessible(true);
+ return m.invoke(obj, parameters);
+ } catch (NoSuchMethodException e) {
+ c = c.getSuperclass();
+ } catch (Exception e) {
+ break;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @tests java.lang.Package#getName()
+ */
+ public void test_getName() {
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_pq.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.q.C", true, ucl);
+ assertEquals("Package getName returns a wrong string", "p.q", c.getPackage()
+ .getName());
+
+ } catch (Exception e) {
+ fail("Exception during getName test : " + e.getMessage());
+ }
+
+ }
+
+ /**
+ * @tests java.lang.Package#getPackage(java.lang.String)
+ */
+ public void test_getPackageLjava_lang_String() {
+ // Test for method java.lang.Package
+ // java.lang.Package.getPackage(java.lang.String)
+ Package.getPackage("java.lang");
+ try {
+ assertTrue("Package getPackage failed for java.lang", Package
+ .getPackage("java.lang") == java.lang.Object.class
+ .getPackage());
+ } catch (Exception e) {
+ fail("Unexpected exception " + e
+ + " in Package.getPackage(java.lang.String)");
+ }
+
+ }
+
+ /**
+ * @tests java.lang.Package#getPackages()
+ */
+ public void test_getPackages() {
+ // Test for method java.lang.Package [] java.lang.Package.getPackages()
+ java.net.URL[] urls = new java.net.URL[1];
+
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_pq.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ Class.forName("p.q.C", true, ucl);
+ Package[] pckgs = (Package[]) invokeMethod(ucl, "getPackages",
+ new Object[0]);
+ boolean found = false;
+ for (int i = 0; i < pckgs.length; i++)
+ if (pckgs[i].getName().equals("p.q")) {
+ found = true;
+ break;
+ }
+ assertTrue("Package getPackages failed to retrieve a package",
+ found);
+ } catch (Exception e) {
+ fail("Unexpected exception " + e
+ + " in Package.getPackages()");
+ }
+ }
+
+ /**
+ * @tests java.lang.Package#hashCode()
+ */
+ public void test_hashCode() {
+ // Test for method int java.lang.Package.hashCode()
+ Package p1 = Package.getPackage("java.lang");
+ Package p2 = Package.getPackage("java.lang");
+ if (p1 != null)
+ assertTrue(
+ "Package hashCode does not return the same hashcode for 2 packages with the same name",
+ p1.hashCode() == p2.hashCode());
+ }
+
+ /**
+ * @tests java.lang.Package#isCompatibleWith(java.lang.String)
+ */
+ public void test_isCompatibleWithLjava_lang_String() {
+ // Test for method boolean
+ // java.lang.Package.isCompatibleWith(java.lang.String)
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_c.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ Package p = c.getPackage();
+ assertTrue("Package isCompatibleWith fails with lower version", p
+ .isCompatibleWith("2.1.9.") == true);
+ assertTrue("Package isCompatibleWith fails with same version (1)",
+ p.isCompatibleWith("2.2.0") == true);
+ assertTrue("Package isCompatibleWith fails with same version (2)",
+ p.isCompatibleWith("2.2") == true);
+ assertTrue("Package isCompatibleWith fails with higher version", p
+ .isCompatibleWith("2.2.0.0.1") == false);
+ } catch (Exception e) {
+ fail("Exception during isCompatibleWith test : " + e.getMessage());
+ }
+ }
+
+ /**
+ * @tests java.lang.Package#isSealed()
+ */
+ public void test_isSealed() {
+ // Test for method boolean java.lang.Package.isSealed()
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_pq.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_pq.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.q.C", true, ucl);
+ assertTrue("Package isSealed returns wrong boolean", c.getPackage()
+ .isSealed() == true);
+
+ } catch (Exception e) {
+ fail("Exception during isSealed test : " + e.getMessage());
+ }
+
+ }
+
+ /**
+ * @tests java.lang.Package#isSealed(java.net.URL)
+ */
+ public void test_isSealedLjava_net_URL() {
+ // Test for method boolean java.lang.Package.isSealed(java.net.URL)
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_c.jar");
+ urls[0] = resourceURL;
+ ucl = new java.net.URLClassLoader(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertTrue(
+ "Package isSealed returns wrong boolean (1)",
+ c.getPackage().isSealed(new URL("file:/" + resPath + "/")) == false);
+ assertTrue("Package isSealed returns wrong boolean (2)",
+ c.getPackage()
+ .isSealed(
+ new URL("file:/" + resPath
+ + "/Package/hyts_c.jar")) == true);
+ } catch (Exception e) {
+ fail("Exception during isSealed test : " + e.getMessage());
+ }
+ }
+
+ /**
+ * @tests java.lang.Package#toString()
+ */
+ public void test_toString() {
+ // Test for method java.lang.String java.lang.Package.toString()
+ java.net.URL[] urls = new java.net.URL[1];
+ Class c = null;
+ java.net.URLClassLoader ucl = null;
+ Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
+ try {
+ java.net.URL resourceURL = new URL("file:/" + resPath
+ + "/Package/hyts_c.jar");
+ urls[0] = resourceURL;
+ ucl = java.net.URLClassLoader.newInstance(urls, null);
+ c = Class.forName("p.C", true, ucl);
+ assertTrue("Package toString returns wrong string", c.getPackage()
+ .toString().length() > 0);
+ } catch (Exception e) {
+ fail("Exception during isSealed test : " + e.getMessage());
+ }
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ resources = Support_Resources.createTempFolder();
+ resPath = resources.toString();
+ if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\')
+ resPath = resPath.substring(1);
+
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class RuntimeExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.RuntimeException#RuntimeException()
- */
- public void test_Constructor() {
- RuntimeException e = new RuntimeException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.RuntimeException#RuntimeException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- RuntimeException e = new RuntimeException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+import junit.framework.TestCase;
+
+public class RuntimeExceptionTest extends TestCase {
+
+ /**
+ * @tests java.lang.RuntimeException#RuntimeException()
+ */
+ public void test_Constructor() {
+ RuntimeException e = new RuntimeException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
+
+ /**
+ * @tests java.lang.RuntimeException#RuntimeException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ RuntimeException e = new RuntimeException("fixture");
+ assertEquals("fixture", e.getMessage());
+ assertNull(e.getCause());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java Mon Aug 28 22:40:44 2006
@@ -1,56 +1,56 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-public class RuntimePermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader");
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
-
- }
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String,
- // java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader", null);
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+public class RuntimePermissionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method java.lang.RuntimePermission(java.lang.String)
+ RuntimePermission r = new RuntimePermission("createClassLoader");
+ assertEquals("Returned incorrect name",
+ "createClassLoader", r.getName());
+
+ }
+
+ /**
+ * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String,
+ * java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+ // Test for method java.lang.RuntimePermission(java.lang.String,
+ // java.lang.String)
+ RuntimePermission r = new RuntimePermission("createClassLoader", null);
+ assertEquals("Returned incorrect name",
+ "createClassLoader", r.getName());
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java Mon Aug 28 22:40:44 2006
@@ -1,171 +1,171 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Vector;
-
-public class RuntimeTest extends junit.framework.TestCase {
-
- Runtime r = Runtime.getRuntime();
-
- InputStream is;
-
- String s;
-
- static boolean flag = false;
-
- static boolean ranFinalize = false;
-
- class HasFinalizer {
- String internalString;
-
- HasFinalizer(String s) {
- internalString = s;
- }
-
- protected void finalize() {
- internalString = "hit";
- }
- }
-
- protected void finalize() {
- if (flag)
- ranFinalize = true;
- }
-
- protected RuntimeTest createInstance() {
- return new RuntimeTest("FT");
- }
-
- /**
- * @tests java.lang.Runtime#exit(int)
- */
- public void test_exitI() {
- // Test for method void java.lang.Runtime.exit(int)
- assertTrue("Can't really test this", true);
- }
-
- /**
- * @tests java.lang.Runtime#exec(java.lang.String)
- */
- public void test_exec() {
- boolean success = false;
-
- /* successful exec's are tested by java.lang.Process */
- try {
- Runtime.getRuntime().exec("AnInexistentProgram");
- } catch (IOException e) {
- success = true;
- }
- assertTrue(
- "failed to throw IOException when exec'ed inexistent program",
- success);
- }
-
- /**
- * @tests java.lang.Runtime#freeMemory()
- */
- public void test_freeMemory() {
- // Test for method long java.lang.Runtime.freeMemory()
- assertTrue("freeMemory returned nonsense value", r.freeMemory() > 0);
- }
-
- /**
- * @tests java.lang.Runtime#gc()
- */
- public void test_gc() {
- // Test for method void java.lang.Runtime.gc()
- try {
- r.gc(); // ensure all garbage objects have been collected
- r.gc(); // two GCs force collection phase to complete
- long firstRead = r.totalMemory() - r.freeMemory();
- Vector v = new Vector();
- for (int i = 1; i < 10; i++)
- v.addElement(new StringBuffer(10000));
- long secondRead = r.totalMemory() - r.freeMemory();
- v = null;
- r.gc();
- r.gc();
- assertTrue("object memory did not grow", secondRead > firstRead);
- assertTrue("space was not reclaimed", (r.totalMemory() - r
- .freeMemory()) < secondRead);
- } catch (Throwable t) {
- System.out.println("Out of memory during freeMemory test");
- r.gc();
- r.gc();
- }
- }
-
- /**
- * @tests java.lang.Runtime#getRuntime()
- */
- public void test_getRuntime() {
- // Test for method java.lang.Runtime java.lang.Runtime.getRuntime()
- assertTrue("Used to test", true);
- }
-
- /**
- * @tests java.lang.Runtime#runFinalization()
- */
- public void test_runFinalization() {
- // Test for method void java.lang.Runtime.runFinalization()
-
- flag = true;
- createInstance();
- int count = 10;
- // the gc below likely bogosifies the test, but will have to do for
- // the moment
- while (!ranFinalize && count-- > 0) {
- r.gc();
- r.runFinalization();
- }
- assertTrue("Failed to run finalization", ranFinalize);
- }
-
- /**
- * @tests java.lang.Runtime#totalMemory()
- */
- public void test_totalMemory() {
- // Test for method long java.lang.Runtime.totalMemory()
- assertTrue("totalMemory returned nonsense value", r.totalMemory() >= r
- .freeMemory());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- flag = false;
- ranFinalize = false;
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-
- public RuntimeTest() {
- }
-
- public RuntimeTest(String name) {
- super(name);
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Vector;
+
+public class RuntimeTest extends junit.framework.TestCase {
+
+ Runtime r = Runtime.getRuntime();
+
+ InputStream is;
+
+ String s;
+
+ static boolean flag = false;
+
+ static boolean ranFinalize = false;
+
+ class HasFinalizer {
+ String internalString;
+
+ HasFinalizer(String s) {
+ internalString = s;
+ }
+
+ protected void finalize() {
+ internalString = "hit";
+ }
+ }
+
+ protected void finalize() {
+ if (flag)
+ ranFinalize = true;
+ }
+
+ protected RuntimeTest createInstance() {
+ return new RuntimeTest("FT");
+ }
+
+ /**
+ * @tests java.lang.Runtime#exit(int)
+ */
+ public void test_exitI() {
+ // Test for method void java.lang.Runtime.exit(int)
+ assertTrue("Can't really test this", true);
+ }
+
+ /**
+ * @tests java.lang.Runtime#exec(java.lang.String)
+ */
+ public void test_exec() {
+ boolean success = false;
+
+ /* successful exec's are tested by java.lang.Process */
+ try {
+ Runtime.getRuntime().exec("AnInexistentProgram");
+ } catch (IOException e) {
+ success = true;
+ }
+ assertTrue(
+ "failed to throw IOException when exec'ed inexistent program",
+ success);
+ }
+
+ /**
+ * @tests java.lang.Runtime#freeMemory()
+ */
+ public void test_freeMemory() {
+ // Test for method long java.lang.Runtime.freeMemory()
+ assertTrue("freeMemory returned nonsense value", r.freeMemory() > 0);
+ }
+
+ /**
+ * @tests java.lang.Runtime#gc()
+ */
+ public void test_gc() {
+ // Test for method void java.lang.Runtime.gc()
+ try {
+ r.gc(); // ensure all garbage objects have been collected
+ r.gc(); // two GCs force collection phase to complete
+ long firstRead = r.totalMemory() - r.freeMemory();
+ Vector v = new Vector();
+ for (int i = 1; i < 10; i++)
+ v.addElement(new StringBuffer(10000));
+ long secondRead = r.totalMemory() - r.freeMemory();
+ v = null;
+ r.gc();
+ r.gc();
+ assertTrue("object memory did not grow", secondRead > firstRead);
+ assertTrue("space was not reclaimed", (r.totalMemory() - r
+ .freeMemory()) < secondRead);
+ } catch (Throwable t) {
+ System.out.println("Out of memory during freeMemory test");
+ r.gc();
+ r.gc();
+ }
+ }
+
+ /**
+ * @tests java.lang.Runtime#getRuntime()
+ */
+ public void test_getRuntime() {
+ // Test for method java.lang.Runtime java.lang.Runtime.getRuntime()
+ assertTrue("Used to test", true);
+ }
+
+ /**
+ * @tests java.lang.Runtime#runFinalization()
+ */
+ public void test_runFinalization() {
+ // Test for method void java.lang.Runtime.runFinalization()
+
+ flag = true;
+ createInstance();
+ int count = 10;
+ // the gc below likely bogosifies the test, but will have to do for
+ // the moment
+ while (!ranFinalize && count-- > 0) {
+ r.gc();
+ r.runFinalization();
+ }
+ assertTrue("Failed to run finalization", ranFinalize);
+ }
+
+ /**
+ * @tests java.lang.Runtime#totalMemory()
+ */
+ public void test_totalMemory() {
+ // Test for method long java.lang.Runtime.totalMemory()
+ assertTrue("totalMemory returned nonsense value", r.totalMemory() >= r
+ .freeMemory());
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ flag = false;
+ ranFinalize = false;
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
+
+ public RuntimeTest() {
+ }
+
+ public RuntimeTest(String name) {
+ super(name);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,63 +1,63 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-import tests.util.SerializationTester;
-
-public class SecurityExceptionTest extends TestCase {
-
- private static final String SERIALIZATION_FILE_NAME =
- "serialization/java/lang/SecurityException.ser"; //$NON-NLS-1$
-
- /**
- * @tests java.lang.SecurityException#SecurityException()
- */
- public void test_Constructor() {
- SecurityException e = new SecurityException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.SecurityException#SecurityException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- SecurityException e = new SecurityException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests serialization/deserilazation.
- */
- public void test_serialization() throws Exception {
- SecurityException srcSecurityException = new SecurityException();
- SecurityException destSecurityException = (SecurityException) SerializationTester
- .getDeserilizedObject(srcSecurityException);
- }
-
- /**
- * @tests serialization/deserilazation compatibility with RI.
- */
- public void test_serializationCompatibility() throws Exception {
- SecurityException srcSecurityException = new SecurityException();
- SecurityException destSecurityException = (SecurityException) SerializationTester
- .readObject(srcSecurityException,
- SERIALIZATION_FILE_NAME);
- }
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+import junit.framework.TestCase;
+import tests.util.SerializationTester;
+
+public class SecurityExceptionTest extends TestCase {
+
+ private static final String SERIALIZATION_FILE_NAME =
+ "serialization/java/lang/SecurityException.ser"; //$NON-NLS-1$
+
+ /**
+ * @tests java.lang.SecurityException#SecurityException()
+ */
+ public void test_Constructor() {
+ SecurityException e = new SecurityException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
+
+ /**
+ * @tests java.lang.SecurityException#SecurityException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ SecurityException e = new SecurityException("fixture");
+ assertEquals("fixture", e.getMessage());
+ assertNull(e.getCause());
+ }
+
+ /**
+ * @tests serialization/deserilazation.
+ */
+ public void test_serialization() throws Exception {
+ SecurityException srcSecurityException = new SecurityException();
+ SecurityException destSecurityException = (SecurityException) SerializationTester
+ .getDeserilizedObject(srcSecurityException);
+ }
+
+ /**
+ * @tests serialization/deserilazation compatibility with RI.
+ */
+ public void test_serializationCompatibility() throws Exception {
+ SecurityException srcSecurityException = new SecurityException();
+ SecurityException destSecurityException = (SecurityException) SerializationTester
+ .readObject(srcSecurityException,
+ SERIALIZATION_FILE_NAME);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java Mon Aug 28 22:40:44 2006
@@ -1,80 +1,80 @@
-/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class SecurityManagerTest extends TestCase {
-
- /**
- * @tests java.lang.SecurityManager#checkMemberAccess(java.lang.Class, int)
- */
- public void test_checkMemberAccessLjava_lang_ClassI() {
- MutableSecurityManager sm = new MutableSecurityManager();
- sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
- System.setSecurityManager(sm);
- try {
- try {
- getClass().getDeclaredFields();
- } catch (SecurityException e) {
- fail("This should not throw a security exception");
- }
-
- try {
- Object.class.getDeclaredFields();
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- }
-
- } finally {
- System.setSecurityManager(null);
- }
- }
-
- /**
- * @tests java.lang.SecurityManager#checkPermission(java.security.Permission)
- */
- public void test_checkPermissionLjava_security_Permission() {
- MutableSecurityManager sm = new MutableSecurityManager();
- sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
- System.setSecurityManager(sm);
- try {
- try {
- System.getSecurityManager().checkPermission(
- new RuntimePermission("createClassLoader"));
- fail("This should throw a SecurityException");
- } catch (SecurityException e) {
- }
- } finally {
- System.setSecurityManager(null);
- }
- }
-
- /**
- * @tests java.lang.SecurityManager#checkAccess(java.lang.Thread)
- */
- public void test_checkAccessLjava_lang_Thread() throws InterruptedException {
- // Regression for HARMONY-66
- Thread t = new Thread() {
- @Override
- public void run() {
- };
- };
- t.start();
- t.join();
- new SecurityManager().checkAccess(t);
- }
-}
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.luni.tests.java.lang;
+
+import junit.framework.TestCase;
+
+public class SecurityManagerTest extends TestCase {
+
+ /**
+ * @tests java.lang.SecurityManager#checkMemberAccess(java.lang.Class, int)
+ */
+ public void test_checkMemberAccessLjava_lang_ClassI() {
+ MutableSecurityManager sm = new MutableSecurityManager();
+ sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
+ System.setSecurityManager(sm);
+ try {
+ try {
+ getClass().getDeclaredFields();
+ } catch (SecurityException e) {
+ fail("This should not throw a security exception");
+ }
+
+ try {
+ Object.class.getDeclaredFields();
+ fail("This should throw a SecurityException.");
+ } catch (SecurityException e) {
+ }
+
+ } finally {
+ System.setSecurityManager(null);
+ }
+ }
+
+ /**
+ * @tests java.lang.SecurityManager#checkPermission(java.security.Permission)
+ */
+ public void test_checkPermissionLjava_security_Permission() {
+ MutableSecurityManager sm = new MutableSecurityManager();
+ sm.addPermission(MutableSecurityManager.SET_SECURITY_MANAGER);
+ System.setSecurityManager(sm);
+ try {
+ try {
+ System.getSecurityManager().checkPermission(
+ new RuntimePermission("createClassLoader"));
+ fail("This should throw a SecurityException");
+ } catch (SecurityException e) {
+ }
+ } finally {
+ System.setSecurityManager(null);
+ }
+ }
+
+ /**
+ * @tests java.lang.SecurityManager#checkAccess(java.lang.Thread)
+ */
+ public void test_checkAccessLjava_lang_Thread() throws InterruptedException {
+ // Regression for HARMONY-66
+ Thread t = new Thread() {
+ @Override
+ public void run() {
+ };
+ };
+ t.start();
+ t.join();
+ new SecurityManager().checkAccess(t);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native