Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -44,7 +44,7 @@ public class ComponentScanAnnotationTests {
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(
|
||||
basePackageClasses={TestBean.class},
|
||||
basePackageClasses = TestBean.class,
|
||||
nameGenerator = DefaultBeanNameGenerator.class,
|
||||
scopedProxy = ScopedProxyMode.NO,
|
||||
scopeResolver = AnnotationScopeMetadataResolver.class,
|
||||
@@ -61,6 +61,6 @@ public class ComponentScanAnnotationTests {
|
||||
class MyConfig {
|
||||
}
|
||||
|
||||
@ComponentScan(basePackageClasses=example.scannable.NamedComponent.class)
|
||||
@ComponentScan(basePackageClasses = example.scannable.NamedComponent.class)
|
||||
class SimpleConfig {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -122,7 +122,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
context.refresh();
|
||||
fail("expected exception due to multiple matches for byType autowiring");
|
||||
}
|
||||
catch (UnsatisfiedDependencyException e) {
|
||||
catch (UnsatisfiedDependencyException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
context.refresh();
|
||||
fail("expected exception due to dependency check");
|
||||
}
|
||||
catch (UnsatisfiedDependencyException e) {
|
||||
catch (UnsatisfiedDependencyException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,6 @@ public class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
|
||||
private boolean destroyed;
|
||||
|
||||
|
||||
public DefaultsTestBean() {
|
||||
INIT_COUNT++;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,13 @@ public class ComponentScanParserScopedProxyTests {
|
||||
@Rule
|
||||
public final ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultScopedProxy() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
|
||||
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
|
||||
// should not be a proxy
|
||||
assertFalse(AopUtils.isAopProxy(bean));
|
||||
@@ -58,6 +60,7 @@ public class ComponentScanParserScopedProxyTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyNoTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
|
||||
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
|
||||
// should not be a proxy
|
||||
assertFalse(AopUtils.isAopProxy(bean));
|
||||
@@ -69,6 +72,7 @@ public class ComponentScanParserScopedProxyTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyInterfacesTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
|
||||
// should cast to the interface
|
||||
FooService bean = (FooService) context.getBean("scopedProxyTestBean");
|
||||
// should be dynamic proxy
|
||||
@@ -86,6 +90,7 @@ public class ComponentScanParserScopedProxyTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
|
||||
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
|
||||
// should be a class-based proxy
|
||||
assertTrue(AopUtils.isCglibProxy(bean));
|
||||
@@ -103,6 +108,7 @@ public class ComponentScanParserScopedProxyTests {
|
||||
exception.expect(BeanDefinitionParsingException.class);
|
||||
exception.expectMessage(containsString("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag"));
|
||||
exception.expectMessage(containsString("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]"));
|
||||
|
||||
new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -145,9 +145,9 @@ public class ComponentScanParserTests {
|
||||
}
|
||||
|
||||
|
||||
@Target({ ElementType.TYPE, ElementType.FIELD })
|
||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface CustomAnnotation {
|
||||
public @interface CustomAnnotation {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -53,7 +53,7 @@ public class ComponentScanParserWithUserDefinedStrategiesTests {
|
||||
"org/springframework/context/annotation/invalidConstructorNameGeneratorTests.xml");
|
||||
fail("should have failed: no-arg constructor is required");
|
||||
}
|
||||
catch (BeansException e) {
|
||||
catch (BeansException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,9 @@ public class ComponentScanParserWithUserDefinedStrategiesTests {
|
||||
"org/springframework/context/annotation/invalidClassNameScopeResolverTests.xml");
|
||||
fail("should have failed: no such class");
|
||||
}
|
||||
catch (BeansException e) {
|
||||
catch (BeansException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user