• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.google.common.testing;
17 public class TearDownStackTest_gwt extends com.google.gwt.junit.client.GWTTestCase {
getModuleName()18 @Override public String getModuleName() {
19   return "com.google.common.testing.testModule";
20 }
testMultipleTearDownsHappenInOrder()21 public void testMultipleTearDownsHappenInOrder() throws Exception {
22   com.google.common.testing.TearDownStackTest testCase = new com.google.common.testing.TearDownStackTest();
23   Throwable failure = null;
24   try {
25     testCase.testMultipleTearDownsHappenInOrder();
26   } catch (Throwable t) {
27     failure = t;
28   }
29   try {
30     testCase.tearDown();
31   } catch (Throwable t) {
32     if (failure == null) {
33       failure = t;
34     }
35   }
36   if (failure instanceof Exception) {
37     throw (Exception) failure;
38   }
39   if (failure instanceof Error) {
40     throw (Error) failure;
41   }
42   if (failure != null) {
43     throw new RuntimeException(failure);
44   }
45 }
46 
testSingleTearDown()47 public void testSingleTearDown() throws Exception {
48   com.google.common.testing.TearDownStackTest testCase = new com.google.common.testing.TearDownStackTest();
49   Throwable failure = null;
50   try {
51     testCase.testSingleTearDown();
52   } catch (Throwable t) {
53     failure = t;
54   }
55   try {
56     testCase.tearDown();
57   } catch (Throwable t) {
58     if (failure == null) {
59       failure = t;
60     }
61   }
62   if (failure instanceof Exception) {
63     throw (Exception) failure;
64   }
65   if (failure instanceof Error) {
66     throw (Error) failure;
67   }
68   if (failure != null) {
69     throw new RuntimeException(failure);
70   }
71 }
72 
testThrowingTearDown()73 public void testThrowingTearDown() throws Exception {
74   com.google.common.testing.TearDownStackTest testCase = new com.google.common.testing.TearDownStackTest();
75   Throwable failure = null;
76   try {
77     testCase.testThrowingTearDown();
78   } catch (Throwable t) {
79     failure = t;
80   }
81   try {
82     testCase.tearDown();
83   } catch (Throwable t) {
84     if (failure == null) {
85       failure = t;
86     }
87   }
88   if (failure instanceof Exception) {
89     throw (Exception) failure;
90   }
91   if (failure instanceof Error) {
92     throw (Error) failure;
93   }
94   if (failure != null) {
95     throw new RuntimeException(failure);
96   }
97 }
98 }
99