@Around("execution(void org.springframework.batch.core.Job+.execute(*)) && target(job) && args(jobExecution)") public void execute(Job job, JobExecution jobExecution) { JobSynchronizationManager.register(jobExecution); try { job.execute(jobExecution); } finally { JobSynchronizationManager.release(); } }
@After public void close() { JobSynchronizationManager.release(); if (context != null) { context.close(); } }
@After public void tearDown() throws Exception { JobSynchronizationManager.release(); }
@Before public void countBeans() { JobSynchronizationManager.release(); beanCount = beanFactory.getBeanDefinitionCount(); }
@Test public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception { init(JobScopeConfigurationWithDefaults.class); JobSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("job scope"); @SuppressWarnings("unchecked") Callable<String> value = context.getBean(Callable.class); assertEquals("JOB", value.call()); }
@Test public void testGetWithNoContext() throws Exception { final String foo = "bar"; JobSynchronizationManager.release(); try { scope.get("foo", new ObjectFactory<String>() { @Override public String getObject() throws BeansException { return foo; } }); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // expected } }
@Test public void testRelease() { JobContext context = JobSynchronizationManager.register(jobExecution); final List<String> list = new ArrayList<>(); context.registerDestructionCallback("foo", new Runnable() { @Override public void run() { list.add("foo"); } }); // On release we expect the destruction callbacks to be called JobSynchronizationManager.release(); assertNull(JobSynchronizationManager.getContext()); assertEquals(1, list.size()); }
@Before public void setup() { JobSynchronizationManager.release(); jobExecution = new JobExecution(new JobInstance(5l, "JOB"), null, null); }
JobSynchronizationManager.release();
@Test public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception { init(JobScopeConfigurationRequiringProxyTargetClass.class); JobSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("job scope"); SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("JOB", value.call()); }
@Test public void testIntentionallyBlowupWithForcedInterface() throws Exception { init(JobScopeConfigurationForcingInterfaceProxy.class); JobSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("job scope"); SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("JOB", value.call()); }
@Around("execution(void org.springframework.batch.core.Job+.execute(*)) && target(job) && args(jobExecution)") public void execute(Job job, JobExecution jobExecution) { JobSynchronizationManager.register(jobExecution); try { job.execute(jobExecution); } finally { JobSynchronizationManager.release(); } }
@Around("execution(void org.springframework.batch.core.Job+.execute(*)) && target(job) && args(jobExecution)") public void execute(Job job, JobExecution jobExecution) { JobSynchronizationManager.register(jobExecution); try { job.execute(jobExecution); } finally { JobSynchronizationManager.release(); } }
@Around("execution(void org.springframework.batch.core.Job+.execute(*)) && target(job) && args(jobExecution)") public void execute(Job job, JobExecution jobExecution) { JobSynchronizationManager.register(jobExecution); try { job.execute(jobExecution); } finally { JobSynchronizationManager.release(); } }
JobSynchronizationManager.release();
JobSynchronizationManager.release();
JobSynchronizationManager.release();