aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc153/PipeliningTests.java
blob: f0f5eaa4de6ae123266194be5534df2f7d694e9a (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
/*******************************************************************************
 * 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.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;

/**
 * testplan: (x = complete)
 *
 * x @AspectJ aspects - are they recognized and sorted correctly ?
 * x compiling classes (various orderings)
 * x compiling classes (inheritance relationships)
 * x compiling aspects and classes (various orderings - aspects first/last)
 * x eclipse annotation transformation logic
 * x aspects extending classes
 * x nested types (and aspect inside a regular class)
 * x set of files that are only aspects
 * x pointcuts in super classes
 * - classes with errors
 * - aspects with errors
 * - Xterminate after compilation (now == skip weaving??)
 *
 * That this pipeline works OK for large systems is kind of confirmed by using it to build shadows!
 *
 */
public class PipeliningTests extends org.aspectj.testing.XMLBasedAjcTestCase {

	// straightforward compilation
	public void testBuildTwoClasses() { runTest("build two classes");}
	public void testBuildOneAspectTwoClasses() { runTest("build one aspect and two classes");}
	public void testBuildTwoClassesOneAspect() { runTest("build two classes and one aspect");}
	public void testBuildTwoAspects() { runTest("build two aspects");}
	public void testBuildClassAndNestedAspect() { runTest("build one class and deeply nested aspect");}

	public void testAspectExtendsClass() { runTest("aspect extends class"); }

	// verifying the type sorting
	public void testRecognizingAnnotationStyleAspects1() {
		AjPipeliningCompilerAdapter.pipelineTesting=true;
		runTest("recognizing annotation style aspects - 1");

		String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
		assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));

		String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder");
		String expectedOrder="[AtAJAspect.java,ClassOne.java]";
		assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
	}
	public void testRecognizingAnnotationStyleAspects2() {
		AjPipeliningCompilerAdapter.pipelineTesting=true;
		runTest("recognizing annotation style aspects - 2");

		String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
		assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));

		String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder");
		String expectedOrder="[AtInnerAJAspect.java,ClassOne.java]";
		assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
	}

	// verifying the new code for transforming Eclipse Annotations into AspectJ ones
	public void testAnnotationTransformation() { runTest("annotation transformation"); }

  // --
  protected void tearDown() throws Exception {
		super.tearDown();
		//AjPipeliningCompilerAdapter.pipelineTesting=false;
  }
  public static Test suite() {
    return XMLBasedAjcTestCase.loadSuite(PipeliningTests.class);
  }
  protected URL getSpecFile() {
    return getClassResource("pipelining.xml");
  }
}