KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > args > ArgsTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

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 /**
32  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
33  * @version $Revision: 45977 $
34  */

35 public class ArgsTestCase extends AOPTestWithSetup
36 {
37
38    public static void main(String JavaDoc[] 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 JavaDoc 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