but an improvement.
Original author: jorgp
Merged from: //branches/cupcake/...
Original author: android-build
Automated import of CL 144836
method = "ClassLoader",
args = {java.lang.ClassLoader.class}
)
+ @BrokenTest("Infinite loop in classloader. Actually a known failure.")
public void test_ClassLoaderLClassLoader() {
PublicClassLoader pcl = new PublicClassLoader(
ClassLoader.getSystemClassLoader());
public void test_clearAssertionStatus() {
String className = getClass().getPackage().getName() + ".TestAssertions";
String className1 = getClass().getPackage().getName() + ".TestAssertions1";
- ClassLoader cl = ClassLoader.getSystemClassLoader();
+ ClassLoader cl = getClass().getClassLoader();
cl.setClassAssertionStatus("TestAssertions", true);
cl.setDefaultAssertionStatus(true);
try {
method = "loadClass",
args = {java.lang.String.class}
)
- @BrokenTest("Both threads try to define class. But defineClass is not " +
- "supported on Adnroid. so both seem to succeed defining the class.")
+ @BrokenTest("Defining classes not supported, unfortunately the test appears"
+ + " to succeed, which is not true, so marking it broken.")
public void test_loadClass_concurrentLoad() throws Exception
{
Object lock = new Object();
public void test_getResourceLjava_lang_String() {
// Test for method java.net.URL
// java.lang.ClassLoader.getResource(java.lang.String)
- java.net.URL u = ClassLoader.getSystemClassLoader().getResource("hyts_Foo.c");
+ java.net.URL u = getClass().getClassLoader().getResource("hyts_Foo.c");
assertNotNull("Unable to find resource", u);
java.io.InputStream is = null;
try {
- assertNull(ClassLoader.getSystemClassLoader().
- getResource("not.found.resource"));
+ assertNull(getClass().getClassLoader()
+ .getResource("not.found.resource"));
}
/**
// Need better test...
java.io.InputStream is = null;
- assertNotNull("Failed to find resource: HelloWorld.txt", (is = ClassLoader
- .getSystemClassLoader().getResourceAsStream("HelloWorld.txt")));
+ assertNotNull("Failed to find resource: HelloWorld.txt",
+ (is = getClass().getClassLoader()
+ .getResourceAsStream("HelloWorld.txt")));
byte [] array = new byte[13];
try {
// java.lang.ClassLoader.getSystemClassLoader()
ClassLoader cl = ClassLoader.getSystemClassLoader();
- java.io.InputStream is = cl.getResourceAsStream("hyts_Foo.c");
+ java.io.InputStream is = cl.getResourceAsStream("classes.dex");
assertNotNull("Failed to find resource from system classpath", is);
try {
is.close();
method = "getSystemResource",
args = {java.lang.String.class}
)
- public void test_getSystemResourceLjava_lang_String() {
+ @AndroidOnly("The RI doesn't have a classes.dex as resource in the "
+ + "core-tests.jar. Also on Android this file is the only one "
+ + "that is sure to exist.")
+ public void test_getSystemResourceLjava_lang_String() throws IOException {
// java.lang.ClassLoader.getSystemResource(java.lang.String)
// Need better test...
//assertNotNull("Failed to find resource: " + classResource,
// ClassLoader.getSystemResource(classResource));
- URL url = null;
- assertNotNull("Failed to find resource: HelloWorld.txt", (url = ClassLoader
- .getSystemClassLoader().getSystemResource("HelloWorld.txt")));
+ URL url = getClass().getClassLoader().getSystemResource("classes.dex");
+ assertNotNull("Failed to find resource: classes.dex", url);
+ java.io.InputStream is = url.openStream();
- byte [] array = new byte[13];
- InputStream is = null;
- try {
- is = url.openStream();
- is.read(array);
- } catch(IOException ioe) {
- fail("IOException was not thrown.");
- } finally {
- try {
- is.close();
- } catch(IOException ioe) {}
- }
-
- assertEquals("Hello, World.", new String(array));
+ assertTrue("System resource not found", is.available() > 0);
assertNull("Doesn't return null for unknown resource.",
- ClassLoader.getSystemClassLoader().getSystemResource("NotFound"));
+ getClass().getClassLoader().getSystemResource("NotFound"));
}
@TestTargetNew(
method = "getSystemResourceAsStream",
args = {java.lang.String.class}
)
- public void test_getSystemResourceAsStreamLjava_lang_String() {
+ @AndroidOnly("The RI doesn't have a classes.dex as resource in the "
+ + "core-tests.jar. Also on Android this file is the only one "
+ + "that is sure to exist.")
+ public void test_getSystemResourceAsStreamLjava_lang_String()
+ throws IOException {
//String classResource = getClass().getPackage().getName().replace(".", "/") + "/" +
// getClass().getSimpleName() + ".class";
//assertNotNull("Failed to find resource: " + classResource,
// ClassLoader.getSystemResourceAsStream(classResource));
- java.io.InputStream is = null;
- assertNotNull("Failed to find resource: HelloWorld.txt", (is = ClassLoader
- .getSystemClassLoader().getSystemResourceAsStream("HelloWorld.txt")));
-
- byte [] array = new byte[13];
- try {
- is.read(array);
- } catch(IOException ioe) {
- fail("IOException was not thrown.");
- } finally {
- try {
- is.close();
- } catch(IOException ioe) {}
- }
+ java.io.InputStream is = getClass().getClassLoader()
+ .getSystemResourceAsStream("classes.dex");
+ assertNotNull("Failed to find resource: classes.dex", is);
- assertEquals("Hello, World.", new String(array));
+ assertTrue("System resource not found", is.available() > 0);
assertNull(ClassLoader.getSystemResourceAsStream("NotFoundResource"));
}
method = "getSystemResources",
args = {java.lang.String.class}
)
+ @AndroidOnly("The RI doesn't have a classes.dex as resource in the "
+ + "core-tests.jar. Also on Android this file is the only one "
+ + "that is sure to exist.")
public void test_getSystemResources() {
- String textResource = "HelloWorld.txt";
+ String textResource = "classes.dex";
try {
Enumeration<URL> urls = ClassLoader.getSystemResources(textResource);
assertNotNull(urls);
assertTrue(urls.nextElement().getPath().endsWith(textResource));
+ while (urls.hasMoreElements()) {
+ assertNotNull(urls.nextElement());
+ }
try {
urls.nextElement();
fail("NoSuchElementException was not thrown.");
Enumeration<java.net.URL> urls = null;
FileInputStream fis = null;
try {
- urls = ClassLoader.getSystemClassLoader().getResources("HelloWorld.txt");
+ urls = getClass().getClassLoader().getResources("HelloWorld.txt");
URL url = urls.nextElement();
fis = new FileInputStream(url.getFile());
byte [] array = new byte[13];
} catch(Exception e) {}
}
- assertNull(ClassLoader.getSystemClassLoader().
- getResource("not.found.resource"));
+ assertNull(getClass().getClassLoader()
+ .getResource("not.found.resource"));
}
public void test_findSystemClass() {
PackageClassLoader pcl = new PackageClassLoader();
- Class [] classes = { String.class, A.class, PublicTestClass.class,
- TestAnnotation.class, TestClass1.class };
+ Class [] classes = { String.class, Integer.class, Object.class,
+ Object[].class };
for(Class clazz:classes) {
try {
import tests.support.resource.Support_Resources;
import dalvik.annotation.AndroidOnly;
import dalvik.annotation.BrokenTest;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestLevel;
@SuppressWarnings("deprecation")
@TestTargetClass(Class.class)
assertEquals(classes[i], clazz);
}
- for(int i = 0; i < classes.length; i++) {
- Class<?> clazz = Class.forName(classes[i].getName(), true,
+ Class<?> [] systemClasses = {String.class, Integer.class, Object.class,
+ Object[].class};
+
+ for(int i = 0; i < systemClasses.length; i++) {
+ Class<?> clazz = Class.forName(systemClasses[i].getName(), true,
ClassLoader.getSystemClassLoader());
- assertEquals(classes[i], clazz);
+ assertEquals(systemClasses[i], clazz);
- clazz = Class.forName(classes[i].getName(), false,
+ clazz = Class.forName(systemClasses[i].getName(), false,
ClassLoader.getSystemClassLoader());
- assertEquals(classes[i], clazz);
+ assertEquals(systemClasses[i], clazz);
}
try {
method = "getProtectionDomain",
args = {}
)
- @BrokenTest("There is no protection domain set in Android.")
+ @KnownFailure("There is no protection domain set in Android.")
public void test_getProtectionDomain() {
ProtectionDomain pd = PublicTestClass.class.getProtectionDomain();
assertNotNull("Test 1: Protection domain expected to be set.", pd);
method = "getClasses",
args = {}
)
- @BrokenTest("Class.forName does not work with an URLClassLoader; " +
- "the VMClassLoader does not support loading classes from a " +
- "(jar) byte array.")
+ @KnownFailure("Defining classes from byte[] not supported in Android")
public void test_getClasses_subtest0() {
final Permission privCheckPermission = new BasicPermission("Privilege check") {
private static final long serialVersionUID = 1L;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.BrokenTest;
@TestTargetClass(Object.class)
public class ObjectTest extends junit.framework.TestCase {
method = "finalize",
args = {}
)
-
public void test_finalize() {
isCalled = false;
class TestObject extends Object {
package org.apache.harmony.luni.tests.java.lang;
+import dalvik.annotation.AndroidOnly;
import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
method = "resume",
args = {}
)
- @SuppressWarnings("deprecation")
- @BrokenTest("Thread.resume is implemented on some RI")
- public void test_resume() throws OutOfMemoryError {
- // Test for method void java.lang.ThreadGroup.resume()
- final ThreadGroup originalCurrent = getInitialThreadGroup();
-
- final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
- "Test group");
- final int DEPTH = 2;
- buildRandomTreeUnder(testRoot, DEPTH);
-
- final int THREADS_PER_GROUP = 2;
- final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
- THREADS_PER_GROUP);
- try {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.start();
- }
- } catch (OutOfMemoryError e) {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.interrupt();
- }
- throw e;
- }
+ @AndroidOnly("RI does implement this method, whereas Android does not")
+ @SuppressWarnings("deprecation")
+ public void test_resume() {
+ ThreadGroup group = new ThreadGroup("Foo");
+
+ Thread thread = launchFiveSecondDummyThread(group);
try {
- testRoot.resume();
- fail("Thread.resume() is not supported and throws an UOE on Android.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
-
- for (int i = 0; i < threads.size(); i++) {
- MyThread t = threads.elementAt(i);
- t.interrupt();
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
}
- // Make sure we do cleanup before returning
- testRoot.destroy();
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ group.resume();
+ assertEquals(state, thread.getState());
- assertEquals("Method destroy must have problems",
- 0, testRoot.activeCount());
-
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- originalCurrent.resume();
+ group.resume();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
- System.setSecurityManager(oldSm);
- }
+ System.setSecurityManager(oldSm);
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
/**
method = "stop",
args = {}
)
- @BrokenTest("stop() method not implemented.")
+ @AndroidOnly("RI does implement this method, whereas Android does not")
@SuppressWarnings("deprecation")
- public void test_stop() throws OutOfMemoryError {
- // Test for method void java.lang.ThreadGroup.stop()
- final ThreadGroup originalCurrent = getInitialThreadGroup();
-
- final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
- "Test group");
- final int DEPTH = 2;
- buildRandomTreeUnder(testRoot, DEPTH);
-
- final int THREADS_PER_GROUP = 2;
- final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
- THREADS_PER_GROUP);
-
- try {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.start();
- }
- } catch (OutOfMemoryError e) {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.interrupt();
- }
- throw e;
- }
+ public void test_stop() {
+ ThreadGroup group = new ThreadGroup("Foo");
+
+ Thread thread = launchFiveSecondDummyThread(group);
- // Now that they are all running, let's stop the ThreadGroup
try {
- testRoot.stop();
- fail("Thread.stop() is not supported and throws an UOE on Android.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.interrupt();
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
}
- // To make sure that even if we fail, we exit in a clean state
- testRoot.destroy();
-
- assertEquals("Method destroy (or wipeAllThreads) must have problems",
- 0, testRoot.activeCount());
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ group.stop();
+ assertEquals(state, thread.getState());
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
-
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- originalCurrent.stop();
+ group.stop();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
- System.setSecurityManager(oldSm);
+ System.setSecurityManager(oldSm);
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
}
}
+ private Thread launchFiveSecondDummyThread(ThreadGroup group) {
+ Thread thread = new Thread(group, "Bar") {
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+ };
+
+ thread.start();
+
+ return thread;
+ }
+
+ private class ThreadSecurityManager extends SecurityManager {
+ public void checkPermission(Permission perm) {
+ }
+
+ public void checkAccess(Thread t) {
+ throw new SecurityException();
+ }
+ };
+
/**
* @tests java.lang.ThreadGroup#suspend()
*/
method = "suspend",
args = {}
)
- @BrokenTest("suspend() method not implemented.")
+ @AndroidOnly("RI does implement this method, whereas Android does not")
@SuppressWarnings("deprecation")
- public void test_suspend() throws OutOfMemoryError {
- // Test for method void java.lang.ThreadGroup.suspend()
- final ThreadGroup originalCurrent = getInitialThreadGroup();
-
- final ThreadGroup testRoot = new ThreadGroup(originalCurrent,
- "Test group");
- final int DEPTH = 2;
- buildRandomTreeUnder(testRoot, DEPTH);
-
- final int THREADS_PER_GROUP = 2;
- final Vector<MyThread> threads = populateGroupsWithThreads(testRoot,
- THREADS_PER_GROUP);
-
- try {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.start();
- }
- } catch (OutOfMemoryError e) {
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.interrupt();
- }
- throw e;
- }
+ public void test_suspend() {
+ ThreadGroup group = new ThreadGroup("Foo");
+
+ Thread thread = launchFiveSecondDummyThread(group);
try {
- testRoot.suspend();
- fail("Thread.suspend() is not supported and throws an UOE on Android.");
- } catch (UnsupportedOperationException e) {
- // expected
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
}
- for (int i = 0; i < threads.size(); i++) {
- Thread t = threads.elementAt(i);
- t.interrupt();
- }
- // Make sure we cleanup before returning from the method
- testRoot.destroy();
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ group.suspend();
+ assertEquals(state, thread.getState());
- assertEquals("Method destroy (or wipeAllThreads) must have problems",
- 0, testRoot.activeCount());
-
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- originalCurrent.suspend();
+ group.suspend();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
- System.setSecurityManager(oldSm);
- }
+ System.setSecurityManager(oldSm);
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
/**
import java.lang.Thread.UncaughtExceptionHandler;
import java.security.Permission;
import java.util.Map;
+import java.util.concurrent.Semaphore;
import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
-
-import java.util.concurrent.Semaphore;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
@TestTargetClass(Thread.class)
public class ThreadTest extends junit.framework.TestCase {
method = "getContextClassLoader",
args = {}
)
+ @KnownFailure("The context class loader is not inherited by a new thread."
+ + " On android the initial context class loader is alsways null.")
public void test_getContextClassLoader() {
// Test for method java.lang.ClassLoader
// java.lang.Thread.getContextClassLoader()
Thread t = new Thread();
+ assertNotNull(Thread.currentThread().getContextClassLoader());
assertTrue("Incorrect class loader returned",
t.getContextClassLoader() == Thread.currentThread()
.getContextClassLoader());
}
}
+ private Thread launchFiveSecondDummyThread() {
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+ };
+
+ thread.start();
+
+ return thread;
+ }
+
+ private class ThreadSecurityManager extends SecurityManager {
+ public void checkPermission(Permission perm) {
+ }
+
+ public void checkAccess(Thread t) {
+ throw new SecurityException();
+ }
+ };
/**
* @tests java.lang.Thread#resume()
method = "resume",
args = {}
)
- @AndroidOnly("Android throws UnsupportedOperationException for Thread.resume()")
+ @AndroidOnly("RI does implement this method, whereas Android does not")
@SuppressWarnings("deprecation")
public void test_resume() {
- // Test for method void java.lang.Thread.resume()
- int orgval;
- ResSupThread t;
+ Thread thread = launchFiveSecondDummyThread();
+
try {
- t = new ResSupThread(Thread.currentThread());
- synchronized (t) {
- ct = new Thread(t, "Interrupt Test2");
- ct.start();
- t.wait();
- }
- try {
- ct.resume();
- } catch (UnsupportedOperationException e) {
- // expected
- }
+ Thread.sleep(1000);
} catch (InterruptedException e) {
- fail("Unexpected interrupt occurred : " + e.getMessage());
+ // Ignore
}
- // Security checks are made even though resume() is not supported.
- SecurityManager sm = new SecurityManager() {
- public void checkPermission(Permission perm) {
- }
-
- public void checkAccess(Thread t) {
- throw new SecurityException();
- }
- };
- st = new Thread();
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ thread.resume();
+ assertEquals(state, thread.getState());
+
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- st.resume();
+ thread.resume();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
System.setSecurityManager(oldSm);
- }
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
/**
method = "stop",
args = {}
)
- @AndroidOnly("Android throws UnsupportedOperationException for Thread.stop()")
+ @AndroidOnly("RI does implement this method, whereas Android does not")
@SuppressWarnings("deprecation")
public void test_stop() {
- // Test for method void java.lang.Thread.stop()
- try {
- Runnable r = new ResSupThread(null);
- synchronized (r) {
- st = new Thread(r, "Interupt Test5");
- st.start();
- r.wait();
- }
+ Thread thread = launchFiveSecondDummyThread();
- } catch (InterruptedException e) {
- fail("Unexpected interrupt received");
- }
try {
- st.stop();
-// fail("Expected UnsupportedOperationException because" +
-// "Thread.stop is not supported.");
- } catch (UnsupportedOperationException e) {
- // expected
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
}
- // Security checks are made even though stop() is not supported.
- SecurityManager sm = new SecurityManager() {
- public void checkPermission(Permission perm) {
- if(perm.getName().equals("stopThread")) {
- throw new SecurityException();
- }
- }
- };
- st = new Thread();
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ thread.stop();
+ assertEquals(state, thread.getState());
+
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- st.stop();
+ thread.stop();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
System.setSecurityManager(oldSm);
- }
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
/**
* @tests java.lang.Thread#stop(java.lang.Throwable)
*/
@TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
+ level = TestLevel.COMPLETE,
notes = "Verifies security.",
method = "stop",
args = {java.lang.Throwable.class}
)
@SuppressWarnings("deprecation")
public void test_stopLjava_lang_Throwable_subtest0() {
- // Security checks are made even though stop(Throwable) is not supported.
- Thread t = new Thread("t");
- class MySecurityManager extends SecurityManager {
- @Override
- public void checkAccess(Thread t) {
- throw new SecurityException();
- }
- @Override
- public void checkPermission(Permission permission) {
-
- if(permission.getName().equals("stopThread")) {
- throw new SecurityException();
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // Ignore
}
}
- }
- MySecurityManager sm = new MySecurityManager();
- System.setSecurityManager(sm);
+ };
+
+ thread.start();
try {
- try {
- t.stop(new ThreadDeath());
- fail("SecurityException was thrown.");
- } catch (SecurityException e) {
- }
- t.start();
- try {
- t.join(1000);
- } catch (InterruptedException e) {
- }
- try {
- t.stop(new ThreadDeath());
- fail("SecurityException was thrown.");
- } catch (SecurityException e) {
- }
-
- } finally {
- System.setSecurityManager(null);
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
}
- }
- /**
- * @tests java.lang.Thread#stop(java.lang.Throwable)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "SecurityException is not verified.",
- method = "stop",
- args = {java.lang.Throwable.class}
- )
- @AndroidOnly("Android throws UnsupportedOperationException for Thread.stop(Thorwable)")
- @SuppressWarnings("deprecation")
- public void test_stopLjava_lang_Throwable() {
- // Test for method void java.lang.Thread.stop(java.lang.Throwable)
- ResSupThread t = new ResSupThread(Thread.currentThread());
- synchronized (t) {
- st = new Thread(t, "StopThread");
- st.setPriority(Thread.MAX_PRIORITY);
- st.start();
- try {
- t.wait();
- } catch (InterruptedException e) {
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ thread.stop(new Exception("Oops!"));
+ assertEquals(state, thread.getState());
+
+ // Security checks are made even though method is not supported.
+ SecurityManager sm = new SecurityManager() {
+ public void checkPermission(Permission perm) {
}
- }
+
+ public void checkAccess(Thread t) {
+ throw new SecurityException();
+ }
+ };
+
+ SecurityManager oldSm = System.getSecurityManager();
+ System.setSecurityManager(sm);
try {
- st.stop(new BogusException("Bogus"));
-// fail("Expected UnsupportedOperationException because" +
-// "Thread.stop is not supported.");
- } catch (UnsupportedOperationException e) {
+ thread.stop();
+ fail("Should throw SecurityException");
+ } catch (SecurityException e) {
// expected
+ } finally {
+ System.setSecurityManager(oldSm);
}
-
+
try {
- st.stop(null);
- fail("Expected NullPointerException was not thrown");
- } catch (NullPointerException e) {
- // expected
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
}
}
method = "suspend",
args = {}
)
- @AndroidOnly("Android throws UnsupportedOperationException for Thread.suspend()")
+ @AndroidOnly("RI does implement this method, whereas Android does not")
@SuppressWarnings("deprecation")
public void test_suspend() {
- // Test for method void java.lang.Thread.suspend()
- int orgval;
- ResSupThread t = new ResSupThread(Thread.currentThread());
+ Thread thread = launchFiveSecondDummyThread();
+
try {
- synchronized (t) {
- ct = new Thread(t, "Interupt Test6");
- ct.start();
- t.wait();
- }
- ct.suspend();
-// fail("Expected UnsupportedOperationException because" +
-// "Thread.suspend is not supported.");
- } catch (UnsupportedOperationException e) {
- // expected
+ Thread.sleep(1000);
} catch (InterruptedException e) {
- fail("Unexpected InterruptedException was thrown");
+ // Ignore
}
- // Security checks are made even though suspend() is not supported.
- SecurityManager sm = new SecurityManager() {
- public void checkPermission(Permission perm) {
- }
-
- public void checkAccess(Thread t) {
- throw new SecurityException();
- }
- };
- st = new Thread();
+ // No-op in Android. Must neither have an effect nor throw an exception.
+ Thread.State state = thread.getState();
+ thread.suspend();
+ assertEquals(state, thread.getState());
+
+ // Security checks are made even though method is not supported.
SecurityManager oldSm = System.getSecurityManager();
- System.setSecurityManager(sm);
+ System.setSecurityManager(new ThreadSecurityManager());
try {
- st.suspend();
+ thread.suspend();
fail("Should throw SecurityException");
} catch (SecurityException e) {
// expected
} finally {
System.setSecurityManager(oldSm);
- }
+ }
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
/**
package org.apache.harmony.luni.tests.java.net;
-import dalvik.annotation.BrokenTest;
+import dalvik.annotation.SideEffect;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
args = { ContentHandlerFactory.class }
)
})
- @BrokenTest("This test affects tests that are run after this one." +
+ @SideEffect("This test affects tests that are run after this one." +
" The reason are side effects due to caching in URLConnection." +
- " Maybe this test has to be marked NOT_FEASIBLE.")
+ " Maybe this test needs to be run in isolation.")
public void test_createContentHandler() throws IOException {
TestContentHandlerFactory factory = new TestContentHandlerFactory();
* Test method for {@link java.net.URL#openConnection(java.net.Proxy)}.
*/
@TestTargetNew(
- level = TestLevel.NOT_FEASIBLE,
+ level = TestLevel.COMPLETE,
notes = "See ExcludedProxyTest.",
method = "openConnection",
args = {java.net.Proxy.class}
public class ComputeSerialVersionUIDTest extends junit.framework.TestCase {
- private String path = "serialization/tests/api/java/io/";
+ private String path = "/serialization/tests/api/java/io/";
@TestTargetNew(
level = TestLevel.COMPLETE,
args = {}
)
public void testComputeSUIDClass() throws Exception {
- ObjectInputStream ois = new ObjectInputStream(ClassLoader
- .getSystemResourceAsStream(path + "testComputeSUIDClass.ser"));
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getResourceAsStream(path + "testComputeSUIDClass.ser"));
SerializationTestClass.TestClassName1 o1 = (SerializationTestClass.TestClassName1) ois
.readObject();
SerializationTestClass.TestClassName2T_T$T o2 = (SerializationTestClass.TestClassName2T_T$T) ois
args = {}
)
public void testComputeSUIDInterfaces() throws Exception {
- ObjectInputStream ois = new ObjectInputStream(ClassLoader
- .getSystemResourceAsStream(path
- + "testComputeSUIDInterfaces.ser"));
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getResourceAsStream(path + "testComputeSUIDInterfaces.ser"));
SerializationTestClass.TestIntefaces o1 = (SerializationTestClass.TestIntefaces) ois
.readObject();
SerializationTestClass.TestIntefacesA o2 = (SerializationTestClass.TestIntefacesA) ois
args = {}
)
public void testComputeSUIDFields() throws Exception {
- ObjectInputStream ois = new ObjectInputStream(ClassLoader
- .getSystemResourceAsStream(path + "testComputeSUIDFields.ser"));
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getResourceAsStream(path + "testComputeSUIDFields.ser"));
SerializationTestClass.TestFieldsNone o1 = (SerializationTestClass.TestFieldsNone) ois
.readObject();
SerializationTestClass.TestFieldsOneFinal o2 = (SerializationTestClass.TestFieldsOneFinal) ois
args = {}
)
public void testComputeSUIDConstructors() throws Exception {
- ObjectInputStream ois = new ObjectInputStream(ClassLoader
- .getSystemResourceAsStream(path
- + "testComputeSUIDConstructors.ser"));
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getResourceAsStream(path + "testComputeSUIDConstructors.ser"));
SerializationTestClass.TestConstructorNone o1 = (SerializationTestClass.TestConstructorNone) ois
.readObject();
SerializationTestClass.TestConstructorOne o2 = (SerializationTestClass.TestConstructorOne) ois
args = {}
)
public void testComputeSUIDMethods() throws Exception {
- ObjectInputStream ois = new ObjectInputStream(ClassLoader
- .getSystemResourceAsStream(path + "testComputeSUIDMethods.ser"));
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getResourceAsStream(path + "testComputeSUIDMethods.ser"));
SerializationTestClass.TestMehodPrivate o1 = (SerializationTestClass.TestMehodPrivate) ois
.readObject();
SerializationTestClass.TestMethodAbstract o2 = (SerializationTestClass.TestMethodAbstract) ois
private ObjectInputStream ois = null;
private final String FILENAME =
- "tests/api/java/io/testFields.ser";
+ "/tests/api/java/io/testFields.ser";
private final String DEFAULTED_FILENAME =
- "tests/api/java/io/testFieldsDefaulted.ser";
+ "/tests/api/java/io/testFieldsDefaulted.ser";
public boolean booleanValue;
public byte byteValue;
ois.close();
}
ois = new ObjectInputStream(
- ClassLoader.getSystemResourceAsStream(fileName));
+ getClass().getResourceAsStream(fileName));
}
protected void tearDown() throws Exception {
public class ObjectOutputStreamPutFieldTest extends junit.framework.TestCase {
private final String FILENAME =
- "tests/api/java/io/testFields.ser";
+ "/tests/api/java/io/testFields.ser";
private final String DEPRECATED_FILENAME =
- "tests/api/java/io/testFieldsDeprecated.ser";
+ "/tests/api/java/io/testFieldsDeprecated.ser";
@TestTargets({
@TestTargetNew(
InputStream refStream = null;
try {
- refStream = ClassLoader.getSystemResourceAsStream(path);
+ refStream = getClass().getResourceAsStream(path);
bytesRead = refStream.read(streamContent);
assertTrue("Test case implementation error: The byte array to " +
"store the reference file is too small.",
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
method = "receive",
args = {int.class}
)
- @BrokenTest("Test hangs indefinitely on the RI")
public void test_receive() throws IOException {
pis = new PipedInputStream();
pos = new PipedOutputStream();
public void run() {
try {
pos.write(1);
- while (readerAlive)
- ;
+ while (readerAlive) {
+ Thread.sleep(100);
+ }
try {
// should throw exception since reader thread
// is now dead
} catch (IOException e) {
pass = true;
}
- } catch (IOException e) {}
+ } catch (IOException e) {
+ // ignore
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
}
WriteRunnable writeRunnable = new WriteRunnable();
package tests.api.java.io;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
-
import java.util.Arrays;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+
@TestTargetClass(PipedWriter.class)
public class PipedWriterTest extends junit.framework.TestCase {
method = "write",
args = {char[].class, int.class, int.class}
)
- @BrokenTest("Hangs on RI")
public void test_write$CII_MultiThread() throws Exception {
final PipedReader pr = new PipedReader();
final PipedWriter pw = new PipedWriter();
pw.write(1);
while (readerAlive) {
// wait the reader thread dead
+ Thread.sleep(100);
}
try {
// should throw exception since reader thread
}
} catch (IOException e) {
//ignore
+ } catch (InterruptedException e) {
+ //ignore
}
}
}
method = "write",
args = {int.class}
)
- @BrokenTest("Hangs on RI")
public void test_writeI_MultiThread() throws IOException {
final PipedReader pr = new PipedReader();
final PipedWriter pw = new PipedWriter();
pw.write(1);
while (readerAlive) {
// wait the reader thread dead
+ Thread.sleep(100);
}
try {
// should throw exception since reader thread
}
} catch (IOException e) {
//ignore
+ } catch (InterruptedException e) {
+ //ignore
}
}
}
package tests.api.java.io;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InvalidObjectException;
-import java.io.NotActiveException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.ObjectStreamException;
import java.io.Serializable;
-import java.io.StreamCorruptedException;
-import java.io.WriteAbortedException;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.TimeZone;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.Vector;
+
+import dalvik.annotation.TestTargetClass;
/**
* Automated Test Suite for class java.io.ObjectOutputStream
*
*/
+@SuppressWarnings({"serial", "unchecked"})
@TestTargetClass(Serializable.class)
public class SerializationStressTest extends junit.framework.TestCase implements
Serializable {
package tests.api.java.io;
+import dalvik.annotation.AndroidOnly;
import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
fail("ClassNotFoundException serializing data : " + e.getMessage());
}
}
-
+
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Verifies serialization.",
method = "!Serialization",
args = {}
)
- @BrokenTest("Needs investigation. succeeds on android, fails on RI")
- public void test_2_writeReplace() {
+ public void test_2_writeReplace_01() {
try {
boolean exception = false;
try {
exception = true;
}
assertTrue("Should throw ObjectStreamException", exception);
- exception = false;
+ } catch (IOException e) {
+ fail("IOException serializing data : " + e.getMessage());
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization.",
+ method = "!Serialization",
+ args = {}
+ )
+ public void test_2_writeReplace_02() {
+ try {
+ boolean exception = false;
try {
oos.writeObject(new WriteReplaceTestF(1, -1));
} catch (RuntimeException e) {
exception = true;
}
assertTrue("Should throw RuntimeException", exception);
- exception = false;
+ } catch (IOException e) {
+ fail("IOException serializing data : " + e.getMessage());
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization.",
+ method = "!Serialization",
+ args = {}
+ )
+ public void test_2_writeReplace_03() {
+ try {
+ boolean exception = false;
try {
oos.writeObject(new WriteReplaceTestF(2, -1));
} catch (Error e) {
exception = true;
}
assertTrue("Should throw Error", exception);
+ } catch (IOException e) {
+ fail("IOException serializing data : " + e.getMessage());
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization.",
+ method = "!Serialization",
+ args = {}
+ )
+ public void test_2_writeReplace_04() {
+ try {
+ boolean exception = false;
oos.writeObject(new WriteReplaceTestF(3, 0));
oos.writeObject(new WriteReplaceTestF(3, 1));
ois = new ObjectInputStream(loadStream());
try {
ois.readObject();
- } catch (WriteAbortedException e) {
- }
-
- exception = false;
- try {
- ois.readObject();
- } catch (ObjectStreamException e) {
+ } catch (InvalidObjectException e) {
exception = true;
}
- assertTrue("Expected ObjectStreamException", exception);
+ assertTrue("Expected InvalidObjectException", exception);
+
exception = false;
try {
ois.readObject();
*/
package tests.api.java.io;
-import dalvik.annotation.BrokenTest;
+import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.Arrays;
+import java.util.Vector;
+@SuppressWarnings("serial")
@TestTargetClass(Serializable.class)
public class SerializationStressTest1 extends SerializationStressTest {
public void run() {
}
+
+ SpecTestSuperClass() {
+ }
}
- private static class SpecTest extends SpecTestSuperClass implements
- Cloneable, Serializable {
+ private static class SpecTest extends SpecTestSuperClass implements Cloneable, Serializable {
public java.lang.String instVar1;
public static java.lang.String staticVar1;
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
calledReadObject = true;
- String s = ((String) in.readObject());
+ in.readObject();
}
private void writeObject(java.io.ObjectOutputStream out)
public void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
calledReadObject = true;
- String s = ((String) in.readObject());
+ in.readObject();
}
public void writeObject(java.io.ObjectOutputStream out)
private static class MyUnserializableExceptionWhenDumping implements
java.io.Serializable {
private static class MyException extends java.io.IOException {
+ @SuppressWarnings("unused")
private Object notSerializable = new Object();
};
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
boolean passed = false;
Throwable t = null;
try {
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
} catch (NotSerializableException ns) {
passed = true;
t = ns;
method = "!Serialization",
args = {}
)
- @BrokenTest("throws IllegalAccessException on Android and InvalidClassException on RI")
public void test_18_14_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
((SpecTest) objLoaded).instVar1.equals(FOO));
} catch (IOException e) {
+ e.printStackTrace();
fail("Exception serializing " + objToSave + "\t->"
+ e.toString());
+
} catch (ClassNotFoundException e) {
fail("ClassNotFoundException reading Object type : "
+ e.getMessage());
method = "!Serialization",
args = {}
)
- @BrokenTest("throws IllegalAccessException on Android and InvalidClassException on RI")
public void test_18_15_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
FieldOrder fieldOrder = new FieldOrder();
objToSave = fieldOrder;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// This test is only useful for X-loading, so if it managed to
// dump&load, we passed the test
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
objToSave = justWriteObject;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Call writeObject on the instance even if it does not define
// readObject
assertTrue(MSG_TEST_FAILED + objToSave,
Object objLoaded;
try {
- java.util.Vector vector = new java.util.Vector(1);
+ java.util.Vector<String> vector = new java.util.Vector<String>(1);
vector.add(FOO);
objToSave = vector;
if (DEBUG)
System.out.println("Obj = " + objToSave);
objLoaded = dumpAndReload(objToSave);
// Has to have the string there
+ @SuppressWarnings("unchecked")
+ java.util.Vector<String> obj = (Vector<String>)objLoaded;
assertTrue(MSG_TEST_FAILED + objToSave, FOO
- .equals(((java.util.Vector) objLoaded).elementAt(0)));
+ .equals(obj.elementAt(0)));
} catch (IOException e) {
fail("IOException serializing " + objToSave + " : "
Object objLoaded;
try {
- java.util.Hashtable hashTable = new java.util.Hashtable(5);
+ java.util.Hashtable<String, String> hashTable = new java.util.Hashtable<String, String>(5);
hashTable.put(FOO, FOO);
objToSave = hashTable;
if (DEBUG)
System.out.println("Obj = " + objToSave);
objLoaded = dumpAndReload(objToSave);
- java.util.Hashtable loadedHashTable = (java.util.Hashtable) objLoaded;
+ @SuppressWarnings("unchecked")
+ java.util.Hashtable<String, String> loadedHashTable = (java.util.Hashtable<String, String>) objLoaded;
// Has to have the key/value there (FOO -> FOO)
assertTrue(MSG_TEST_FAILED + objToSave, FOO.equals(loadedHashTable
.get(FOO)));
method = "!Serialization",
args = {}
)
- @BrokenTest("Needs investigation. fails on RI, succeeds on Android. Maybe a bug in the RI.")
+ @KnownFailure("nested writeReplace is not handled")
public void test_18_28_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
assertTrue(
"Executed multiple levels of replacement (see PR 1F9RNT1), loaded= "
+ objLoaded,
- objLoaded instanceof MultipleClassBasedReplacementWhenDumping.C1);
+ objLoaded instanceof String);
} catch (IOException e) {
fail("IOException serializing " + objToSave + " : "
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
ClassBasedReplacementWhenLoadingViolatesFieldType classBasedReplacementWhenLoadingViolatesFieldType = new ClassBasedReplacementWhenLoadingViolatesFieldType();
objToSave = classBasedReplacementWhenLoadingViolatesFieldType;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// We cannot gere here, the load replacement must have caused a
// field type violation
fail(
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
MyExceptionWhenDumping1 exceptionWhenDumping = new MyExceptionWhenDumping1();
causedException);
causedException = false;
try {
- objLoaded = reload();
+ reload();
// Although the spec says we should get a WriteAbortedException,
// the serialization format handle an Exception when reading
// primitive data so we get ClassCastException instead
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
MyExceptionWhenDumping2 exceptionWhenDumping = new MyExceptionWhenDumping2();
causedException);
causedException = false;
try {
- objLoaded = reload();
+ reload();
} catch (java.io.WriteAbortedException e) {
causedException = true;
}
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
NonSerializableExceptionWhenDumping nonSerializableExceptionWhenDumping = new NonSerializableExceptionWhenDumping();
causedException);
causedException = false;
try {
- objLoaded = reload();
+ reload();
} catch (java.io.WriteAbortedException e) {
causedException = true;
}
method = "!Serialization",
args = {}
)
- @BrokenTest("succeeds on Android, but fails on RI with MyException being thrown.")
public void test_18_33_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
MyUnserializableExceptionWhenDumping exceptionWhenDumping = new MyUnserializableExceptionWhenDumping();
boolean causedException = false;
try {
dump(objToSave);
- } catch (java.io.StreamCorruptedException e) {
+ } catch (java.io.ObjectStreamException e) {
causedException = true;
}
;
// As the stream is corrupted, reading the stream will have
// undefined results
} catch (IOException e) {
+ e.printStackTrace();
fail("IOException serializing " + objToSave + " : "
+ e.getMessage());
} catch (ClassNotFoundException e) {
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ioe = new java.io.IOException();
objToSave = ioe;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.InvalidClassException(FOO);
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.InvalidObjectException(FOO);
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.NotActiveException(FOO);
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.NotSerializableException(FOO);
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.StreamCorruptedException(FOO);
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
import java.util.Date;
import java.util.Locale;
+@SuppressWarnings("serial")
@TestTargetClass(Serializable.class)
public class SerializationStressTest2 extends SerializationStressTest {
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
- ObjectInputStream.GetField fields = in.readFields();
+ in.readFields();
}
private void writeObject(java.io.ObjectOutputStream out)
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
- ObjectInputStream.GetField fields = in.readFields();
+ in.readFields();
}
private void writeObject(java.io.ObjectOutputStream out)
throws java.io.IOException, ClassNotFoundException {
- ObjectOutputStream.PutField fields = out.putFields();
+ out.putFields();
out.writeFields();
}
}
// does not consume. Have to make sure we can load object properly AND
// object after it (to show the extra byte[] is consumed)
private static class OptionalDataNotRead implements java.io.Serializable {
+ @SuppressWarnings("unused")
private int field1, field2;
public OptionalDataNotRead() {
}
protected Object replaceObject(Object obj) throws IOException {
- Class objClass = obj.getClass();
+ Class<?> objClass = obj.getClass();
if (objClass == String.class)
calledStringReplacement = true;
InitializerFieldsTest inst = (InitializerFieldsTest) obj;
return inst.toBeSerialized.equals(this.toBeSerialized)
- && inst.toBeNotSerialized.equals(this.toBeNotSerialized2);
+ && InitializerFieldsTest.toBeNotSerialized.equals(InitializerFieldsTest.toBeNotSerialized2);
}
}
&& inst.toBeSerialized3.equals(this.toBeSerialized3)
&& inst.toBeSerialized4.equals(this.toBeSerialized4)
&& inst.toBeSerialized5.equals(this.toBeSerialized5)
- && inst.toBeNotSerialized.equals(this.toBeNotSerialized2);
+ && InitializerFieldsTest2.toBeNotSerialized.equals(InitializerFieldsTest2.toBeNotSerialized2);
}
}
.equals(this.sub_toBeSerialized4)
&& inst.sub_toBeSerialized5
.equals(this.sub_toBeSerialized5)
- && inst.sub_toBeNotSerialized
- .equals(this.sub_toBeNotSerialized2);
+ && InitializerFieldsTest3.sub_toBeNotSerialized
+ .equals(InitializerFieldsTest3.sub_toBeNotSerialized2);
}
}
// replace or supplement this.
// NOTE: if two objects are equal (equals Object) returns true) they
// must have the same hash code
- Class[] c = { String.class }; // *** synthetic field
+ @SuppressWarnings("unused")
+ Class<?>[] c = { String.class }; // *** synthetic field
return super.hashCode();
}
}
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
java.io.IOException ex = new java.io.WriteAbortedException(FOO,
objToSave = ex;
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
WithUnmatchingSerialPersistentFields spf = new WithUnmatchingSerialPersistentFields();
System.out.println("Obj = " + objToSave);
boolean causedException = false;
try {
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
} catch (InvalidClassException ce) {
causedException = true;
}
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
WriteFieldsWithoutFetchingPutFields spf = new WriteFieldsWithoutFetchingPutFields();
System.out.println("Obj = " + objToSave);
boolean causedException = false;
try {
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
} catch (NotActiveException ce) {
causedException = true;
}
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
objToSave = SerialPersistentFields.class; // Test for 1FA7TA6
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
objToSave = ObjectStreamClass.lookup(SerialPersistentFields.class); // Test
// 1FA7TA6
if (DEBUG)
System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
+ dumpAndReload(objToSave);
// Has to be able to save/load an exception
assertTrue(MSG_TEST_FAILED + objToSave, true);
try {
- ArrayList list = new ArrayList(Arrays.asList(new String[] { "a",
+ ArrayList<String> list = new ArrayList<String>(Arrays.asList(new String[] { "a",
"list", "of", "strings" }));
objToSave = list;
if (DEBUG)
objLoaded = dumpAndReload(objToSave);
// Has to have worked
assertTrue(MSG_TEST_FAILED + objToSave, true);
+ assertNotNull(objLoaded);
} catch (IOException e) {
fail("IOException serializing " + objToSave + " : "
objLoaded = dumpAndReload(objToSave);
// Has to have worked
assertTrue(MSG_TEST_FAILED + objToSave, true);
+ assertNotNull(objLoaded);
} catch (IOException e) {
fail("IOException serializing " + objToSave + " : "
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
ByteArrayOutputStream out;
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
ByteArrayOutputStream out;
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
ByteArrayOutputStream out;
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
Object objToSave = null;
- Object objLoaded;
try {
ByteArrayOutputStream out;
objLoaded = dumpAndReload(objToSave);
// Has to have worked
assertTrue(MSG_TEST_FAILED + objToSave, true);
+ assertNotNull(objLoaded);
} catch (IOException e) {
fail("IOException serializing " + objToSave + " : "
try {
ObjectInputStream ois = new ObjectInputStream(
new ByteArrayInputStream(out.toByteArray()));
- Object obj = ois.readObject();
+ ois.readObject();
} catch (OptionalDataException e) {
lengthRead = e.length;
}
*/
package tests.api.java.io;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
}
}
- private static class NonSerPrivateConstructor {
+ static class NonSerPrivateConstructor {
public int f1;
public static int valueAfterConstructor = 5;
- private NonSerPrivateConstructor() {
+ NonSerPrivateConstructor() {
f1 = valueAfterConstructor;
}
- public NonSerPrivateConstructor(String notUsed) {
+ NonSerPrivateConstructor(String notUsed) {
}
}
}
// -----------------------------------------------------------------------------------
- private static class PrivateConstructorSub extends NonSerPrivateConstructor
+ static class PrivateConstructorSub extends NonSerPrivateConstructor
implements java.io.Serializable {
int fsub;
static int subValueAfterConstructor = 11;
- public PrivateConstructorSub() {
+ private PrivateConstructorSub() {
super("notUsed");
f1 = 7;
fsub = subValueAfterConstructor;
method = "!Serialization",
args = {}
)
- @BrokenTest("Needs investigation.Fails on Android with IlegalAccessException and RI with IOException: no valid constructor")
public void test_18_85_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
//
// }
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Verifies serialization.",
- method = "!Serialization",
- args = {}
- )
- @BrokenTest("Needs investigation. Fails on RI and on Android with the same IOException.")
- public void test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = java.util.Collections.unmodifiableMap(MAP).entrySet();
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- equals = ((java.util.Collection) objToSave).size() == ((java.util.Collection) objLoaded)
- .size();
- if (equals) {
- java.util.Iterator iter1 = ((java.util.Collection) objToSave)
- .iterator(), iter2 = ((java.util.Collection) objLoaded)
- .iterator();
- while (iter1.hasNext())
- equals = equals && iter1.next().equals(iter2.next());
- }
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
+ /*
+ * serializing java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet tries to serialize
+ * java.util.HashMap.EntrySet which is not serializable
+ */
+ // @TestTargetNew(
+ // level = TestLevel.COMPLETE,
+ // notes = "Verifies serialization.",
+ // method = "!Serialization",
+ // args = {}
+ // )
+ // @BrokenTest("Needs investigation. Fails on RI and on Android with the same IOException.")
+ // public void
+ // test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
+ // // Test for method void
+ // //
+ // java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet)
+ //
+ // Object objToSave = null;
+ // Object objLoaded = null;
+ //
+ // try {
+ // objToSave = java.util.Collections.unmodifiableMap(MAP).entrySet();
+ // if (DEBUG)
+ // System.out.println("Obj = " + objToSave);
+ // objLoaded = dumpAndReload(objToSave);
+ //
+ // // Has to have worked
+ // boolean equals;
+ // equals = ((java.util.Collection) objToSave).size() ==
+ // ((java.util.Collection) objLoaded)
+ // .size();
+ // if (equals) {
+ // java.util.Iterator iter1 = ((java.util.Collection) objToSave)
+ // .iterator(), iter2 = ((java.util.Collection) objLoaded)
+ // .iterator();
+ // while (iter1.hasNext())
+ // equals = equals && iter1.next().equals(iter2.next());
+ // }
+ // assertTrue(MSG_TEST_FAILED + objToSave, equals);
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // fail("IOException serializing " + objToSave + " : "
+ // + e.getMessage());
+ // } catch (ClassNotFoundException e) {
+ // fail("ClassNotFoundException reading Object type : "
+ // + e.getMessage());
+ // } catch (Error err) {
+ // System.out.println("Error when obj = " + objToSave);
+ // // err.printStackTrace();
+ // throw err;
+ // }
+ //
+ // }
@TestTargetNew(
level = TestLevel.COMPLETE,
)
public void testHeavyLoad() {
int i;
- for (i = 0; i < 2000; i++)
+ for (i = 0; i < 100; i++)
stuff();
}
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.BrokenTest;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
package tests.api.java.lang.reflect;
import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.SideEffect;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
)
@AndroidOnly("Uses Android specific class dalvik.system.DexFile " +
"for loading classes.")
+ @SideEffect("strange issue (exception: 'could not open dex file', " +
+ "dalvikvm: 'waitpid failed' log msg - only occurs when @SideEffect is removed " +
+ "and this test is run via running tests.luni.AllTestsLang TestSuite")
public void test_signatureFormatError() throws Exception {
/*
* dex1.bytes is a jar file with a classes.dex in it.
method = "connect",
args = {java.net.InetAddress.class, int.class}
)
- @BrokenTest("IllegalArgumentException is thrown from Permission object")
public void test_connectLjava_net_InetAddressI_SecurityManager() throws
SocketException, UnknownHostException {
- byte[] addressBytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0 };
+ byte[] addressBytes = { 0, 0, 0, 0 };
ds = new java.net.DatagramSocket();
int portNumber = Support_PortManager.getNextPortForUDP();
List alist;
- static Object[] objArray;
- {
- objArray = new Object[100];
- for (int i = 0; i < objArray.length; i++)
- objArray[i] = new Integer(i);
- }
-
+ Object[] objArray;
+
/**
* @tests java.util.ArrayList#ArrayList()
*/
*/
protected void setUp() throws Exception {
super.setUp();
+
+ objArray = new Object[100];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ }
+
alist = new ArrayList();
- for (int i = 0; i < objArray.length; i++)
+ for (int i = 0; i < objArray.length; i++) {
alist.add(objArray[i]);
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ objArray = null;
+ alist = null;
+
+ super.tearDown();
}
}
final static int arraySize = 100;
- static Object[] objArray;
+ Object[] objArray;
- static boolean[] booleanArray;
+ boolean[] booleanArray;
- static byte[] byteArray;
+ byte[] byteArray;
- static char[] charArray;
+ char[] charArray;
- static double[] doubleArray;
+ double[] doubleArray;
- static float[] floatArray;
+ float[] floatArray;
- static int[] intArray;
+ int[] intArray;
- static long[] longArray;
+ long[] longArray;
- static Object[] objectArray;
-
- static short[] shortArray;
- {
- objArray = new Object[arraySize];
- for (int i = 0; i < objArray.length; i++)
- objArray[i] = new Integer(i);
- }
+ Object[] objectArray;
+ short[] shortArray;
+
/**
* @tests java.util.Arrays#asList(java.lang.Object[])
*/
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[arraySize];
+ for (int i = 0; i < objArray.length; i++)
+ objArray[i] = new Integer(i);
+
booleanArray = new boolean[arraySize];
byteArray = new byte[arraySize];
charArray = new char[arraySize];
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ booleanArray = null;
+ byteArray = null;
+ charArray = null;
+ doubleArray = null;
+ floatArray = null;
+ intArray = null;
+ longArray = null;
+ objectArray = null;
+ shortArray = null;
}
}
cal1.setTimeZone(TimeZone.getTimeZone("GMT-8"));
assertTrue(cal1.toString().equals(cal2.toString()));
}
+
+ @TestTargetNew(
+ level = TestLevel.ADDITIONAL,
+ method = "get",
+ args = {int.class}
+ )
+ public void test_EdgeCases() {
+ Calendar c = Calendar.getInstance();
+
+ c.setTimeInMillis(Long.MAX_VALUE);
+
+ assertEquals(292278994, c.get(Calendar.YEAR));
+ assertEquals(Calendar.AUGUST, c.get(Calendar.MONTH));
+ assertEquals(17, c.get(Calendar.DAY_OF_MONTH));
+ assertEquals(Calendar.SUNDAY, c.get(Calendar.DAY_OF_WEEK));
+ assertEquals(7, c.get(Calendar.HOUR_OF_DAY));
+ assertEquals(12, c.get(Calendar.MINUTE));
+ assertEquals(55, c.get(Calendar.SECOND));
+ }
protected void setUp() {
defaultLocale = Locale.getDefault();
@TestTargetClass(Collections.class)
public class CollectionsTest extends junit.framework.TestCase {
- LinkedList ll;
+ private LinkedList ll;
- LinkedList myll;
+ private LinkedList myll;
- LinkedList reversedLinkedList;
+ private LinkedList reversedLinkedList;
- LinkedList myReversedLinkedList;
+ private LinkedList myReversedLinkedList;
- Set s;
+ private Set s;
- Set mys;
+ private Set mys;
- HashMap hm;
+ private HashMap hm;
- static Object[] objArray;
-
- static Object[] myobjArray;
- {
- objArray = new Object[1000];
- myobjArray = new Object[1000];
- for (int i = 0; i < objArray.length; i++) {
- objArray[i] = new Integer(i);
- myobjArray[i] = new MyInt(i);
- }
- }
+ private Object[] objArray;
+ private Object[] myobjArray;
+
public static class ReversedMyIntComparator implements Comparator {
public int compare(Object o1, Object o2) {
return -((MyInt) o1).compareTo((MyInt) o2);
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[1000];
+ myobjArray = new Object[1000];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ myobjArray[i] = new MyInt(i);
+ }
+
ll = new LinkedList();
myll = new LinkedList();
s = new HashSet();
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ myobjArray = null;
+
+ ll = null;
+ myll = null;
+ reversedLinkedList = null;
+ myReversedLinkedList = null;
+ s = null;
+ mys = null;
+ hm = null;
}
protected void doneSuite() {
@TestTargetClass(EmptyStackException.class)
public class EmptyStackExceptionTest extends junit.framework.TestCase {
- static Object[] objArray = new Object[10];
+ Object[] objArray = new Object[10];
Stack s;
- {
- for (int counter = 0; counter < objArray.length; counter++)
- objArray[counter] = new Integer(counter);
- }
-
/**
* @tests java.util.EmptyStackException#EmptyStackException()
*/
* is called before a test is executed.
*/
protected void setUp() {
+ for (int counter = 0; counter < objArray.length; counter++) {
+ objArray[counter] = new Integer(counter);
+ }
+
s = new Stack();
- for (int counter = 0; counter < objArray.length; counter++)
+ for (int counter = 0; counter < objArray.length; counter++) {
s.push(objArray[counter]);
+ }
}
/**
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ s = null;
}
}
method = "format",
args = {java.lang.String.class, java.lang.Object[].class}
)
- @AndroidOnly("Icu data for Czech locale differs a bit from the RI")
- @BrokenTest("Many failures in this test. Needs more investigation.")
+ @AndroidOnly("ICU data is different from RI data")
public void test_formatLjava_lang_String$Ljava_lang_Object_DateTimeConversion() {
+ /*
+ * Implementation note: For a millisecond date based on Long.MAX_VALUE,
+ * the RI produces different formatted minutes and seconds than we do.
+ * Our Calendar does handle these values in the same way (see
+ * CalendardTest#test_EdgeCases()), so we obviously inherit this
+ * difference from ICU and simply accept it. We have left the original
+ * RI values in comments in the following tables. Apart from that, there
+ * are numerous other differences due to ICU locale data.
+ */
Formatter f = null;
Date now = new Date(1147327147578L);
{new Date(1147327147578L), 'b', "Mai"}, //$NON-NLS-2$
{paris, 'b', "Mai"}, //$NON-NLS-2$
{china, 'b', "Mai"}, //$NON-NLS-2$
- {0L, 'c', "Do Jan 01 08:00:00 CST 1970"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'c', "So Aug 17 15:12:55 CST 292278994"}, //$NON-NLS-2$
- {-1000L, 'c', "Do Jan 01 07:59:59 CST 1970"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'c', "Do Mai 11 13:59:07 CST 2006"}, //$NON-NLS-2$
- {paris, 'c', "Mo Mai 08 12:00:00 CEST 2006"}, //$NON-NLS-2$
+ {0L, 'c', "Do Jan 01 08:00:00 GMT+08:00 1970"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'c', "So Aug 17 15:12:55 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'c', "So Aug 17 15:18:47 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {-1000L, 'c', "Do Jan 01 07:59:59 GMT+08:00 1970"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'c', "Do Mai 11 13:59:07 GMT+08:00 2006"}, //$NON-NLS-2$
+ {paris, 'c', "Mo Mai 08 12:00:00 MESZ 2006"}, //$NON-NLS-2$
{china, 'c', "Mo Mai 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
{0L, 'd', "01"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'd', "17"}, //$NON-NLS-2$
{new Date(1147327147578L), 'm', "05"}, //$NON-NLS-2$
{paris, 'm', "05"}, //$NON-NLS-2$
{china, 'm', "05"}, //$NON-NLS-2$
- {0L, 'p', "am"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'p', "pm"}, //$NON-NLS-2$
- {-1000L, 'p', "am"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'p', "pm"}, //$NON-NLS-2$
- {paris, 'p', "pm"}, //$NON-NLS-2$
- {china, 'p', "pm"}, //$NON-NLS-2$
- {0L, 'r', "08:00:00 AM"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'r', "03:12:55 PM"}, //$NON-NLS-2$
- {-1000L, 'r', "07:59:59 AM"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'r', "01:59:07 PM"}, //$NON-NLS-2$
- {paris, 'r', "12:00:00 PM"}, //$NON-NLS-2$
- {china, 'r', "12:00:00 PM"}, //$NON-NLS-2$
+ {0L, 'p', "vorm."}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'p', "nachm."}, //$NON-NLS-2$
+ {-1000L, 'p', "vorm."}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'p', "nachm."}, //$NON-NLS-2$
+ {paris, 'p', "nachm."}, //$NON-NLS-2$
+ {china, 'p', "nachm."}, //$NON-NLS-2$
+ {0L, 'r', "08:00:00 vorm."}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'r', "03:12:55 PM"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'r', "03:18:47 nachm."}, //$NON-NLS-2$
+ {-1000L, 'r', "07:59:59 vorm."}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'r', "01:59:07 nachm."}, //$NON-NLS-2$
+ {paris, 'r', "12:00:00 nachm."}, //$NON-NLS-2$
+ {china, 'r', "12:00:00 nachm."}, //$NON-NLS-2$
{0L, 's', "0"}, //$NON-NLS-2$
{Long.MAX_VALUE, 's', "9223372036854775"}, //$NON-NLS-2$
{-1000L, 's', "-1"}, //$NON-NLS-2$
{new Date(1147327147578L), 'b', "mai"}, //$NON-NLS-2$
{paris, 'b', "mai"}, //$NON-NLS-2$
{china, 'b', "mai"}, //$NON-NLS-2$
- {0L, 'c', "jeu. janv. 01 08:00:00 CST 1970"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'c', "dim. ao\u00fbt 17 15:12:55 CST 292278994"}, //$NON-NLS-2$
- {-1000L, 'c', "jeu. janv. 01 07:59:59 CST 1970"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'c', "jeu. mai 11 13:59:07 CST 2006"}, //$NON-NLS-2$
- {paris, 'c', "lun. mai 08 12:00:00 CEST 2006"}, //$NON-NLS-2$
- {china, 'c', "lun. mai 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
+ {0L, 'c', "jeu. janv. 01 08:00:00 HMG+08:00 1970"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'c', "dim. ao\u00fbt 17 15:12:55 HMG+08:00 292278994"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'c', "dim. ao\u00fbt 17 15:18:47 HMG+08:00 292278994"}, //$NON-NLS-2$
+ {-1000L, 'c', "jeu. janv. 01 07:59:59 HMG+08:00 1970"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'c', "jeu. mai 11 13:59:07 HMG+08:00 2006"}, //$NON-NLS-2$
+ {paris, 'c', "lun. mai 08 12:00:00 HAEC 2006"}, //$NON-NLS-2$
+ {china, 'c', "lun. mai 08 12:00:00 HMG-08:00 2006"}, //$NON-NLS-2$
{0L, 'd', "01"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'd', "17"}, //$NON-NLS-2$
{-1000L, 'd', "01"}, //$NON-NLS-2$
{paris, 'p', "pm"}, //$NON-NLS-2$
{china, 'p', "pm"}, //$NON-NLS-2$
{0L, 'r', "08:00:00 AM"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'r', "03:12:55 PM"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'r', "03:12:55 PM"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'r', "03:18:47 PM"}, //$NON-NLS-2$
{-1000L, 'r', "07:59:59 AM"}, //$NON-NLS-2$
{new Date(1147327147578L), 'r', "01:59:07 PM"}, //$NON-NLS-2$
{paris, 'r', "12:00:00 PM"}, //$NON-NLS-2$
{new Date(1147327147578L), 'b', "5"}, //$NON-NLS-2$
{paris, 'b', "5"}, //$NON-NLS-2$
{china, 'b', "5"}, //$NON-NLS-2$
- {0L, 'c', "\u010dt I 01 08:00:00 CST 1970"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'c', "ne VIII 17 15:12:55 CST 292278994"}, //$NON-NLS-2$
- {-1000L, 'c', "\u010dt I 01 07:59:59 CST 1970"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'c', "\u010dt V 11 13:59:07 CST 2006"}, //$NON-NLS-2$
- {paris, 'c', "po V 08 12:00:00 CEST 2006"}, //$NON-NLS-2$
- {china, 'c', "po V 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
+ {0L, 'c', "\u010dt 1 01 08:00:00 GMT+08:00 1970"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'c', "ne 8 17 15:12:55 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'c', "ne 8 17 15:18:47 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {-1000L, 'c', "\u010dt 1 01 07:59:59 GMT+08:00 1970"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'c', "\u010dt 5 11 13:59:07 GMT+08:00 2006"}, //$NON-NLS-2$
+ {paris, 'c', "po 5 08 12:00:00 GMT+02:00 2006"}, //$NON-NLS-2$
+ {china, 'c', "po 5 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
{0L, 'd', "01"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'd', "17"}, //$NON-NLS-2$
{-1000L, 'd', "01"}, //$NON-NLS-2$
{new Date(1147327147578L), 'e', "11"}, //$NON-NLS-2$
{paris, 'e', "8"}, //$NON-NLS-2$
{china, 'e', "8"}, //$NON-NLS-2$
- {0L, 'h', "I"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'h', "VIII"}, //$NON-NLS-2$
- {-1000L, 'h', "I"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'h', "V"}, //$NON-NLS-2$
- {paris, 'h', "V"}, //$NON-NLS-2$
- {china, 'h', "V"}, //$NON-NLS-2$
+ {0L, 'h', "1"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'h', "8"}, //$NON-NLS-2$
+ {-1000L, 'h', "1"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'h', "5"}, //$NON-NLS-2$
+ {paris, 'h', "5"}, //$NON-NLS-2$
+ {china, 'h', "5"}, //$NON-NLS-2$
{0L, 'j', "001"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'j', "229"}, //$NON-NLS-2$
{-1000L, 'j', "001"}, //$NON-NLS-2$
{new Date(1147327147578L), 'p', "odp."}, //$NON-NLS-2$
{paris, 'p', "odp."}, //$NON-NLS-2$
{china, 'p', "odp."}, //$NON-NLS-2$
- {0L, 'r', "08:00:00 DOP."}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'r', "03:12:55 ODP."}, //$NON-NLS-2$
- {-1000L, 'r', "07:59:59 DOP."}, //$NON-NLS-2$
- {new Date(1147327147578L), 'r', "01:59:07 ODP."}, //$NON-NLS-2$
- {paris, 'r', "12:00:00 ODP."}, //$NON-NLS-2$
- {china, 'r', "12:00:00 ODP."}, //$NON-NLS-2$
+ {0L, 'r', "08:00:00 dop."}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'r', "03:12:55 ODP."}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'r', "03:18:47 odp."}, //$NON-NLS-2$
+ {-1000L, 'r', "07:59:59 dop."}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'r', "01:59:07 odp."}, //$NON-NLS-2$
+ {paris, 'r', "12:00:00 odp."}, //$NON-NLS-2$
+ {china, 'r', "12:00:00 odp."}, //$NON-NLS-2$
{0L, 's', "0"}, //$NON-NLS-2$
{Long.MAX_VALUE, 's', "9223372036854775"}, //$NON-NLS-2$
{-1000L, 's', "-1"}, //$NON-NLS-2$
{china, 'z', "-0800"}, //$NON-NLS-2$
};
+ assertEquals(lowerCaseGermanTriple.length, lowerCaseFranceTriple.length);
+ assertEquals(lowerCaseGermanTriple.length, lowerCaseCzechTriple.length);
+
final int input = 0;
final int pattern = 1;
final int output = 2;
- for (int i = 0; i < 90; i++) {
+ for (int i = 0; i < lowerCaseGermanTriple.length; i++) {
// go through legal conversion
String formatSpecifier = "%t" + lowerCaseGermanTriple[i][pattern]; //$NON-NLS-2$
String formatSpecifierUpper = "%T" + lowerCaseGermanTriple[i][pattern]; //$NON-NLS-2$
{paris, 'L', "453"}, //$NON-NLS-2$
{china, 'L', "609"}, //$NON-NLS-2$
{0L, 'M', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'M', "18"}, //$NON-NLS-2$
{-1000L, 'M', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'M', "59"}, //$NON-NLS-2$
{paris, 'M', "00"}, //$NON-NLS-2$
{paris, 'Q', "1147082400453"}, //$NON-NLS-2$
{china, 'Q', "1147118400609"}, //$NON-NLS-2$
{0L, 'R', "08:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'R', "15:18"}, //$NON-NLS-2$
{-1000L, 'R', "07:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'R', "13:59"}, //$NON-NLS-2$
{paris, 'R', "12:00"}, //$NON-NLS-2$
{china, 'R', "12:00"}, //$NON-NLS-2$
{0L, 'S', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'S', "47"}, //$NON-NLS-2$
{-1000L, 'S', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'S', "07"}, //$NON-NLS-2$
{paris, 'S', "00"}, //$NON-NLS-2$
{china, 'S', "00"}, //$NON-NLS-2$
{0L, 'T', "08:00:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'T', "15:18:47"}, //$NON-NLS-2$
{-1000L, 'T', "07:59:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'T', "13:59:07"}, //$NON-NLS-2$
{paris, 'T', "12:00:00"}, //$NON-NLS-2$
{new Date(1147327147578L), 'Y', "2006"}, //$NON-NLS-2$
{paris, 'Y', "2006"}, //$NON-NLS-2$
{china, 'Y', "2006"}, //$NON-NLS-2$
- {0L, 'Z', "CST"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'Z', "CST"}, //$NON-NLS-2$
- {-1000L, 'Z', "CST"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'Z', "CST"}, //$NON-NLS-2$
- {paris, 'Z', "CEST"}, //$NON-NLS-2$
+ {0L, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {-1000L, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {paris, 'Z', "MESZ"}, //$NON-NLS-2$
{china, 'Z', "GMT-08:00"}, //$NON-NLS-2$
};
{paris, 'L', "453"}, //$NON-NLS-2$
{china, 'L', "609"}, //$NON-NLS-2$
{0L, 'M', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'M', "18"}, //$NON-NLS-2$
{-1000L, 'M', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'M', "59"}, //$NON-NLS-2$
{paris, 'M', "00"}, //$NON-NLS-2$
{paris, 'Q', "1147082400453"}, //$NON-NLS-2$
{china, 'Q', "1147118400609"}, //$NON-NLS-2$
{0L, 'R', "08:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'R', "15:18"}, //$NON-NLS-2$
{-1000L, 'R', "07:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'R', "13:59"}, //$NON-NLS-2$
{paris, 'R', "12:00"}, //$NON-NLS-2$
{china, 'R', "12:00"}, //$NON-NLS-2$
{0L, 'S', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'S', "47"}, //$NON-NLS-2$
{-1000L, 'S', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'S', "07"}, //$NON-NLS-2$
{paris, 'S', "00"}, //$NON-NLS-2$
{china, 'S', "00"}, //$NON-NLS-2$
{0L, 'T', "08:00:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'T', "15:18:47"}, //$NON-NLS-2$
{-1000L, 'T', "07:59:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'T', "13:59:07"}, //$NON-NLS-2$
{paris, 'T', "12:00:00"}, //$NON-NLS-2$
{new Date(1147327147578L), 'Y', "2006"}, //$NON-NLS-2$
{paris, 'Y', "2006"}, //$NON-NLS-2$
{china, 'Y', "2006"}, //$NON-NLS-2$
- {0L, 'Z', "CST"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'Z', "CST"}, //$NON-NLS-2$
- {-1000L, 'Z', "CST"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'Z', "CST"}, //$NON-NLS-2$
- {paris, 'Z', "CEST"}, //$NON-NLS-2$
- {china, 'Z', "GMT-08:00"}, //$NON-NLS-2$
+ {0L, 'Z', "HMG+08:00"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'Z', "HMG+08:00"}, //$NON-NLS-2$
+ {-1000L, 'Z', "HMG+08:00"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'Z', "HMG+08:00"}, //$NON-NLS-2$
+ {paris, 'Z', "HAEC"}, //$NON-NLS-2$
+ {china, 'Z', "HMG-08:00"}, //$NON-NLS-2$
};
final Object[][] upperCaseCzechTriple = {
- {0L, 'A', "\u010ctvrtek"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'A', "Ned\u011ble"}, //$NON-NLS-2$
- {-1000L, 'A', "\u010ctvrtek"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'A', "\u010ctvrtek"}, //$NON-NLS-2$
- {paris, 'A', "Pond\u011bl\u00ed"}, //$NON-NLS-2$
- {china, 'A', "Pond\u011bl\u00ed"}, //$NON-NLS-2$
- {0L, 'B', "leden"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'B', "srpen"}, //$NON-NLS-2$
- {-1000L, 'B', "leden"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'B', "kv\u011bten"}, //$NON-NLS-2$
- {paris, 'B', "kv\u011bten"}, //$NON-NLS-2$
- {china, 'B', "kv\u011bten"}, //$NON-NLS-2$
+ {0L, 'A', "\u010dtvrtek"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'A', "ned\u011ble"}, //$NON-NLS-2$
+ {-1000L, 'A', "\u010dtvrtek"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'A', "\u010dtvrtek"}, //$NON-NLS-2$
+ {paris, 'A', "pond\u011bl\u00ed"}, //$NON-NLS-2$
+ {china, 'A', "pond\u011bl\u00ed"}, //$NON-NLS-2$
+ {0L, 'B', "ledna"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'B', "srpna"}, //$NON-NLS-2$
+ {-1000L, 'B', "ledna"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'B', "kv\u011btna"}, //$NON-NLS-2$
+ {paris, 'B', "kv\u011btna"}, //$NON-NLS-2$
+ {china, 'B', "kv\u011btna"}, //$NON-NLS-2$
{0L, 'C', "19"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'C', "2922789"}, //$NON-NLS-2$
{-1000L, 'C', "19"}, //$NON-NLS-2$
{paris, 'L', "453"}, //$NON-NLS-2$
{china, 'L', "609"}, //$NON-NLS-2$
{0L, 'M', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'M', "12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'M', "18"}, //$NON-NLS-2$
{-1000L, 'M', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'M', "59"}, //$NON-NLS-2$
{paris, 'M', "00"}, //$NON-NLS-2$
{paris, 'Q', "1147082400453"}, //$NON-NLS-2$
{china, 'Q', "1147118400609"}, //$NON-NLS-2$
{0L, 'R', "08:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'R', "15:12"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'R', "15:18"}, //$NON-NLS-2$
{-1000L, 'R', "07:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'R', "13:59"}, //$NON-NLS-2$
{paris, 'R', "12:00"}, //$NON-NLS-2$
{china, 'R', "12:00"}, //$NON-NLS-2$
{0L, 'S', "00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'S', "55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'S', "47"}, //$NON-NLS-2$
{-1000L, 'S', "59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'S', "07"}, //$NON-NLS-2$
{paris, 'S', "00"}, //$NON-NLS-2$
{china, 'S', "00"}, //$NON-NLS-2$
{0L, 'T', "08:00:00"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'T', "15:12:55"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'T', "15:18:47"}, //$NON-NLS-2$
{-1000L, 'T', "07:59:59"}, //$NON-NLS-2$
{new Date(1147327147578L), 'T', "13:59:07"}, //$NON-NLS-2$
{paris, 'T', "12:00:00"}, //$NON-NLS-2$
{new Date(1147327147578L), 'Y', "2006"}, //$NON-NLS-2$
{paris, 'Y', "2006"}, //$NON-NLS-2$
{china, 'Y', "2006"}, //$NON-NLS-2$
- {0L, 'Z', "CST"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'Z', "CST"}, //$NON-NLS-2$
- {-1000L, 'Z', "CST"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'Z', "CST"}, //$NON-NLS-2$
- {paris, 'Z', "CEST"}, //$NON-NLS-2$
+ {0L, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {-1000L, 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'Z', "GMT+08:00"}, //$NON-NLS-2$
+ {paris, 'Z', "GMT+02:00"}, //$NON-NLS-2$
{china, 'Z', "GMT-08:00"}, //$NON-NLS-2$
};
+ assertEquals(upperCaseGermanTriple.length, upperCaseFranceTriple.length);
+ assertEquals(upperCaseGermanTriple.length, upperCaseCzechTriple.length);
- for (int i = 0; i < 90; i++) {
+ for (int i = 0; i < upperCaseGermanTriple.length; i++) {
String formatSpecifier = "%t" + upperCaseGermanTriple[i][pattern]; //$NON-NLS-2$
String formatSpecifierUpper = "%T" + upperCaseGermanTriple[i][pattern]; //$NON-NLS-2$
if ((Character)upperCaseGermanTriple[i][pattern] == 'N') {
final static int hmSize = 1000;
- static Object[] objArray;
-
- static Object[] objArray2;
- {
- objArray = new Object[hmSize];
- objArray2 = new Object[hmSize];
- for (int i = 0; i < objArray.length; i++) {
- objArray[i] = new Integer(i);
- objArray2[i] = objArray[i].toString();
- }
- }
+ Object[] objArray;
+ Object[] objArray2;
+
/**
* @tests java.util.HashMap#HashMap()
*/
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[hmSize];
+ objArray2 = new Object[hmSize];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ objArray2[i] = objArray[i].toString();
+ }
+
hm = new HashMap();
for (int i = 0; i < objArray.length; i++)
hm.put(objArray2[i], objArray[i]);
* method is called after a test is executed.
*/
protected void tearDown() {
+ hm = null;
+ objArray = null;
+ objArray2 = null;
}
}
HashSet hs;
- static Object[] objArray;
- {
- objArray = new Object[1000];
- for (int i = 0; i < objArray.length; i++)
- objArray[i] = new Integer(i);
- }
-
+ Object[] objArray;
+
/**
* @tests java.util.HashSet#HashSet()
*/
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[1000];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ }
+
hs = new HashSet();
- for (int i = 0; i < objArray.length; i++)
+ for (int i = 0; i < objArray.length; i++) {
hs.add(objArray[i]);
+ }
+
hs.add(null);
}
* method is called after a test is executed.
*/
protected void tearDown() {
+ hs = null;
+ objArray = null;
}
private static final SerializationTest.SerializableAssert comparator = new
* method is called after a test is executed.
*/
protected void tearDown() {
+ ht10 = null;
+ ht100 = null;
+ htfull = null;
+ keyVector = null;
+ elmVector = null;
}
}
final static int hmSize = 1000;
- static Object[] objArray;
-
- static Object[] objArray2;
- {
- objArray = new Object[hmSize];
- objArray2 = new Object[hmSize];
- for (int i = 0; i < objArray.length; i++) {
- objArray[i] = new Integer(i);
- objArray2[i] = objArray[i].toString();
- }
- }
+ Object[] objArray;
+ Object[] objArray2;
+
/**
* @tests java.util.IdentityHashMap#IdentityHashMap()
*/
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[hmSize];
+ objArray2 = new Object[hmSize];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ objArray2[i] = objArray[i].toString();
+ }
+
hm = new IdentityHashMap();
for (int i = 0; i < objArray.length; i++)
hm.put(objArray2[i], objArray[i]);
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ objArray2 = null;
+ hm = null;
}
private static final SerializationTest.SerializableAssert comparator = new
final static int hmSize = 1000;
- static Object[] objArray;
-
- static Object[] objArray2;
- {
- objArray = new Object[hmSize];
- objArray2 = new Object[hmSize];
- for (int i = 0; i < objArray.length; i++) {
- objArray[i] = new Integer(i);
- objArray2[i] = objArray[i].toString();
- }
- }
+ Object[] objArray;
+ Object[] objArray2;
+
static final class CacheMap extends LinkedHashMap {
protected boolean removeEldestEntry(Map.Entry e) {
return size() > 5;
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[hmSize];
+ objArray2 = new Object[hmSize];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ objArray2[i] = objArray[i].toString();
+ }
+
hm = new LinkedHashMap();
for (int i = 0; i < objArray.length; i++)
hm.put(objArray2[i], objArray[i]);
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ objArray2 = null;
+ hm = null;
}
}
LinkedHashSet hs;
- static Object[] objArray;
- {
- objArray = new Object[1000];
- for (int i = 0; i < objArray.length; i++)
- objArray[i] = new Integer(i);
- }
-
+ Object[] objArray;
+
/**
* @tests java.util.LinkedHashSet#LinkedHashSet()
*/
* is called before a test is executed.
*/
protected void setUp() {
+ objArray = new Object[1000];
+ for (int i = 0; i < objArray.length; i++)
+ objArray[i] = new Integer(i);
+
hs = new LinkedHashSet();
for (int i = 0; i < objArray.length; i++)
hs.add(objArray[i]);
* method is called after a test is executed.
*/
protected void tearDown() {
+ objArray = null;
+ hs = null;
}
}
LinkedList ll;
- static Object[] objArray;
- {
- objArray = new Object[100];
- for (int i = 0; i < objArray.length; i++)
- objArray[i] = new Integer(i);
- }
-
+ Object[] objArray;
+
/**
* @tests java.util.LinkedList#LinkedList()
*/
*/
protected void setUp() throws Exception {
super.setUp();
+
+ objArray = new Object[100];
+ for (int i = 0; i < objArray.length; i++) {
+ objArray[i] = new Integer(i);
+ }
+
ll = new LinkedList();
for (int i = 0; i < objArray.length; i++) {
ll.add(objArray[i]);
}
}
+
+ @Override
+ protected void tearDown() throws Exception {
+ objArray = null;
+ ll = null;
+
+ super.tearDown();
+ }
}