KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > query > QueryManagerTest


1 // $Id: QueryManagerTest.java,v 1.2 2004/05/12 17:26:52 anicoara Exp $
2
// =====================================================================
3
//
4
// (history at end)
5
//
6

7 package ch.ethz.prose.query;
8
9 // used packages
10
import junit.framework.*;
11
12 import ch.ethz.prose.DefaultAspect;
13 import ch.ethz.prose.ProseSystem;
14 import ch.ethz.prose.crosscut.Crosscut;
15 import ch.ethz.prose.crosscut.MethodCut;
16 import ch.ethz.prose.filter.PointCutter;
17 import ch.ethz.prose.filter.Within;
18
19
20
21 /**
22  * JUnit testcase for class XXX.
23  *
24  * @version $Revision: 1.2 $
25  * @author Andrei Popovici
26  */

27 public
28 class QueryManagerTest extends TestCase {
29
30     /**
31      * Construct test with given name.
32      * @param name test name
33      */

34     public QueryManagerTest(String JavaDoc name)
35     {
36         super(name);
37     }
38
39     public static class QMCrosscut extends MethodCut
40     {
41         public void METHOD_ARGS(QueryManagerTest tst, int i)
42         {}
43     
44         protected PointCutter pointCutter()
45         {
46             return Within.method("salut");
47         }
48     };
49
50     public static class QMAspect1 extends DefaultAspect
51     {
52         public Crosscut c1 = new QMCrosscut();
53         public Crosscut c2 = new QMCrosscut();
54         public Crosscut c3 = new QMCrosscut();
55     }
56
57     public static class QMAspect2 extends DefaultAspect
58     {
59         public Crosscut c1 = new QMCrosscut();
60     }
61
62     QMAspect1 a1 = null;
63     QMAspect2 a2 = null;
64     QueryManager qMgr = null;
65   /**
66    * Set up fixture.
67    */

68     protected
69     void setUp() throws Exception JavaDoc
70     {
71         ProseSystem.startup();
72         a1 = new QMAspect1();
73         a2 = new QMAspect2();
74         qMgr = new QueryManager(ProseSystem.getAspectManager());
75     }
76
77     protected void tearDown() throws Exception JavaDoc
78     {
79         ProseSystem.teardown();
80     }
81
82   /**
83    * Test suite.
84    * @return test instance
85    */

86   public static
87   Test suite()
88   {
89     return new TestSuite(QueryManagerTest.class);
90   }
91
92
93     public void testReconstructAspect() throws Exception JavaDoc
94     {
95         ProseSystem.getAspectManager().insert(a1);
96         ProseSystem.getAspectManager().insert(a2);
97     
98         AspectSurrogate as1 = new AspectSurrogate(a1);
99     
100         assertSame("a1 == as1.reconstruct",a1,qMgr.reconstructAspect(as1));
101         assertEquals("a1 EQUALS as1.reconstruct",a1,qMgr.reconstructAspect(as1));
102     
103         ProseSystem.getAspectManager().withdraw(a1);
104         assertNull("a1.reconstruct = null",qMgr.reconstructAspect(as1));
105     }
106
107     public void testReconstructCrosscut() throws Exception JavaDoc
108     {
109         ProseSystem.getAspectManager().insert(a1);
110     
111         AspectSurrogate as1 = new AspectSurrogate(a1);
112         CrosscutSurrogate cs2 = new CrosscutSurrogate(as1,a1.c2);
113     
114         assertSame("a1.c2 == cs3.reconstruct",a1.c2,qMgr.reconstructCrosscut(cs2));
115         ProseSystem.getAspectManager().withdraw(a1);
116     
117         assertNull("a1.c2.reconstruct = null",qMgr.reconstructCrosscut(cs2));
118     }
119 }
120
121
122 //======================================================================
123
//
124
// $Log: QueryManagerTest.java,v $
125
// Revision 1.2 2004/05/12 17:26:52 anicoara
126
// Adapt Junit tests to 3.8.1 version and the new package structure
127
//
128
// Revision 1.1.1.1 2003/07/02 15:30:43 apopovic
129
// Imported from ETH Zurich
130
//
131
// Revision 1.1 2003/05/25 13:02:15 popovici
132
// Initial Revision
133
//
134
Popular Tags