Skip to content

Commit cdaa247

Browse files
committed
Unwind _TestTypes to top-level public test classes in AOP test suite
1 parent 2523c3a commit cdaa247

File tree

11 files changed

+308
-230
lines changed

11 files changed

+308
-230
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,23 +18,6 @@
1818

1919
import org.aspectj.lang.JoinPoint;
2020

21-
/**
22-
* Definitions of testing types for use in within this package.
23-
* Wherever possible, test types should be defined local to the java
24-
* file that makes use of them. In some cases however, a test type may
25-
* need to be shared across tests. Such types reside here, with the
26-
* intention of reducing the surface area of java files within this
27-
* package. This allows developers to think about tests first, and deal
28-
* with these second class testing artifacts on an as-needed basis.
29-
*
30-
* Types here should be defined as package-private top level classes in
31-
* order to avoid needing to fully qualify, e.g.: _TestTypes$Foo.
32-
*
33-
* @author Chris Beams
34-
*/
35-
final class _TestTypes { }
36-
37-
3821
/**
3922
* Aspect used as part of before advice binding tests and
4023
* serves as base class for a number of more specialized test aspects.
@@ -44,13 +27,16 @@ final class _TestTypes { }
4427
*/
4528
class AdviceBindingTestAspect {
4629

47-
protected AdviceBindingCollaborator collaborator = null;
30+
protected AdviceBindingCollaborator collaborator;
31+
4832

4933
public void setCollaborator(AdviceBindingCollaborator aCollaborator) {
5034
this.collaborator = aCollaborator;
5135
}
5236

37+
5338
// "advice" methods
39+
5440
public void oneIntArg(int age) {
5541
this.collaborator.oneIntArg(age);
5642
}
@@ -79,67 +65,14 @@ public void needsJoinPointStaticPart(JoinPoint.StaticPart tjpsp) {
7965
public interface AdviceBindingCollaborator {
8066

8167
void oneIntArg(int x);
82-
void oneObjectArg(Object o);
83-
void oneIntAndOneObject(int x, Object o);
84-
void needsJoinPoint(String s);
85-
void needsJoinPointStaticPart(String s);
86-
}
87-
88-
}
89-
90-
91-
/**
92-
* @author Ramnivas Laddad
93-
*/
94-
interface ICounter {
95-
96-
void increment();
9768

98-
void decrement();
99-
100-
int getCount();
101-
102-
void setCount(int counter);
103-
104-
void reset();
105-
106-
}
107-
108-
109-
/**
110-
* A simple counter for use in simple tests (for example, how many times an advice was executed)
111-
*
112-
* @author Ramnivas Laddad
113-
*/
114-
final class Counter implements ICounter {
115-
116-
private int count;
117-
118-
public Counter() {
119-
}
120-
121-
@Override
122-
public void increment() {
123-
count++;
124-
}
69+
void oneObjectArg(Object o);
12570

126-
@Override
127-
public void decrement() {
128-
count--;
129-
}
71+
void oneIntAndOneObject(int x, Object o);
13072

131-
@Override
132-
public int getCount() {
133-
return count;
134-
}
73+
void needsJoinPoint(String s);
13574

136-
@Override
137-
public void setCount(int counter) {
138-
this.count = counter;
75+
void needsJoinPointStaticPart(String s);
13976
}
14077

141-
@Override
142-
public void reset() {
143-
this.count = 0;
144-
}
14578
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj;
18+
19+
/**
20+
* A simple counter for use in simple tests (for example, how many times an advice was executed)
21+
*
22+
* @author Ramnivas Laddad
23+
*/
24+
final class Counter implements ICounter {
25+
26+
private int count;
27+
28+
public Counter() {
29+
}
30+
31+
@Override
32+
public void increment() {
33+
count++;
34+
}
35+
36+
@Override
37+
public void decrement() {
38+
count--;
39+
}
40+
41+
@Override
42+
public int getCount() {
43+
return count;
44+
}
45+
46+
@Override
47+
public void setCount(int counter) {
48+
this.count = counter;
49+
}
50+
51+
@Override
52+
public void reset() {
53+
this.count = 0;
54+
}
55+
56+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj;
18+
19+
/**
20+
* @author Ramnivas Laddad
21+
*/
22+
interface ICounter {
23+
24+
void increment();
25+
26+
void decrement();
27+
28+
int getCount();
29+
30+
void setCount(int counter);
31+
32+
void reset();
33+
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj.autoproxy;
18+
19+
/**
20+
* @author Adrian Colyer
21+
* @since 2.0
22+
*/
23+
interface AnnotatedTestBean {
24+
25+
String doThis();
26+
27+
String doThat();
28+
29+
String doTheOther();
30+
31+
String[] doArray();
32+
33+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj.autoproxy;
18+
19+
/**
20+
* @author Adrian Colyer
21+
* @since 2.0
22+
*/
23+
class AnnotatedTestBeanImpl implements AnnotatedTestBean {
24+
25+
@Override
26+
@TestAnnotation("this value")
27+
public String doThis() {
28+
return "doThis";
29+
}
30+
31+
@Override
32+
@TestAnnotation("that value")
33+
public String doThat() {
34+
return "doThat";
35+
}
36+
37+
@Override
38+
@TestAnnotation("array value")
39+
public String[] doArray() {
40+
return new String[] {"doThis", "doThat"};
41+
}
42+
43+
// not annotated
44+
@Override
45+
public String doTheOther() {
46+
return "doTheOther";
47+
}
48+
49+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj.autoproxy;
18+
19+
import org.aspectj.lang.ProceedingJoinPoint;
20+
21+
/**
22+
* @author Adrian Colyer
23+
*/
24+
class AnnotationBindingTestAspect {
25+
26+
public String doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnnotation) throws Throwable {
27+
return testAnnotation.value();
28+
}
29+
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.aop.aspectj.autoproxy;
18+
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
22+
/**
23+
* @author Adrian Colyer
24+
* @since 2.0
25+
*/
26+
@Retention(RetentionPolicy.RUNTIME)
27+
@interface TestAnnotation {
28+
String value() ;
29+
}

0 commit comments

Comments
 (0)