1 22 package org.jboss.test.aop.args; 23 24 import org.jboss.test.aop.AOPTestWithSetup; 25 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 import junit.textui.TestRunner; 29 30 31 35 public class ArgsTestCase extends AOPTestWithSetup 36 { 37 38 public static void main(String [] args) 39 { 40 TestRunner.run(suite()); 41 } 42 43 public static Test suite() 44 { 45 TestSuite suite = new TestSuite("AnnotatedTester"); 46 suite.addTestSuite(ArgsTestCase.class); 47 return suite; 48 } 49 50 public ArgsTestCase(String name) 51 { 52 super(name); 53 } 54 55 public void testBench() 56 { 57 POJO pojo = new POJO(); 58 59 { 60 long start = System.currentTimeMillis(); 61 for (int i = 0; i < 1000000; i++) 62 { 63 pojo.bunchArgs(1, 2.2, 3.3F, "four", 5); 64 } 65 long end = System.currentTimeMillis() - start; 66 System.out.println("bunchArgs: " + end); 67 } 68 69 { 70 long start = System.currentTimeMillis(); 71 for (int i = 0; i < 1000000; i++) 72 { 73 pojo.bunchWrapped(1, 2.2, 3.3F, "four", 5); 74 } 75 long end = System.currentTimeMillis() - start; 76 System.out.println("bunchWrapped: " + end); 77 } 78 79 { 80 long start = System.currentTimeMillis(); 81 for (int i = 0; i < 1000000; i++) 82 { 83 pojo.bunchArgsWithInvocation(1, 2.2, 3.3F, "four", 5); 84 } 85 long end = System.currentTimeMillis() - start; 86 System.out.println("bunchArgsWithInvocation: " + end); 87 } 88 89 assertTrue(Aspect.argsWithInvocation); 90 assertTrue(Aspect.args); 91 assertTrue(Aspect.wrapped); 92 93 } 94 95 public void testEcho() 96 { 97 POJO pojo = new POJO(); 98 99 Aspect.echoCalled = false; 100 pojo.echo("hello"); 101 assertTrue(Aspect.echoCalled); 102 } 103 104 public void testBunch() 105 { 106 POJO pojo = new POJO(); 107 108 Aspect.bunchCalled = false; 109 Aspect.arg1Called = false; 110 Aspect.arg2Called = false; 111 Aspect.arg3Called = false; 112 Aspect.arg4Called = false; 113 Aspect.arg15Called = false; 114 Aspect.arg24Called = false; 115 pojo.bunch(1, 2.2, 3.3F, "four", 5); 116 assertTrue(Aspect.bunchCalled); 117 assertTrue(Aspect.arg1Called); 118 assertTrue(Aspect.arg2Called); 119 assertTrue(Aspect.arg3Called); 120 assertTrue(Aspect.arg4Called); 121 assertTrue(Aspect.arg15Called); 122 assertTrue(Aspect.arg24Called); 123 } 124 125 } 126 | Popular Tags |