blob: cbde8e680d243e98347a42f44b70327a4920ef60 (
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
|
/* *******************************************************************
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors:
* Adrian Colyer Initial implementation
* ******************************************************************/
package org.aspectj.weaver.reflect;
import junit.framework.TestCase;
import java.util.List;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.World;
import org.aspectj.weaver.patterns.ConcreteCflowPointcut;
public class ReflectionWorldTest extends TestCase {
public void testDelegateCreation() {
World world = new ReflectionWorld(getClass().getClassLoader());
ResolvedType rt = world.resolve("java.lang.Object");
assertNotNull(rt);
assertEquals("Ljava/lang/Object;", rt.getSignature());
}
public void testArrayTypes() {
IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
String[] strArray = new String[1];
ResolvedType rt = world.resolve(strArray.getClass());
assertTrue(rt.isArray());
}
public void testPrimitiveTypes() {
IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
assertEquals("int", UnresolvedType.INT, world.resolve(int.class));
assertEquals("void", UnresolvedType.VOID, world.resolve(void.class));
}
static class AbstractSuperClass<A,B> {}
static interface InterfaceOne {}
static interface InterfaceTwo<A> {}
static class ID {}
static abstract class AbstractTestClass<T> extends AbstractSuperClass<T,ID> implements InterfaceOne, InterfaceTwo<T> {
}
static class TestType {}
// static class ConcreteClass extends AbstractTestClass<TestType> {
static class ConcreteClass extends AbstractTestClass<List<TestType>> {
}
static class Bar extends ConcreteClass {}
public void testGenerics() {
ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
// world.lookupOrCreateName(UnresolvedType.forName(AbstractTestClass.class.getName()));
// ResolvedType resolvedType = world.resolve(AbstractTestClass.class);
JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world);
ResolvedType resolvedType2 = converter.fromType(ConcreteClass.class);
}
}
|