001: // $Id: QueryManagerTest.java,v 1.2 2004/05/12 17:26:52 anicoara Exp $
002: // =====================================================================
003: //
004: // (history at end)
005: //
006:
007: package ch.ethz.prose.query;
008:
009: // used packages
010: import junit.framework.*;
011: import ch.ethz.prose.DefaultAspect;
012: import ch.ethz.prose.ProseSystem;
013: import ch.ethz.prose.crosscut.Crosscut;
014: import ch.ethz.prose.crosscut.MethodCut;
015: import ch.ethz.prose.filter.PointCutter;
016: import ch.ethz.prose.filter.Within;
017:
018: /**
019: * JUnit testcase for class XXX.
020: *
021: * @version $Revision: 1.2 $
022: * @author Andrei Popovici
023: */
024: public class QueryManagerTest extends TestCase {
025:
026: /**
027: * Construct test with given name.
028: * @param name test name
029: */
030: public QueryManagerTest(String name) {
031: super (name);
032: }
033:
034: public static class QMCrosscut extends MethodCut {
035: public void METHOD_ARGS(QueryManagerTest tst, int i) {
036: }
037:
038: protected PointCutter pointCutter() {
039: return Within.method("salut");
040: }
041: };
042:
043: public static class QMAspect1 extends DefaultAspect {
044: public Crosscut c1 = new QMCrosscut();
045: public Crosscut c2 = new QMCrosscut();
046: public Crosscut c3 = new QMCrosscut();
047: }
048:
049: public static class QMAspect2 extends DefaultAspect {
050: public Crosscut c1 = new QMCrosscut();
051: }
052:
053: QMAspect1 a1 = null;
054: QMAspect2 a2 = null;
055: QueryManager qMgr = null;
056:
057: /**
058: * Set up fixture.
059: */
060: protected void setUp() throws Exception {
061: ProseSystem.startup();
062: a1 = new QMAspect1();
063: a2 = new QMAspect2();
064: qMgr = new QueryManager(ProseSystem.getAspectManager());
065: }
066:
067: protected void tearDown() throws Exception {
068: ProseSystem.teardown();
069: }
070:
071: /**
072: * Test suite.
073: * @return test instance
074: */
075: public static Test suite() {
076: return new TestSuite(QueryManagerTest.class);
077: }
078:
079: public void testReconstructAspect() throws Exception {
080: ProseSystem.getAspectManager().insert(a1);
081: ProseSystem.getAspectManager().insert(a2);
082:
083: AspectSurrogate as1 = new AspectSurrogate(a1);
084:
085: assertSame("a1 == as1.reconstruct", a1, qMgr
086: .reconstructAspect(as1));
087: assertEquals("a1 EQUALS as1.reconstruct", a1, qMgr
088: .reconstructAspect(as1));
089:
090: ProseSystem.getAspectManager().withdraw(a1);
091: assertNull("a1.reconstruct = null", qMgr.reconstructAspect(as1));
092: }
093:
094: public void testReconstructCrosscut() throws Exception {
095: ProseSystem.getAspectManager().insert(a1);
096:
097: AspectSurrogate as1 = new AspectSurrogate(a1);
098: CrosscutSurrogate cs2 = new CrosscutSurrogate(as1, a1.c2);
099:
100: assertSame("a1.c2 == cs3.reconstruct", a1.c2, qMgr
101: .reconstructCrosscut(cs2));
102: ProseSystem.getAspectManager().withdraw(a1);
103:
104: assertNull("a1.c2.reconstruct = null", qMgr
105: .reconstructCrosscut(cs2));
106: }
107: }
108:
109: //======================================================================
110: //
111: // $Log: QueryManagerTest.java,v $
112: // Revision 1.2 2004/05/12 17:26:52 anicoara
113: // Adapt Junit tests to 3.8.1 version and the new package structure
114: //
115: // Revision 1.1.1.1 2003/07/02 15:30:43 apopovic
116: // Imported from ETH Zurich
117: //
118: // Revision 1.1 2003/05/25 13:02:15 popovici
119: // Initial Revision
120: //
|