01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.ioc.internal.util;
16:
17: import org.apache.tapestry.ioc.test.IOCTestCase;
18: import org.testng.annotations.Test;
19:
20: public class OneShotLockTest extends IOCTestCase {
21: private static final String CLASS_NAME = OneShotLockSubject.class
22: .getName();
23:
24: @Test
25: public void basic_locking() {
26: OneShotLockSubject s = new OneShotLockSubject();
27:
28: s.go();
29:
30: s.done();
31:
32: try {
33: s.go();
34: unreachable();
35: } catch (IllegalStateException ex) {
36: assertTrue(ex.getMessage().contains(CLASS_NAME + ".go"));
37: assertTrue(ex.getMessage().contains(
38: "may no longer be invoked."));
39: }
40: }
41:
42: @Test
43: public void locking_method_includes_check() {
44: OneShotLockSubject s = new OneShotLockSubject();
45:
46: s.go();
47:
48: s.done();
49:
50: try {
51: s.done();
52: unreachable();
53: } catch (IllegalStateException ex) {
54: assertTrue(ex.getMessage().contains(CLASS_NAME + ".done"));
55: assertTrue(ex.getMessage().contains(
56: "may no longer be invoked."));
57: }
58: }
59:
60: }
|