1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*******************************************************************************
* Copyright (c) 2018-2019 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.aspectj.systemtest.ajc193;
import java.io.File;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater;
import org.aspectj.weaver.WeaverStateInfo;
import junit.framework.Test;
/**
* @author Andy Clement
*/
public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
public void testDeclareMixinOverweavingControl() {
runTest("overweaving decm - control");
}
public void testDeclareMixinOverweavingReweaving() {
runTest("overweaving decm - reweaving");
}
public void testDeclareMixinOverweaving() {
runTest("overweaving decm - 1");
}
public void xtestDeclareMixinOverweaving2() {
runTest("overweaving decm - 2");
}
public void xtestOverweavingDeclareMixinTargetingAspect() {
runTest("mood indicator 4");
}
public void testOverweavingAtDecPControl() {
runTest("overweaving atdecp - control");
}
public void testOverweavingAtDecP() {
runTest("overweaving atdecp");
}
public void testComplexOverweaving1() {
// This is the same code as the other test but overweaving OFF
runTest("overweaving");
}
public void testComplexOverweaving2() throws Exception {
// This is the same code as the other test but overweaving ON
runTest("overweaving 2");
// Asserting the weaver state info in the tests that will drive overweaving behaviour:
// After step 1 of the test, MyAspect will have been applied.
JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application");
WeaverStateInfo wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertTrue(wsi.getUnwovenClassFileData().length>0);
// After overweaving, MyAspect2 should also be getting applied but the unwovenclassfile
// data has been blanked out - because we can no longer use it, only overweaving is possible
// once one overweaving step is done
jc = getClassFrom(ajc.getSandboxDirectory(), "Application");
wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertEquals(0,wsi.getUnwovenClassFileData().length);
}
// Two steps of overweaving
public void testComplexOverweaving3() throws Exception {
// This is the same code as the other test but overweaving ON
runTest("overweaving 3");
// Asserting the weaver state info in the tests that will drive overweaving behaviour:
// After step 1 of the test, MyAspect will have been applied.
JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application");
WeaverStateInfo wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertTrue(wsi.getUnwovenClassFileData().length>0);
// After overweaving, MyAspect2 should also be getting applied but the unwovenclassfile
// data has been blanked out - because we can no longer use it, only overweaving is possible
// once one overweaving step is done
jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow3.jar"), "Application");
wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertEquals(0,wsi.getUnwovenClassFileData().length);
jc = getClassFrom(ajc.getSandboxDirectory(), "Application");
wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect3;, LMyAspect2;, LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertEquals(0,wsi.getUnwovenClassFileData().length);
}
// overweaving then attempt non overweaving - should fail
public void testComplexOverweaving4() throws Exception {
// This is the same code as the other test but overweaving ON
runTest("overweaving 4");
// Asserting the weaver state info in the tests that will drive overweaving behaviour:
// After step 1 of the test, MyAspect will have been applied.
JavaClass jc = getClassFrom(new File(ajc.getSandboxDirectory(),"ow1.jar"), "Application");
WeaverStateInfo wsi = getWeaverStateInfo(jc);
assertEquals("[LMyAspect;]", wsi.getAspectsAffectingType().toString());
assertTrue(wsi.getUnwovenClassFileData().length>0);
}
// Altered version of this test from org.aspectj.systemtest.ajc150.Enums for 542682
public void testDecpOnEnumNotAllowed_xlints() {
runTest("wildcard enum match in itd");
}
public void testEnumDecmixinMessage() {
runTest("declare mixin a");
}
public void testIsAbstractType() {
runTest("is abstract");
}
public void testIsAbstractType2() {
runTest("is abstract - 2");
}
// ---
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Ajc193Tests.class);
}
@Override
protected File getSpecFile() {
return getClassResource("ajc193.xml");
}
}
|