Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c6e0c763
Commit
c6e0c763
authored
Oct 02, 2013
by
Eberhard Wolff
Committed by
Dave Syer
Oct 07, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for AOP auto configuration and dependency to AspectJ
parent
6d6c261c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
2 deletions
+115
-2
pom.xml
spring-boot-autoconfigure/pom.xml
+6
-0
AopAutoConfiguration.java
...ramework/boot/autoconfigure/aop/AopAutoConfiguration.java
+2
-2
AopAutoConfigurationTests.java
...ork/boot/autoconfigure/aop/AopAutoConfigurationTests.java
+107
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
c6e0c763
...
...
@@ -151,6 +151,12 @@
<artifactId>
geronimo-jms_1.1_spec
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
<version>
1.7.3
</version>
<optional>
true
</optional>
</dependency>
<!-- Test -->
<dependency>
<groupId>
${project.groupId}
</groupId>
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java
View file @
c6e0c763
...
...
@@ -37,13 +37,13 @@ public class AopAutoConfiguration {
@Configuration
@EnableAspectJAutoProxy
(
proxyTargetClass
=
false
)
@ConditionalOnExpression
(
"!${spring.aop.proxyTargetClass:
fals
e}"
)
@ConditionalOnExpression
(
"!${spring.aop.proxyTargetClass:
tru
e}"
)
public
static
class
JdkDynamicAutoProxyConfiguration
{
}
@Configuration
@EnableAspectJAutoProxy
(
proxyTargetClass
=
true
)
@ConditionalOnExpression
(
"${spring.aop.proxyTargetClass:
fals
e}"
)
@ConditionalOnExpression
(
"${spring.aop.proxyTargetClass:
tru
e}"
)
public
static
class
CglibAutoProxyConfiguration
{
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java
0 → 100644
View file @
c6e0c763
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
aop
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.junit.Test
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.autoconfigure.aop.AopAutoConfigurationTests.TestInterface
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* Tests for {@link AopAutoConfiguration}.
*
* @author Eberhard Wolff
*/
public
class
AopAutoConfigurationTests
{
public
interface
TestInterface
{
public
abstract
void
foo
();
}
private
AnnotationConfigApplicationContext
context
;
@Test
public
void
testAopAutoConfigurationProxyTargetClass
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
);
TestUtils
.
addEnviroment
(
this
.
context
,
"spring.aop.proxyTargetClass:true"
);
TestUtils
.
addEnviroment
(
this
.
context
,
"spring.aop.auto:true"
);
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
TestBean
bean
=
this
.
context
.
getBean
(
TestBean
.
class
);
bean
.
foo
();
assertTrue
(
aspect
.
isCalled
());
}
@Test
public
void
testAopAutoConfigurationNoProxyTargetClass
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
);
TestUtils
.
addEnviroment
(
this
.
context
,
"spring.aop.proxyTargetClass:false"
);
TestUtils
.
addEnviroment
(
this
.
context
,
"spring.aop.auto:true"
);
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
TestInterface
bean
=
this
.
context
.
getBean
(
TestInterface
.
class
);
bean
.
foo
();
assertTrue
(
aspect
.
isCalled
());
}
@Configuration
protected
static
class
TestConfiguration
{
@Bean
public
TestAspect
aspect
()
{
return
new
TestAspect
();
}
@Bean
public
TestInterface
bean
()
{
return
new
TestBean
();
}
}
protected
static
class
TestBean
implements
TestInterface
{
@Override
public
void
foo
()
{
}
}
@Aspect
protected
static
class
TestAspect
{
private
boolean
called
;
public
boolean
isCalled
()
{
return
called
;
}
@Before
(
"execution(* foo(..))"
)
public
void
before
()
{
called
=
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment