aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc153/Ajc153Tests.java
blob: 98ea6e458d9621f54e78f042465923f62c16ae37 (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/*******************************************************************************
 * Copyright (c) 2006 IBM
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
 *
 * Contributors:
 *    Andy Clement - initial API and implementation
 *******************************************************************************/
package org.aspectj.systemtest.ajc153;

import java.net.URL;

import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.weaver.bcel.Utility;

import junit.framework.Test;

public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {

	public void testFormalCommentsAreSetForConstructorIPEs_pr164340() {
		runTest("formal comments are set for constructor ipes");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C()");
		assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());
	}

	// public void testGenericsProblem_pr151978() { runTest("generics problem");}
	// public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");}
	// public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
	// public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
	// public void testNegatedAnnotationMatchingProblem_pr153464() { runTest("negated annotation matching problem");}
	public void testAnnotationStyleBcException_pr162135() {
		runTest("bcexception in annotation style around advice");
	}

	public void testAnnotationStyleBcException_pr162135_2() {
		runTest("bcexception in annotation style around advice - 2");
	}

	public void testAnnotationStyleBcException_pr162135_3() {
		runTest("bcexception in annotation style around advice - 3");
	}

	public void testAnnotationStyleBcException_pr162135_4() {
		runTest("bcexception in annotation style around advice - 4");
	}

	public void testAnnotationStyleBcException_pr162135_5() {
		runTest("bcexception in annotation style around advice - 5");
	}

	public void testAnnotationStyleBcException_pr162135_6() {
		runTest("bcexception in annotation style around advice - 6");
	}

	public void testAnnotationStyleBcException_pr162135_7() {
		runTest("bcexception in annotation style around advice - 7");
	}

	public void testIncompatibleClassChangeWithITD_pr164633() {
		runTest("incompatibleclasschange");
	}

	public void testComplexPointcut_pr162657() {
		runTest("complex pointcut");
	}

	public void testGenericsInPointcuts_pr161502() {
		runTest("generics in pointcuts");
	}

	public void testGenericsInPointcuts_pr161502_2() {
		runTest("generics in pointcuts - 2");
	}

	public void testNoNPEDueToMissingType_pr149908() {
		runTest("ensure no npe due to missing type");
	}

	public void testNoNPEDueToMember_pr149908() {
		runTest("ensure no npe due to missing member");
	}

	public void testPTWgetWithinTypeName_pr123423_1() {
		runTest("basic usage of getWithinTypeName");
	}

	public void testPTWgetWithinTypeName_pr123423_2() {
		runTest("basic usage of getWithinTypeName - multiple types");
	}

	public void testPTWgetWithinTypeName_pr123423_3() {
		runTest("basic usage of getWithinTypeName - non matching types");
	}

	public void testPTWgetWithinTypeName_pr123423_4() {
		runTest("basic usage of getWithinTypeName - types in packages");
	}

	public void testPTWgetWithinTypeName_pr123423_5() {
		runTest("basic usage of getWithinTypeName - annotation style");
	}

	public void testTurningOffBcelCaching_pr160674() {
		runTest("turning off bcel caching");
	}

	public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058() {
		runTest("no IllegalStateException with generic inner aspect");
	}

	public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058_2() {
		runTest("no IllegalStateException with generic inner aspect - 2");
	}

	public void testDeclareMethodAnnotations_pr159143() {
		runTest("declare method annotations");
	}

	public void testVisibilityProblem_pr149071() {
		runTest("visibility problem");
	}

	public void testMissingLineNumbersInStacktraceAfter_pr145442() {
		runTest("missing line numbers in stacktrace after");
	}

	public void testMissingLineNumbersInStacktraceAround_pr145442() {
		runTest("missing line numbers in stacktrace around");
	}

	public void testGenericArrays_pr158624() {
		runTest("generics and arrays");
	}

	public void testMissingLineNumbersInStacktraceBefore_pr145442() {
		runTest("missing line numbers in stacktrace before");
	}

	public void testMissingLineNumbersInStacktraceBefore_pr145442_Binary() {
		runTest("missing line numbers in stacktrace before - binary");
	}

	public void testAnnotationStylePointcutNPE_pr158412() {
		runTest("annotation style pointcut npe");
	}

	public void testAnnotationStylePointcutNPE_pr158412_2() {
		runTest("annotation style pointcut npe - 2");
	}

	public void testAnnotationsCallConstructors_pr158126() {
		runTest("annotations, call and constructors problem");
	}

	public void testIllegalStateExceptionGenerics_pr153845() {
		runTest("IllegalStateException at GenericSignatureParser.java");
	}

	public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_1() {
		runTest("no illegal state exception from AsmDelegate - 1");
	}

	public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_2() {
		runTest("no illegal state exception from AsmDelegate - 2");
	}

	public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_3() {
		runTest("no illegal state exception from AsmDelegate - 3");
	}

	public void testAnnotMethod_pr156962() {
		runTest("Test Annot Method");
	}

	public void testAnnotMethodHasMember_pr156962() {
		runTest("Test Annot Method Has Member");
	}

	public void testMixingGenerics_pr152848() {
		runTest("mixing generics");
	}

	public void testIncorrectStaticinitializationWeaving_pr149560_1() {
		runTest("incorrect staticinitialization weaving - codestyle");
	}

	public void testIncorrectStaticinitializationWeaving_pr149560_2() {
		runTest("incorrect staticinitialization weaving - annstyle");
	}

	public void testIncorrectDeprecatedAnnotationProcessing_pr154332() {
		runTest("incorrect deprecated annotation processing");
	}

	public void testPipeliningProblemWithAnnotationsDecp_pr153380_1() {
		runTest("pipelining decps");
	}

	public void testUnwantedPointcutWarning_pr148219() {
		runTest("unwanted warning for pointcut");
	}

	public void testDecpAndCflowadderMungerClash_pr152631() {
		runTest("decp and cflowadder munger clash");
	}

	public void testGenericInheritanceDecp_pr150095() {
		runTest("generics, inheritance and decp");
	}

	public void testIllegalStateException_pr148737() {
		runTest("illegalstateexception for non generic type");
	}

	public void testAtajInheritance_pr149305_1() {
		runTest("ataj inheritance - 1");
	}

	public void testAtajInheritance_pr149305_2() {
		runTest("ataj inheritance - 2");
	}

	public void testAtajInheritance_pr149305_3() {
		runTest("ataj inheritance - 3");
	}

	// public void testVerificationFailureForAspectOf_pr148693() {
	// runTest("verification problem"); // build the code
	// Utils.verifyClass(ajc, "mypackage.MyAspect"); // verify it <<< BRAND NEW VERIFY UTILITY FOR EVERYONE TO TRY ;)
	// }

	public void testIncorrectAnnotationValue_pr148537() {
		runTest("incorrect annotation value");
	}

	public void testVerifyErrNoTypeCflowField_pr145693_1() {
		runTest("verifyErrNoTypeCflowField");
	}

	public void testVerifyErrInpathNoTypeCflowField_pr145693_2() {
		runTest("verifyErrInpathNoTypeCflowField");
	}

	public void testCpathNoTypeCflowField_pr145693_3() {
		runTest("cpathNoTypeCflowField");
	}

	// public void testAdviceNotWovenAspectPath_pr147841() { runTest("advice not woven on aspectpath");}
	public void testGenericSignatures_pr148409() {
		runTest("generic signature problem");
	}

	public void testCantFindType_pr149322_01() {
		runTest("can't find type on interface call 1");
	}

	public void testCantFindType_pr149322_02() {
		runTest("can't find type on interface call 2");
	}

	public void testCantFindType_pr149322_03() {
		runTest("can't find type on interface call 3");
	}

	public void testParsingBytecodeLess_pr152871() {
		Utility.testingParseCounter = 0;
		runTest("parsing bytecode less");
		assertTrue("Should have called parse 2 times, not " + Utility.testingParseCounter + " times",
				Utility.testingParseCounter == 2);
		// 5 means: // 3 of these are gone with change to UnwovenClassFileWTPMB to take a classname in ctor
		// (1)=registerAspect
		// (2,3)=checkingIfShouldWeave,AcceptingResult for class
		// (4,5)=checkingIfShouldWeave,AcceptingResult for aspect
	}

	public void testMatchVolatileField_pr150671() {
		runTest("match volatile field");
	}

	public void testDuplicateJVMTIAgents_pr151938() {
		runTest("Duplicate JVMTI agents");
	}

	public void testLTWWorldWithAnnotationMatching_pr153572() {
		runTest("LTWWorld with annotation matching");
	}

	public void testReweavableAspectNotRegistered_pr129525() {
		runTest("reweavableAspectNotRegistered error");
	}

	public void testNPEinConstructorSignatureImpl_pr155972() {
		runTest("NPE in ConstructorSignatureImpl");
	}

	public void testNPEinFieldSignatureImpl_pr155972() {
		runTest("NPE in FieldSignatureImpl");
	}

	public void testNPEinInitializerSignatureImpl_pr155972() {
		runTest("NPE in InitializerSignatureImpl");
	}

	public void testLineNumberTableCorrectWithGenericsForEachAndContinue_pr155763() {
		runTest("ensure LineNumberTable correct with generics, for each and continue");
	}

	public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() {
		runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class");
	}

	public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() {
		runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2");
	}

	public void testDeclareSoftAndInnerClasses_pr125981() {
		runTest("declare soft and inner classes");
	}

	public void testGetSourceSignature_pr148908() {
		runTest("ensure getSourceSignature correct with static field");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "MY_COMPARATOR");
		String expected = "static final Comparator MY_COMPARATOR = null;\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aString");
		expected = "static final String aString = \"Constant String\";\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bString");
		expected = "static final String bString = aString;\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cString");
		expected = "static final String cString = (aString + bString);\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "dString");
		expected = "static final String dString = ((aString + \" and \") + bString);\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "eString");
		expected = "static final String eString = \"Hello World\";\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aList");
		expected = "public List<String> aList = null;\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bList");
		expected = "public List<String> bList = null;\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cList");
		expected = "public List<String> cList = null;\n";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());
	}

	// public void testNPEWithCustomAgent_pr158205() {
	// runTest("NPE with custom agent");
	// }

	public void testWeaveConcreteSubaspectWithAdvice_pr132080() {
		runTest("Weave concrete sub-aspect with advice");
	}

	public void testWeaveConcreteSubaspectWithITD_pr132080() {
		runTest("Weave concrete sub-aspect with ITD");
	}

	public void testWeaveConcreteSubaspectWithAroundClosure_pr132080() {
		runTest("Weave concrete sub-aspect with around closure");
	}

	public void testWeaveConcreteSubaspectWithCflow_pr132080() {
		runTest("Weave concrete sub-aspect with cflow");
	}

	public void testNPEWithLTWPointcutLibraryAndMissingAspectDependency_pr158957() {
		runTest("NPE with LTW, pointcut library and missing aspect dependency");
	}

	public void testNoInvalidAbsoluteTypeNameWarning_pr156904_1() {
		runTest("ensure no invalidAbsoluteTypeName when do match - 1");
	}

	public void testNoInvalidAbsoluteTypeNameWarning_pr156904_2() {
		runTest("ensure no invalidAbsoluteTypeName when do match - 2");
	}

	public void testNoInvalidAbsoluteTypeNameWarning_pr156904_3() {
		runTest("ensure no invalidAbsoluteTypeName when do match - 3");
	}

	public void testNoInvalidAbsoluteTypeNameWarning_pr156904_4() {
		runTest("ensure no invalidAbsoluteTypeName when do match - 4");
	}

	public void testNoNPEWithThrownExceptionWarningAndAtAspectj_pr161217() {
		runTest("NPE with thrown exception warning and at aspectj");
	}

	public void testJavadocCommentsAreSetIfHaveNormalComments_pr164340() {
		runTest("javadoc comments are set if have normal comments");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();

		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "foo()");
		assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "bar()");
		assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "goo()");
		assertNull("expected formal comment to be null but" + " found that it was " + ipe.getFormalComment(), ipe
				.getFormalComment());

	}

	public void testBinaryWeavingIntoJava6Library_pr164384() {
		runTest("binary weaving into java 6 library");
	}

	public void testCompilanceJava6ThrowsUsageError_pr164384() {
		runTest("compliance java 6 throws usage error");
	}

	public void testSourceLevelJava6ThrowsUsageError_pr164384() {
		runTest("source level java 6 throws usage error");
	}

	public void testTargetLevelJava6ThrowsUsageError_pr164384() {
		runTest("target level java 6 throws usage error");
	}

	public void testStaticImport() {
		runTest("ensure static import reference have static modifier set");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();

		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE,
				"ABC.StaticImport.Alphabet.A");
		String expected = "import static ABC.StaticImport.Alphabet.A;";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());
	}

	public void testAspected_Annotation() {
		runTest("ensure Annotations are added to import list");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();

		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE, "annotation.A");
		String expected = "import annotation.A;";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

	}

	public void testGetSourceSignature_GenericMethods() {
		runTest("ensure getSourceSignature correct with generic method");
		IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();

		IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnT(T)");
		String expected = "public <T> T returnT(T a)";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnQ(Q)");
		expected = "public <Q extends List> Q returnQ(Q a)";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "doubleGeneric(Q,T)");
		expected = "public <T, Q> void doubleGeneric(Q a, T b)";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());

		// Generic Method Constructor
		ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C(T)");
		expected = "public <T> C(T b)";
		assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
				.getSourceSignature());
	}

	// ///////////////////////////////////////
	public static Test suite() {
		return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
	}

	protected URL getSpecFile() {
		return getClassResource("ajc153.xml");
	}

}