Merge "Fix a test's incorrect expectations." into dalvik-dev
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
index 7ac69e9..d4cac1f 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java
@@ -472,87 +472,6 @@
 	}
 
 	/**
-	 * @tests java.lang.ThreadGroup#resume()
-	 */
-	@SuppressWarnings("deprecation")
-    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);
-
-		boolean[] isResumed = null;
-		try {
-			try {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.start();
-					t.suspend();
-				}
-				// In 5.0, activeCount() only returns threads that are alive
-				assertTrue("Internal error when populating ThreadGroups", testRoot
-						.activeCount() == threads.size());
-			} catch (OutOfMemoryError e) {
-				for (int i = 0; i < threads.size(); i++) {
-					Thread t = threads.elementAt(i);
-					t.resume();
-					t.stop(); // deprecated but effective
-				}
-				throw e;
-			}
-
-			// Now that they are all suspended, let's resume the ThreadGroup
-			testRoot.resume();
-
-			// Give them some time to really resume
-			try {
-				Thread.sleep(500);
-			} catch (InterruptedException ie) {
-				fail("Should not have been interrupted");
-			}
-
-			isResumed = new boolean[threads.size()];
-			boolean failed = false;
-			for (int i = 0; i < isResumed.length; i++) {
-				MyThread t = threads.elementAt(i);
-				if (!failed) { // if one failed, don't waste time checking the
-					// rest
-					isResumed[i] = t.isActivelyRunning(1000);
-					failed = failed | (!isResumed[i]);
-				}
-				t.stop(); // deprecated but effective
-			}
-
-			// Give them some time to really die
-			try {
-				Thread.sleep(500);
-			} catch (InterruptedException ie) {
-				fail("Should not have been interrupted");
-			}
-		} finally {
-			// Make sure we do cleanup before returning
-			testRoot.destroy();
-		}
-
-		for (int i = 0; i < isResumed.length; i++) {
-			assertTrue("Thread " + threads.elementAt(i)
-					+ " was not running when it was killed", isResumed[i]);
-		}
-
-		assertEquals("Method destroy must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
 	 * @tests java.lang.ThreadGroup#setDaemon(boolean)
 	 */
 	public void test_setDaemonZ() {
@@ -681,177 +600,6 @@
 	}
 
 	/**
-	 * @tests java.lang.ThreadGroup#stop()
-	 */
-	@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.stop(); // deprecated but effective
-			}
-			throw e;
-		}
-
-		// Now that they are all running, let's stop the ThreadGroup
-		testRoot.stop();
-
-		// stop is an async call. The thread may take a while to stop. We have
-		// to wait for all of them to stop. However, if stop does not work,
-		// we'd have to wait forever. So, we wait with a timeout, and if the
-		// Thread is still alive, we assume stop for ThreadGroups does not
-		// work. How much we wait (timeout) is very important
-		boolean passed = true;
-		for (int i = 0; i < threads.size(); i++) {
-			Thread t = threads.elementAt(i);
-			try {
-				// We wait 5000 ms per Thread, but due to scheduling it may
-				// take a while to run
-				t.join(5000);
-			} catch (InterruptedException ie) {
-				fail("Should not be interrupted");
-			}
-			if (t.isAlive()) {
-				passed = false;
-				break;
-			}
-		}
-
-		// To make sure that even if we fail, we exit in a clean state
-		testRoot.destroy();
-
-		assertTrue("Thread should be dead by now", passed);
-
-		assertEquals("Method destroy (or wipeAllThreads) must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
-	 * @tests java.lang.ThreadGroup#suspend()
-	 */
-	@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);
-
-		boolean passed = false;
-		try {
-			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.stop(); // deprecated but effective
-				}
-				throw e;
-			}
-
-			// Now that they are all running, let's suspend the ThreadGroup
-			testRoot.suspend();
-
-			passed = allSuspended(threads);
-			assertTrue("Should be able to wipe all threads (allSuspended="
-					+ passed + ")", wipeAllThreads(testRoot));
-		} finally {
-
-			// We can't destroy a ThreadGroup if we do not make sure it has no
-			// threads at all
-            testRoot.stop();
-            long waitTime = 5000;
-            for (int i = 0; i < threads.size(); i++) {
-                Thread t = threads.elementAt(i);
-                while (t.isAlive() && waitTime >= 0) {
-                   try {
-                      Thread.sleep(10);
-                      waitTime -= 10;
-                   } catch (InterruptedException e) {
-                      fail("unexpected interruption");
-                   }
-                }
-                if (waitTime < 0) {
-                   fail("stop() has not stopped threads in ThreadGroup 'testRoot'");
-                }
-             }
-			// Make sure we cleanup before returning from the method
-			testRoot.destroy();
-		}
-		assertTrue("All threads should be suspended", passed);
-
-		assertEquals("Method destroy (or wipeAllThreads) must have problems",
-				0, testRoot.activeCount());
-
-	}
-
-	/**
-	 * @tests java.lang.ThreadGroup#toString()
-	 */
-	public void test_toString() {
-		// Test for method java.lang.String java.lang.ThreadGroup.toString()
-
-		final ThreadGroup originalCurrent = getInitialThreadGroup();
-		final String tGroupName = "Test group";
-
-		// Our own subclass
-		class MyThreadGroup extends ThreadGroup {
-			// Have to define a constructor since there's no default one
-			public MyThreadGroup(ThreadGroup parent, String name) {
-				super(parent, name);
-			}
-		}
-		;
-
-		ThreadGroup testRoot = new MyThreadGroup(originalCurrent, tGroupName);
-		final String toString = testRoot.toString();
-
-		StringBuffer expectedResult = new StringBuffer();
-		expectedResult.append(testRoot.getClass().getName());
-		expectedResult.append("[name=");
-		expectedResult.append(tGroupName);
-		expectedResult.append(",maxpri=");
-		expectedResult.append(testRoot.getMaxPriority());
-		expectedResult.append("]");
-
-		String expectedValue = expectedResult.toString();
-
-		assertTrue("toString does not follow the Java language spec.", toString
-				.equals(expectedValue));
-
-		testRoot.destroy();
-	}
-
-	/**
 	 * @tests java.lang.ThreadGroup#uncaughtException(java.lang.Thread,
 	 *        java.lang.Throwable)
 	 */
@@ -897,43 +645,6 @@
 			}
 		};
 
-		// Test if a Thread tells its ThreadGroup about ThreadDeath
-		thread = new Thread(testRoot, null, "victim thread (to be killed)") {
-			@Override
-            public void run() {
-				while (true) {
-					Thread.yield();
-				}
-			}
-		};
-		thread.start();
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		// we know this is deprecated, but we must test this scenario.
-		// When we stop a thread, it is tagged as not alive even though it is
-		// still running code.
-		// join would be a no-op, and we might have a race condition. So, to
-		// play safe, we wait before joining & testing if the exception was
-		// really forwarded to the ThreadGroup
-		thread.stop();
-		try {
-			Thread.sleep(1000);
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		try {
-			thread.join();
-		} catch (InterruptedException ie) {
-			fail("Should not have been interrupted");
-		}
-		testRoot.destroy();
-		assertTrue(
-				"Any thread should notify its ThreadGroup about its own death, even if killed:"
-						+ testRoot, passed[TEST_KILLING]);
-
 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 		// - - - - - - -
 		testRoot = new ThreadGroup(originalCurrent,
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
index ba35ada..4816975 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/ThreadTest.java
@@ -742,38 +742,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Thread#resume()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_resume() {
-		// Test for method void java.lang.Thread.resume()
-		int orgval;
-		ResSupThread t;
-		try {
-			t = new ResSupThread(Thread.currentThread());
-			synchronized (t) {
-				ct = new Thread(t, "Interrupt Test2");
-				ct.start();
-				t.wait();
-			}
-			ct.suspend();
-			// Wait to be sure the suspend has occurred
-			Thread.sleep(500);
-			orgval = t.getCheckVal();
-			// Wait to be sure the thread is suspended
-			Thread.sleep(500);
-			assertTrue("Failed to suspend thread", orgval == t.getCheckVal());
-			ct.resume();
-			// Wait to be sure the resume has occurred.
-			Thread.sleep(500);
-			assertTrue("Failed to resume thread", orgval != t.getCheckVal());
-			ct.interrupt();
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt occurred : " + e.getMessage());
-		}
-	}
-
-	/**
 	 * @tests java.lang.Thread#run()
 	 */
 	public void test_run() {
@@ -906,115 +874,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Thread#stop()
-	 */
-	@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();
-			}
-
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt received");
-		}
-		st.stop();
-
-		try {
-			st.join(10000);
-		} catch (InterruptedException e1) {
-			st.interrupt();
-			fail("Failed to stopThread before 10000 timeout");
-		}
-		assertTrue("Failed to stopThread", !st.isAlive());
-	}
-
-	/**
-	 * @tests java.lang.Thread#stop(java.lang.Throwable)
-	 */
-	@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) {
-			}
-		}
-		try {
-			st.stop(new BogusException("Bogus"));
-			Thread.sleep(20000);
-		} catch (InterruptedException e) {
-			assertTrue("Stopped child with exception not alive", st.isAlive());
-			st.interrupt();
-			return;
-		}
-		st.interrupt();
-		fail("Stopped child did not throw exception");
-	}
-
-	/**
-	 * @tests java.lang.Thread#suspend()
-	 */
-	@SuppressWarnings("deprecation")
-    public void test_suspend() {
-		// Test for method void java.lang.Thread.suspend()
-		int orgval;
-		ResSupThread t = new ResSupThread(Thread.currentThread());
-		try {
-			synchronized (t) {
-				ct = new Thread(t, "Interupt Test6");
-				ct.start();
-				t.wait();
-			}
-			ct.suspend();
-			// Wait to be sure the suspend has occurred
-			Thread.sleep(500);
-			orgval = t.getCheckVal();
-			// Wait to be sure the thread is suspended
-			Thread.sleep(500);
-			assertTrue("Failed to suspend thread", orgval == t.getCheckVal());
-			ct.resume();
-			// Wait to be sure the resume has occurred.
-			Thread.sleep(500);
-			assertTrue("Failed to resume thread", orgval != t.getCheckVal());
-			ct.interrupt();
-		} catch (InterruptedException e) {
-			fail("Unexpected interrupt occurred");
-		}
-
-		final Object notify = new Object();
-		Thread t1 = new Thread(new Runnable() {
-			public void run() {
-				synchronized (notify) {
-					notify.notify();
-				}
-				Thread.currentThread().suspend();
-			}
-		});
-		try {
-			synchronized (notify) {
-				t1.start();
-				notify.wait();
-			}
-			// wait for Thread to suspend
-			Thread.sleep(500);
-			assertTrue("Thread should be alive", t1.isAlive());
-			t1.resume();
-			t1.join();
-		} catch (InterruptedException e) {
-		}
-	}
-
-	/**
 	 * @tests java.lang.Thread#toString()
 	 */
 	public void test_toString() {