aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java
blob: 61331cdb3fa4ffe3b478cdbeda78df7096fe08db (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
/*******************************************************************************
 * Copyright (c) 2016 Contributors
 * 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.ajc1811;

import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.bcel.BcelWorld;

import junit.framework.Test;

/**
 * @author Andy Clement
 */
public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase {

	public void testParameterizedWithInner() throws Exception {
		runTest("parameterized with inner");
		JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Outer");
		assertNotNull(jc);
		BcelWorld world = new BcelWorld(ajc.getSandboxDirectory().toString());

		ResolvedType outerType = world.resolve(UnresolvedType.forName("Outer"));
		ResolvedMember m = findMethod(outerType,"m");

		UnresolvedType type = m.getReturnType();
		assertEquals("LOuter$Inner;",type.getSignature());

		type = m.getGenericReturnType();
		assertEquals("LOuter$Inner;",type.getSignature());

		ResolvedType resolvedType = world.resolve(type);
		ResolvedType outerResolvedType = resolvedType.getOuterClass();
		assertEquals("LOuter;",outerResolvedType.getSignature());

		ResolvedMember m2 = findMethod(outerType,"m2");
		type = m2.getReturnType();
		assertEquals("LOuter$Inner;",type.getSignature());

		type = m2.getGenericReturnType();
		assertEquals("LOuter$Inner;",type.getSignature());

		// public Inner m() { ... }
//		Method m = findMethod(jc,"m");
//		System.out.println(m);
//		System.out.println(">"+m.getReturnType());
//		assertNotNull(returnType);

		// public Outer<String>.Inner m2() { ... }
	}

//
//	public void testMultiArgs_509235() {
//		runTest("multiargs");
//	}
//
//	public void testMultiArgs_509235_2() {
//		runTest("multiargs - no ellipsis");
//	}

	// 1.8.13:

	public void testAjcGenerics() {
		runTest("generics");
	}

	// ---

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

	@Override
	protected java.net.URL getSpecFile() {
		return getClassResource("ajc1811.xml");
	}

}