KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > crosscut > AllLocationsTest


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

7 package ch.ethz.prose.crosscut;
8
9 // used packages
10
import java.util.Vector JavaDoc;
11
12 import junit.framework.*;
13 import ch.ethz.prose.ProseSystem;
14 import ch.ethz.prose.filter.PointCutter;
15
16 /**
17  * JUnit testcase for class AllLocations.
18  *
19  * @version $Revision: 1.2 $
20  * @author Andrei Popovici
21  */

22 public
23 class AllLocationsTest extends TestCase {
24
25   // fixture
26
static class AllLocationsExample extends MethodCut
27   {
28       protected PointCutter pointCutter()
29       {
30       return null;
31       }
32
33     public void METHOD_ARGS() {}
34
35     public CrosscutRequest doCreateRequest(Class JavaDoc c)
36     {
37         return super.doCreateRequest(c);
38     }
39   };
40
41   static class ExampleClass
42   {
43     public void method1() {}
44     public void method2()
45     {
46         System.err.println("method 2");
47     }
48     protected void method3() {}
49     void method4(){}
50   }
51
52   AllLocationsExample testCrosscut = null;
53   /**
54    * Construct test with given name.
55    * @param name test name
56    */

57   public AllLocationsTest(String JavaDoc name)
58   {
59     super(name);
60   }
61
62
63   /**
64    * Set up fixture.
65    */

66   protected
67   void setUp() throws Exception JavaDoc
68   {
69       try
70           { ProseSystem.startup();
71           testCrosscut = new AllLocationsExample();
72           // let 'testCrosscut' think it has been activated
73
testCrosscut.insertionAction(true);
74           testCrosscut.insertionAction(false);
75           }
76       catch (Exception JavaDoc e)
77         {
78           e.printStackTrace();
79           Assert.fail("ProseSystem.startup() failed");
80         }
81   }
82
83   protected
84   void tearDown()
85   {
86     try
87       { ProseSystem.teardown(); }
88     catch (Exception JavaDoc e)
89       { Assert.fail("ProseSystem.teardown() failed"); }
90   }
91
92   public void testDoCreateRequest() throws Exception JavaDoc
93   {
94     assertNotNull(testCrosscut.doCreateRequest(Vector JavaDoc.class));
95     assertTrue("some public methods in there", testCrosscut.doCreateRequest(Vector JavaDoc.class).size() > 0);
96     // additional tests should check: empty methods
97
// non-public members
98
// we check here that just one joinpoint is generated for the
99
// emtpy methods.
100

101     assertTrue("Class testClass has exactly 8 crosscut points", testCrosscut.doCreateRequest(ExampleClass.class).size() == 8);
102   }
103
104   /**
105    * Test suite.
106    * @return test instance
107    */

108   public static
109   Test suite()
110   {
111     return new TestSuite(AllLocationsTest.class);
112   }
113
114
115 }
116
117
118 //======================================================================
119
//
120
// $Log: AllLocationsTest.java,v $
121
// Revision 1.2 2004/05/12 17:26:51 anicoara
122
// Adapt Junit tests to 3.8.1 version and the new package structure
123
//
124
// Revision 1.1.1.1 2003/07/02 15:30:43 apopovic
125
// Imported from ETH Zurich
126
//
127
// Revision 1.1 2003/05/05 14:03:29 popovici
128
// renaming from runes to prose
129
//
130
// Revision 1.12 2003/04/27 13:08:56 popovici
131
// Specializers renamed to PointCutter
132
//
133
// Revision 1.11 2003/04/17 15:15:17 popovici
134
// Extension->Aspect renaming
135
//
136
// Revision 1.10 2003/04/17 12:49:43 popovici
137
// Refactoring of the crosscut package
138
// ExceptionCut renamed to ThrowCut
139
// McutSignature is now SignaturePattern
140
//
141
// Revision 1.9 2003/04/17 08:46:47 popovici
142
// Important functionality additions
143
// - Cflow specializers
144
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
145
// - Transactional capabilities
146
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
147
// between static and dynamic specializers.
148
// - Functionality pulled up in abstract classes
149
// - Uniformization of advice methods patterns and names
150
//
151
// Revision 1.8 2003/03/05 15:26:44 popovici
152
// Bug fixes after the extraction of 'AdviceMethod' and 'AdviceExcecution' as top level classes:
153
// - a new Abstract class is superclassing 'UserDefinedAdvice' and 'DefaultAdvice'
154
//
155
// Revision 1.7 2003/03/04 18:36:41 popovici
156
// Organization of imprts
157
//
158
// Revision 1.6 2003/03/04 11:25:59 popovici
159
// Important refactorization step (march):
160
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
161
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
162
// structures
163
//
164
// Revision 1.5 2002/11/26 17:15:35 pschoch
165
// RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
166
// ProseSystem now owns and starts the Aspect interface.
167
// ProseSystem now containes a 'test' AspectManager
168
// AspectManager now owns the JoinPointManager.
169
// ExtensionManger can be 'connected' to the JVM, or disconnected. The
170
// JoinPointManager of a connected Ext.Mgr enables joinpoints; the
171
// JoinPointManger of a disconnected Ext.Mgr never enables join-points
172
// Documentation updated accordingly.
173
//
174
// Revision 1.4 2002/06/06 14:39:49 popovici
175
// Renamings: FunctionalCrosscut->MethodCut
176
// AllFields->SetCut
177
// SetCu.fieldModiticationAdvice -> SetCut.setAdvice
178
//
179
// Revision 1.3 2002/06/04 11:51:13 popovici
180
// The AllLocation crosscut eliminated; replaced with the 'AllLocations' flavour of
181
// FunctionalCrosscut
182
//
183
// Revision 1.2 2002/02/05 11:19:23 smarkwal
184
// modifications to test JVMAI-based implementation
185
//
186
// Revision 1.1.1.1 2001/11/29 18:13:31 popovici
187
// Sources from runes
188
//
189
// Revision 1.1.2.4 2001/11/21 11:56:37 popovici
190
//
191
// -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
192
// replaced with the iks.jvmdi package. References to this old
193
// functionality replaced throughout the code.
194
// -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
195
// part of their functionality moved to the ch.ethz.prose.reflect
196
// abstract classes. New classes and functionality added to the
197
// ch.ethz.prose.reflect package, partially to reflect the
198
// more stable features taken from the iks.runes packages, partially
199
// to reflect the structure of the VM (constant pool, etc). Functionality in
200
// ch.ethz.prose.crosscut and the junit classes adapted to use the
201
// new form of the ch.ethz.prose.reflect package
202
//
203
// Revision 1.1.2.3 2000/10/25 09:13:00 popovici
204
// Updated to a bug fix in ByteCodeImpl. Location has to be endBCI -1; therefore
205
// test has just 5 croscut points.
206
//
207
// Revision 1.1.2.2 2000/10/24 18:06:07 popovici
208
// 'System.err' removed
209
//
210
// Revision 1.1.2.1 2000/10/24 17:59:12 popovici
211
// Initial Revision
212
//
213
Popular Tags