BATCH-2023: Change default @StepScope proxy mode to INTERFACES

This commit is contained in:
Dave Syer
2013-05-06 09:36:53 +01:00
parent 3f1d56be43
commit 378006801a
2 changed files with 28 additions and 5 deletions

View File

@@ -103,8 +103,18 @@ public class StepScopeConfigurationTests {
}
@Test
public void testStepScopeWithInterface() throws Exception {
init(StepScopeConfigurationWithInterface.class);
public void testIntentionallyBlowupWithForcedInterface() throws Exception {
init(StepScopeConfigurationForcingInterfaceProxy.class);
StepSynchronizationManager.release();
expected.expect(BeanCreationException.class);
expected.expectMessage("step scope");
SimpleHolder value = context.getBean(SimpleHolder.class);
assertEquals("STEP", value.call());
}
@Test
public void testStepScopeWithDefaults() throws Exception {
init(StepScopeConfigurationWithDefaults.class);
@SuppressWarnings("unchecked")
Callable<String> value = context.getBean(Callable.class);
assertEquals("STEP", value.call());
@@ -112,7 +122,7 @@ public class StepScopeConfigurationTests {
@Test
public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
init(StepScopeConfigurationWithInterface.class);
init(StepScopeConfigurationWithDefaults.class);
StepSynchronizationManager.release();
expected.expect(BeanCreationException.class);
expected.expectMessage("step scope");
@@ -222,7 +232,7 @@ public class StepScopeConfigurationTests {
@Configuration
@EnableBatchProcessing
public static class StepScopeConfigurationWithInterface {
public static class StepScopeConfigurationWithDefaults {
@Bean
@StepScope
@@ -233,4 +243,17 @@ public class StepScopeConfigurationTests {
}
@Configuration
@EnableBatchProcessing
public static class StepScopeConfigurationForcingInterfaceProxy {
@Bean
@Scope(value="step", proxyMode = ScopedProxyMode.INTERFACES)
protected SimpleHolder value(@Value("#{stepExecution.stepName}")
final String value) {
return new SimpleHolder(value);
}
}
}