1
2
3
4
5
6
7
8
9
10
11
12
13
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 /***
26 * Tests {@link AbstractMethodDefinitionSource} and associated {@link
27 * ConfigAttributeDefinition}.
28 *
29 * @author Ben Alex
30 * @version $Id: AbstractMethodDefinitionSourceTests.java,v 1.3 2005/11/25 04:17:24 benalex Exp $
31 */
32 public class AbstractMethodDefinitionSourceTests extends TestCase {
33
34
35 public AbstractMethodDefinitionSourceTests() {
36 super();
37 }
38
39 public AbstractMethodDefinitionSourceTests(String arg0) {
40 super(arg0);
41 }
42
43
44
45 public final void setUp() throws Exception {
46 super.setUp();
47 }
48
49 public static void main(String[] args) {
50 junit.textui.TestRunner.run(AbstractMethodDefinitionSourceTests.class);
51 }
52
53 public void testDoesNotSupportAnotherObject() {
54 MockMethodDefinitionSource mds = new MockMethodDefinitionSource(false,
55 true);
56 assertFalse(mds.supports(String.class));
57 }
58
59 public void testGetAttributesForANonMethodInvocation() {
60 MockMethodDefinitionSource mds = new MockMethodDefinitionSource(false,
61 true);
62
63 try {
64 mds.getAttributes(new String());
65 fail("Should have thrown IllegalArgumentException");
66 } catch (IllegalArgumentException expected) {
67 assertTrue(true);
68 }
69 }
70
71 public void testGetAttributesForANullObject() {
72 MockMethodDefinitionSource mds = new MockMethodDefinitionSource(false,
73 true);
74
75 try {
76 mds.getAttributes(null);
77 fail("Should have thrown IllegalArgumentException");
78 } catch (IllegalArgumentException expected) {
79 assertTrue(true);
80 }
81 }
82
83 public void testGetAttributesForMethodInvocation() {
84 MockMethodDefinitionSource mds = new MockMethodDefinitionSource(false,
85 true);
86
87 try {
88 mds.getAttributes(new SimpleMethodInvocation());
89 fail("Should have thrown UnsupportedOperationException");
90 } catch (UnsupportedOperationException expected) {
91 assertTrue(true);
92 }
93 }
94
95 public void testSupportsMethodInvocation() {
96 MockMethodDefinitionSource mds = new MockMethodDefinitionSource(false,
97 true);
98 assertTrue(mds.supports(MethodInvocation.class));
99 }
100 }