KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > deployment > HotDeployedTest


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package test.deployment;
9
10 import junit.framework.TestCase;
11 import test.annotation.DefaultValueTest;
12 import org.codehaus.aspectwerkz.transform.inlining.deployer.Deployer;
13
14 /**
15  * @author <a HREF="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
16  */

17 public class HotDeployedTest extends TestCase {
18
19     static int HIT = 0;
20
21     public void target() {
22         HIT++;
23     }
24
25     public void testDeployment() {
26         // is deployed from beginning
27
target();
28         assertEquals(1, HIT);
29         assertEquals(1, HotdeployableAspect.HIT);
30
31         // undeploy
32
Deployer.undeploy(HotdeployableAspect.class);
33
34         target();
35         assertEquals(2, HIT);
36         assertEquals(1, HotdeployableAspect.HIT);
37
38         // redeploy
39
Deployer.deploy(HotdeployableAspect.class);
40         target();
41         assertEquals(3, HIT);
42         assertEquals(2, HotdeployableAspect.HIT);
43     }
44
45
46
47
48     public static void main(String JavaDoc[] args) {
49         junit.textui.TestRunner.run(suite());
50     }
51
52     public static junit.framework.Test suite() {
53         return new junit.framework.TestSuite(HotDeployedTest.class);
54     }
55
56 }
57
Popular Tags