KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > interceptor > CustomizableTraceInterceptorTests


1 /*
2  * Copyright 2002-2005 the original author or 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
17 package org.springframework.aop.interceptor;
18
19 import junit.framework.TestCase;
20
21 import org.springframework.core.JdkVersion;
22
23 /**
24  * @author Rob Harrop
25  */

26 public class CustomizableTraceInterceptorTests extends TestCase {
27
28     public void testSetEmptyEnterMessage() {
29         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
30             return;
31         }
32         try {
33             new CustomizableTraceInterceptor().setEnterMessage("");
34             fail("Should not be able to set empty enter message");
35         }
36         catch (IllegalArgumentException JavaDoc ex) {
37             // success
38
}
39     }
40
41     public void testSetEnterMessageWithReturnValuePlaceholder() {
42         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
43             return;
44         }
45         try {
46             new CustomizableTraceInterceptor().setEnterMessage(CustomizableTraceInterceptor.PLACEHOLDER_RETURN_VALUE);
47             fail("Should not be able to set enter message with return value placeholder");
48         }
49         catch (IllegalArgumentException JavaDoc ex) {
50             // success
51
}
52     }
53
54     public void testSetEnterMessageWithExceptionPlaceholder() {
55         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
56             return;
57         }
58         try {
59             new CustomizableTraceInterceptor().setEnterMessage(CustomizableTraceInterceptor.PLACEHOLDER_EXCEPTION);
60             fail("Should not be able to set enter message with exception placeholder");
61         }
62         catch (IllegalArgumentException JavaDoc ex) {
63             // success
64
}
65     }
66
67     public void testSetEnterMessageWithInvocationTimePlaceholder() {
68         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
69             return;
70         }
71         try {
72             new CustomizableTraceInterceptor().setEnterMessage(CustomizableTraceInterceptor.PLACEHOLDER_INVOCATION_TIME);
73             fail("Should not be able to set enter message with invocation time placeholder");
74         }
75         catch (IllegalArgumentException JavaDoc ex) {
76             // success
77
}
78     }
79
80     public void testSetEmptyExitMessage() {
81         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
82             return;
83         }
84         try {
85             new CustomizableTraceInterceptor().setExitMessage("");
86             fail("Should not be able to set empty exit message");
87         }
88         catch (IllegalArgumentException JavaDoc ex) {
89             // success
90
}
91     }
92
93     public void testSetExitMessageWithExceptionPlaceholder() {
94         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
95             return;
96         }
97         try {
98             new CustomizableTraceInterceptor().setExitMessage(CustomizableTraceInterceptor.PLACEHOLDER_EXCEPTION);
99             fail("Should not be able to set exit message with exception placeholder");
100         }
101         catch (IllegalArgumentException JavaDoc ex) {
102             // success
103
}
104     }
105
106     public void testSetEmptyExceptionMessage() {
107         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
108             return;
109         }
110         try {
111             new CustomizableTraceInterceptor().setExceptionMessage("");
112             fail("Should not be able to set empty exception message");
113         }
114         catch (IllegalArgumentException JavaDoc ex) {
115             // success
116
}
117     }
118
119     public void testSetExceptionMethodWithReturnValuePlaceholder() {
120         if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) {
121             return;
122         }
123         try {
124             new CustomizableTraceInterceptor().setExceptionMessage(CustomizableTraceInterceptor.PLACEHOLDER_RETURN_VALUE);
125             fail("Should not be able to set exception message with return value placeholder");
126         }
127         catch (IllegalArgumentException JavaDoc ex) {
128             // success
129
}
130     }
131
132 }
133
Popular Tags