ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ExchangerTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ExchangerTest.java (file contents):
Revision 1.2 by dl, Sun Sep 14 20:42:40 2003 UTC vs.
Revision 1.3 by dl, Sat Sep 20 18:20:07 2003 UTC

# Line 18 | Line 18 | public class ExchangerTest extends JSR16
18          return new TestSuite(ExchangerTest.class);
19      }
20  
21 +    /**
22 +     *
23 +     */
24      public void testExchange() {
25          final Exchanger e = new Exchanger();
26          Thread t1 = new Thread(new Runnable(){
# Line 28 | Line 31 | public class ExchangerTest extends JSR16
31                          Object w = e.exchange(v);
32                          threadAssertEquals(w, one);
33                      } catch(InterruptedException e){
34 <                        threadFail("unexpected exception");
34 >                        threadUnexpectedException();
35                      }
36                  }
37              });
# Line 40 | Line 43 | public class ExchangerTest extends JSR16
43                          Object w = e.exchange(v);
44                          threadAssertEquals(w, two);
45                      } catch(InterruptedException e){
46 <                        threadFail("unexpected exception");
46 >                        threadUnexpectedException();
47                      }
48                  }
49              });
# Line 50 | Line 53 | public class ExchangerTest extends JSR16
53              t1.join();
54              t2.join();
55          } catch(InterruptedException ex) {
56 <            fail("unexpected exception");
56 >            unexpectedException();
57          }
58      }
59  
60 +    /**
61 +     *
62 +     */
63      public void testTimedExchange() {
64          final Exchanger e = new Exchanger();
65          Thread t1 = new Thread(new Runnable(){
# Line 64 | Line 70 | public class ExchangerTest extends JSR16
70                          Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
71                          threadAssertEquals(w, one);
72                      } catch(InterruptedException e){
73 <                        threadFail("unexpected exception");
73 >                        threadUnexpectedException();
74                      } catch(TimeoutException toe) {
75 <                        threadFail("unexpected exception");
75 >                        threadUnexpectedException();
76                      }
77                  }
78              });
# Line 78 | Line 84 | public class ExchangerTest extends JSR16
84                          Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
85                          threadAssertEquals(w, two);
86                      } catch(InterruptedException e){
87 <                        threadFail("unexpected exception");
87 >                        threadUnexpectedException();
88                      } catch(TimeoutException toe) {
89 <                        threadFail("unexpected exception");
89 >                        threadUnexpectedException();
90                      }
91                  }
92              });
# Line 90 | Line 96 | public class ExchangerTest extends JSR16
96              t1.join();
97              t2.join();
98          } catch(InterruptedException ex) {
99 <            fail("unexpected exception");
99 >            unexpectedException();
100          }
101      }
102  
103 +    /**
104 +     *
105 +     */
106      public void testExchange_InterruptedException(){
107          final Exchanger e = new Exchanger();
108          Thread t = new Thread(new Runnable() {
109                  public void run(){
110                      try {
111                          e.exchange(one);
112 <                        threadFail("should throw");
112 >                        threadShouldThrow();
113                      } catch(InterruptedException success){
114                      }
115                  }
# Line 111 | Line 120 | public class ExchangerTest extends JSR16
120              t.interrupt();
121              t.join();
122          } catch(InterruptedException ex) {
123 <            fail("unexpected exception");
123 >            unexpectedException();
124          }
125      }
126  
127 +    /**
128 +     *
129 +     */
130      public void testTimedExchange_InterruptedException(){
131          final Exchanger e = new Exchanger();
132          Thread t = new Thread(new Runnable() {
133                  public void run(){
134                      try {
135                          e.exchange(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
136 <                        threadFail("should throw");
136 >                        threadShouldThrow();
137                      } catch(InterruptedException success){
138                      } catch(Exception e2){
139                          threadFail("should throw IE");
# Line 133 | Line 145 | public class ExchangerTest extends JSR16
145              t.interrupt();
146              t.join();
147          } catch(InterruptedException ex){
148 <            fail("unexpected exception");
148 >            unexpectedException();
149          }
150      }
151  
152 +    /**
153 +     *
154 +     */
155      public void testExchange_TimeOutException(){
156          final Exchanger e = new Exchanger();
157          Thread t = new Thread(new Runnable() {
158                  public void run(){
159                      try {
160                          e.exchange(null, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
161 <                        threadFail("should throw");
161 >                        threadShouldThrow();
162                      } catch(TimeoutException success){
163                      } catch(InterruptedException e2){
164                          threadFail("should throw TOE");
# Line 154 | Line 169 | public class ExchangerTest extends JSR16
169              t.start();
170              t.join();
171          } catch(InterruptedException ex){
172 <            fail("unexpected exception");
172 >            unexpectedException();
173          }
174      }
175   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines