001: package com.clarkware.junitperf;
002:
003: import junit.framework.TestCase;
004:
005: public class MockTest extends TestCase {
006:
007: public MockTest(String name) {
008: super (name);
009: }
010:
011: public void testSuccess() {
012: }
013:
014: public void testFailure() {
015: fail();
016: }
017:
018: public void testError() {
019: throw new RuntimeException();
020: }
021:
022: public void testOneSecondExecutionTime() throws Exception {
023: Thread.sleep(1000);
024: }
025:
026: public void testOneSecondExecutionTimeWithFailure()
027: throws Exception {
028: Thread.sleep(1000);
029: fail();
030: }
031:
032: public void testInfiniteExecutionTime() {
033: while (true) {
034: }
035: }
036:
037: public void testLongExecutionTime() {
038: try {
039: Thread.sleep(60000);
040: } catch (InterruptedException ignored) {
041: }
042: }
043:
044: public void testAtomic2SecondResponseWithWorkerThread() {
045:
046: Thread t = new Thread(new Runnable() {
047: public void run() {
048: try {
049: Thread.sleep(2000);
050: } catch (InterruptedException ignored) {
051: }
052: }
053: });
054:
055: t.start();
056:
057: try {
058: Thread.sleep(1000);
059: // don't wait for worker thread to finish
060: } catch (InterruptedException ignored) {
061: }
062: }
063:
064: public void testNonAtomic2SecondResponseWithWorkerThread() {
065:
066: Thread t = new Thread(new Runnable() {
067: public void run() {
068: try {
069: Thread.sleep(2000);
070: } catch (InterruptedException ignored) {
071: }
072: }
073: });
074:
075: t.start();
076:
077: try {
078:
079: Thread.sleep(1000);
080: // wait for worker thread to finish
081: t.join();
082:
083: } catch (InterruptedException ignored) {
084: }
085: }
086:
087: public void testRogueThread() {
088:
089: Thread t = new Thread(new Runnable() {
090: public void run() {
091: while (true) {
092: try {
093: Thread.sleep(100);
094: } catch (Exception ignored) {
095: }
096: }
097: }
098: });
099:
100: t.start();
101:
102: assertTrue(true);
103: }
104: }
|