01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
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:
16: package org.acegisecurity.intercept.method;
17:
18: import junit.framework.TestCase;
19:
20: import org.acegisecurity.util.SimpleMethodInvocation;
21:
22: import org.aopalliance.intercept.MethodInvocation;
23:
24: /**
25: * Tests {@link AbstractMethodDefinitionSource} and associated {@link ConfigAttributeDefinition}.
26: *
27: * @author Ben Alex
28: * @version $Id: AbstractMethodDefinitionSourceTests.java 1496 2006-05-23 13:38:33Z benalex $
29: */
30: public class AbstractMethodDefinitionSourceTests extends TestCase {
31: //~ Constructors ===================================================================================================
32:
33: public AbstractMethodDefinitionSourceTests() {
34: super ();
35: }
36:
37: public AbstractMethodDefinitionSourceTests(String arg0) {
38: super (arg0);
39: }
40:
41: //~ Methods ========================================================================================================
42:
43: public static void main(String[] args) {
44: junit.textui.TestRunner
45: .run(AbstractMethodDefinitionSourceTests.class);
46: }
47:
48: public final void setUp() throws Exception {
49: super .setUp();
50: }
51:
52: public void testDoesNotSupportAnotherObject() {
53: MockMethodDefinitionSource mds = new MockMethodDefinitionSource(
54: false, true);
55: assertFalse(mds.supports(String.class));
56: }
57:
58: public void testGetAttributesForANonMethodInvocation() {
59: MockMethodDefinitionSource mds = new MockMethodDefinitionSource(
60: false, true);
61:
62: try {
63: mds.getAttributes(new String());
64: fail("Should have thrown IllegalArgumentException");
65: } catch (IllegalArgumentException expected) {
66: assertTrue(true);
67: }
68: }
69:
70: public void testGetAttributesForANullObject() {
71: MockMethodDefinitionSource mds = new MockMethodDefinitionSource(
72: false, true);
73:
74: try {
75: mds.getAttributes(null);
76: fail("Should have thrown IllegalArgumentException");
77: } catch (IllegalArgumentException expected) {
78: assertTrue(true);
79: }
80: }
81:
82: public void testGetAttributesForMethodInvocation() {
83: MockMethodDefinitionSource mds = new MockMethodDefinitionSource(
84: false, true);
85:
86: try {
87: mds.getAttributes(new SimpleMethodInvocation());
88: fail("Should have thrown UnsupportedOperationException");
89: } catch (UnsupportedOperationException expected) {
90: assertTrue(true);
91: }
92: }
93:
94: public void testSupportsMethodInvocation() {
95: MockMethodDefinitionSource mds = new MockMethodDefinitionSource(
96: false, true);
97: assertTrue(mds.supports(MethodInvocation.class));
98: }
99: }
|