001: // $Id: AllLocationsTest.java,v 1.2 2004/05/12 17:26:51 anicoara Exp $
002: // =====================================================================
003: //
004: // (history at end)
005: //
006:
007: package ch.ethz.prose.crosscut;
008:
009: // used packages
010: import java.util.Vector;
011:
012: import junit.framework.*;
013: import ch.ethz.prose.ProseSystem;
014: import ch.ethz.prose.filter.PointCutter;
015:
016: /**
017: * JUnit testcase for class AllLocations.
018: *
019: * @version $Revision: 1.2 $
020: * @author Andrei Popovici
021: */
022: public class AllLocationsTest extends TestCase {
023:
024: static class AllLocationsExample extends MethodCut {
025: protected PointCutter pointCutter() {
026: return null;
027: }
028:
029: public void METHOD_ARGS() {
030: }
031:
032: public CrosscutRequest doCreateRequest(Class c) {
033: return super .doCreateRequest(c);
034: }
035: };
036:
037: static class ExampleClass {
038: public void method1() {
039: }
040:
041: public void method2() {
042: System.err.println("method 2");
043: }
044:
045: protected void method3() {
046: }
047:
048: void method4() {
049: }
050: }
051:
052: AllLocationsExample testCrosscut = null;
053:
054: /**
055: * Construct test with given name.
056: * @param name test name
057: */
058: public AllLocationsTest(String name) {
059: super (name);
060: }
061:
062: /**
063: * Set up fixture.
064: */
065: protected void setUp() throws Exception {
066: try {
067: ProseSystem.startup();
068: testCrosscut = new AllLocationsExample();
069: // let 'testCrosscut' think it has been activated
070: testCrosscut.insertionAction(true);
071: testCrosscut.insertionAction(false);
072: } catch (Exception e) {
073: e.printStackTrace();
074: Assert.fail("ProseSystem.startup() failed");
075: }
076: }
077:
078: protected void tearDown() {
079: try {
080: ProseSystem.teardown();
081: } catch (Exception e) {
082: Assert.fail("ProseSystem.teardown() failed");
083: }
084: }
085:
086: public void testDoCreateRequest() throws Exception {
087: assertNotNull(testCrosscut.doCreateRequest(Vector.class));
088: assertTrue("some public methods in there", testCrosscut
089: .doCreateRequest(Vector.class).size() > 0);
090: // additional tests should check: empty methods
091: // non-public members
092: // we check here that just one joinpoint is generated for the
093: // emtpy methods.
094:
095: assertTrue(
096: "Class testClass has exactly 8 crosscut points",
097: testCrosscut.doCreateRequest(ExampleClass.class).size() == 8);
098: }
099:
100: /**
101: * Test suite.
102: * @return test instance
103: */
104: public static Test suite() {
105: return new TestSuite(AllLocationsTest.class);
106: }
107:
108: }
109:
110: //======================================================================
111: //
112: // $Log: AllLocationsTest.java,v $
113: // Revision 1.2 2004/05/12 17:26:51 anicoara
114: // Adapt Junit tests to 3.8.1 version and the new package structure
115: //
116: // Revision 1.1.1.1 2003/07/02 15:30:43 apopovic
117: // Imported from ETH Zurich
118: //
119: // Revision 1.1 2003/05/05 14:03:29 popovici
120: // renaming from runes to prose
121: //
122: // Revision 1.12 2003/04/27 13:08:56 popovici
123: // Specializers renamed to PointCutter
124: //
125: // Revision 1.11 2003/04/17 15:15:17 popovici
126: // Extension->Aspect renaming
127: //
128: // Revision 1.10 2003/04/17 12:49:43 popovici
129: // Refactoring of the crosscut package
130: // ExceptionCut renamed to ThrowCut
131: // McutSignature is now SignaturePattern
132: //
133: // Revision 1.9 2003/04/17 08:46:47 popovici
134: // Important functionality additions
135: // - Cflow specializers
136: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
137: // - Transactional capabilities
138: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
139: // between static and dynamic specializers.
140: // - Functionality pulled up in abstract classes
141: // - Uniformization of advice methods patterns and names
142: //
143: // Revision 1.8 2003/03/05 15:26:44 popovici
144: // Bug fixes after the extraction of 'AdviceMethod' and 'AdviceExcecution' as top level classes:
145: // - a new Abstract class is superclassing 'UserDefinedAdvice' and 'DefaultAdvice'
146: //
147: // Revision 1.7 2003/03/04 18:36:41 popovici
148: // Organization of imprts
149: //
150: // Revision 1.6 2003/03/04 11:25:59 popovici
151: // Important refactorization step (march):
152: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
153: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
154: // structures
155: //
156: // Revision 1.5 2002/11/26 17:15:35 pschoch
157: // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
158: // ProseSystem now owns and starts the Aspect interface.
159: // ProseSystem now containes a 'test' AspectManager
160: // AspectManager now owns the JoinPointManager.
161: // ExtensionManger can be 'connected' to the JVM, or disconnected. The
162: // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
163: // JoinPointManger of a disconnected Ext.Mgr never enables join-points
164: // Documentation updated accordingly.
165: //
166: // Revision 1.4 2002/06/06 14:39:49 popovici
167: // Renamings: FunctionalCrosscut->MethodCut
168: // AllFields->SetCut
169: // SetCu.fieldModiticationAdvice -> SetCut.setAdvice
170: //
171: // Revision 1.3 2002/06/04 11:51:13 popovici
172: // The AllLocation crosscut eliminated; replaced with the 'AllLocations' flavour of
173: // FunctionalCrosscut
174: //
175: // Revision 1.2 2002/02/05 11:19:23 smarkwal
176: // modifications to test JVMAI-based implementation
177: //
178: // Revision 1.1.1.1 2001/11/29 18:13:31 popovici
179: // Sources from runes
180: //
181: // Revision 1.1.2.4 2001/11/21 11:56:37 popovici
182: //
183: // -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
184: // replaced with the iks.jvmdi package. References to this old
185: // functionality replaced throughout the code.
186: // -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
187: // part of their functionality moved to the ch.ethz.prose.reflect
188: // abstract classes. New classes and functionality added to the
189: // ch.ethz.prose.reflect package, partially to reflect the
190: // more stable features taken from the iks.runes packages, partially
191: // to reflect the structure of the VM (constant pool, etc). Functionality in
192: // ch.ethz.prose.crosscut and the junit classes adapted to use the
193: // new form of the ch.ethz.prose.reflect package
194: //
195: // Revision 1.1.2.3 2000/10/25 09:13:00 popovici
196: // Updated to a bug fix in ByteCodeImpl. Location has to be endBCI -1; therefore
197: // test has just 5 croscut points.
198: //
199: // Revision 1.1.2.2 2000/10/24 18:06:07 popovici
200: // 'System.err' removed
201: //
202: // Revision 1.1.2.1 2000/10/24 17:59:12 popovici
203: // Initial Revision
204: //
|