~ubuntu-branches/debian/squeeze/junitperf/squeeze

« back to all changes in this revision

Viewing changes to test/com/clarkware/junitperf/MockTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-11-06 12:10:29 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061106121029-0f8e7pzmig6sh1x5
Tags: 1.9.1-5
* built with java-gcj-compat-dev.
* debian/rules: 
  + removed ant-launcher.jar
  + removed the test target (closes: #396419)
* Standards-Version: 3.7.2 (no change)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.clarkware.junitperf;
 
2
 
 
3
import junit.framework.TestCase;
 
4
 
 
5
public class MockTest extends TestCase {
 
6
                
 
7
        public MockTest(String name) {
 
8
                super(name);
 
9
        }
 
10
 
 
11
        public void testSuccess() {
 
12
        }
 
13
 
 
14
        public void testFailure() {
 
15
                fail();
 
16
        }
 
17
 
 
18
        public void testError() {
 
19
                throw new RuntimeException();
 
20
        }
 
21
        
 
22
        public void testOneSecondExecutionTime() throws Exception {
 
23
                Thread.sleep(1000);
 
24
        }
 
25
 
 
26
        public void testOneSecondExecutionTimeWithFailure() throws Exception {
 
27
                Thread.sleep(1000);
 
28
                fail();
 
29
        }
 
30
 
 
31
        public void testInfiniteExecutionTime() {
 
32
                while (true) {
 
33
                }
 
34
        }
 
35
 
 
36
        public void testLongExecutionTime() {
 
37
                try {
 
38
                        Thread.sleep(60000);
 
39
                } catch (InterruptedException ignored) {}
 
40
        }
 
41
 
 
42
        public void testAtomic2SecondResponseWithWorkerThread() {
 
43
 
 
44
                Thread t = new Thread(new Runnable() {
 
45
                        public void run() {
 
46
                                try {
 
47
                                        Thread.sleep(2000);
 
48
                                } catch (InterruptedException ignored) {}
 
49
                        }
 
50
                });
 
51
 
 
52
                t.start();
 
53
 
 
54
                try {
 
55
                        Thread.sleep(1000);
 
56
                        // don't wait for worker thread to finish
 
57
                } catch (InterruptedException ignored) {}
 
58
        }
 
59
 
 
60
        public void testNonAtomic2SecondResponseWithWorkerThread() {
 
61
 
 
62
                Thread t = new Thread(new Runnable() {
 
63
                        public void run() {
 
64
                                try {
 
65
                                        Thread.sleep(2000);
 
66
                                } catch (InterruptedException ignored) {}
 
67
                        }
 
68
                });
 
69
 
 
70
                t.start();
 
71
 
 
72
                try {
 
73
 
 
74
                        Thread.sleep(1000);
 
75
                        // wait for worker thread to finish
 
76
                        t.join();
 
77
 
 
78
                } catch (InterruptedException ignored) {}
 
79
        }
 
80
 
 
81
        public void testRogueThread() {
 
82
 
 
83
                Thread t = new Thread(new Runnable() {
 
84
                        public void run() {
 
85
                                while (true) {
 
86
                                        try {
 
87
                                                Thread.sleep(100);
 
88
                                        } catch (Exception ignored) {}
 
89
                                }
 
90
                        }
 
91
                });
 
92
 
 
93
                t.start();
 
94
 
 
95
                assertTrue(true);
 
96
        }
 
97
}