1 16 17 package org.springframework.aop.interceptor; 18 19 import junit.framework.TestCase; 20 21 import org.springframework.core.JdkVersion; 22 23 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 ex) { 37 } 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 ex) { 50 } 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 ex) { 63 } 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 ex) { 76 } 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 ex) { 89 } 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 ex) { 102 } 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 ex) { 115 } 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 ex) { 128 } 130 } 131 132 } 133 | Popular Tags |