Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -50,10 +50,8 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class ConcurrentBeanFactoryTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ConcurrentBeanFactoryTests.class);
|
||||
private static final Resource CONTEXT = qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml");
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
|
||||
|
||||
private static final Date DATE_1, DATE_2;
|
||||
|
||||
static {
|
||||
@@ -66,27 +64,32 @@ public class ConcurrentBeanFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ConcurrentBeanFactoryTests.class);
|
||||
|
||||
private BeanFactory factory;
|
||||
|
||||
private final Set<TestRun> set = Collections.synchronizedSet(new HashSet<TestRun>());
|
||||
private final Set<TestRun> set = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
private Throwable ex;
|
||||
|
||||
private Throwable ex = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CONTEXT);
|
||||
factory.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
registry.registerCustomEditor(Date.class, new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false));
|
||||
}
|
||||
});
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
|
||||
qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml"));
|
||||
|
||||
factory.addPropertyEditorRegistrar(
|
||||
registry -> registry.registerCustomEditor(Date.class,
|
||||
new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false)));
|
||||
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSingleThread() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -21,10 +21,8 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.DependencyDescriptor;
|
||||
import org.springframework.beans.factory.support.AutowireCandidateResolver;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.tests.TestResourceUtils.*;
|
||||
@@ -38,13 +36,12 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class CustomAutowireConfigurerTests {
|
||||
|
||||
private static final Resource CONTEXT = qualifiedResource(CustomAutowireConfigurerTests.class, "context.xml");
|
||||
|
||||
@Test
|
||||
public void testCustomResolver() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
|
||||
reader.loadBeanDefinitions(CONTEXT);
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(CustomAutowireConfigurerTests.class, "context.xml"));
|
||||
|
||||
CustomAutowireConfigurer cac = new CustomAutowireConfigurer();
|
||||
CustomResolver customResolver = new CustomResolver();
|
||||
bf.setAutowireCandidateResolver(customResolver);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -22,7 +22,6 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -37,9 +36,6 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class FieldRetrievingFactoryBeanTests {
|
||||
|
||||
private static final Resource CONTEXT =
|
||||
qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml");
|
||||
|
||||
@Test
|
||||
public void testStaticField() throws Exception {
|
||||
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
|
||||
@@ -127,7 +123,9 @@ public class FieldRetrievingFactoryBeanTests {
|
||||
@Test
|
||||
public void testBeanNameSyntaxWithBeanFactory() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml"));
|
||||
|
||||
TestBean testBean = (TestBean) bf.getBean("testBean");
|
||||
assertEquals(new Integer(Connection.TRANSACTION_SERIALIZABLE), testBean.getSomeIntegerArray()[0]);
|
||||
assertEquals(new Integer(Connection.TRANSACTION_SERIALIZABLE), testBean.getSomeIntegerArray()[1]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -42,25 +41,25 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class ObjectFactoryCreatingFactoryBeanTests {
|
||||
|
||||
private static final Resource CONTEXT =
|
||||
qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml");
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml"));
|
||||
this.beanFactory.setSerializationId("test");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
public void close() {
|
||||
this.beanFactory.setSerializationId(null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFactoryOperation() throws Exception {
|
||||
public void testFactoryOperation() {
|
||||
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
|
||||
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
|
||||
|
||||
@@ -82,7 +81,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProviderOperation() throws Exception {
|
||||
public void testProviderOperation() {
|
||||
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
|
||||
Provider<?> provider = testBean.getProvider();
|
||||
|
||||
@@ -152,7 +151,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() throws Exception {
|
||||
public void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() {
|
||||
assertEquals("Must be reporting that it creates ObjectFactory instances (as per class contract).",
|
||||
ObjectFactory.class, new ObjectFactoryCreatingFactoryBean().getObjectType());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -25,7 +25,6 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -40,12 +39,11 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class SimpleScopeTests {
|
||||
|
||||
private static final Resource CONTEXT = qualifiedResource(SimpleScopeTests.class, "context.xml");
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
beanFactory = new DefaultListableBeanFactory();
|
||||
Scope scope = new NoOpScope() {
|
||||
private int index;
|
||||
@@ -69,10 +67,11 @@ public class SimpleScopeTests {
|
||||
assertEquals("myScope", scopeNames[0]);
|
||||
assertSame(scope, beanFactory.getRegisteredScope("myScope"));
|
||||
|
||||
XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(beanFactory);
|
||||
xbdr.loadBeanDefinitions(CONTEXT);
|
||||
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
|
||||
qualifiedResource(SimpleScopeTests.class, "context.xml"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCanGetScopedObject() {
|
||||
TestBean tb1 = (TestBean) beanFactory.getBean("usesScope");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -24,7 +24,6 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -37,8 +36,6 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||
*/
|
||||
public class CustomProblemReporterTests {
|
||||
|
||||
private static final Resource CONTEXT = qualifiedResource(CustomProblemReporterTests.class, "context.xml");
|
||||
|
||||
private CollatingProblemReporter problemReporter;
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
@@ -47,16 +44,17 @@ public class CustomProblemReporterTests {
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
this.problemReporter = new CollatingProblemReporter();
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
this.reader.setProblemReporter(this.problemReporter);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testErrorsAreCollated() {
|
||||
this.reader.loadBeanDefinitions(CONTEXT);
|
||||
this.reader.loadBeanDefinitions(qualifiedResource(CustomProblemReporterTests.class, "context.xml"));
|
||||
assertEquals("Incorrect number of errors collated", 4, this.problemReporter.getErrors().length);
|
||||
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("validBean");
|
||||
|
||||
Reference in New Issue
Block a user