OPEN - issue BATCH-937: Make sure JobRepository can be proxied
Plus fix error with stax config in tiger profile
This commit is contained in:
@@ -32,17 +32,13 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml")
|
||||
public class SimpleJobRepositoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private SimpleJobRepository jobRepository;
|
||||
|
||||
private JobSupport job = new JobSupport("SimpleJobRepositoryIntegrationTestsJob");
|
||||
|
||||
private JobParameters jobParameters = new JobParameters();
|
||||
|
||||
@Autowired
|
||||
public void setJobRepository(SimpleJobRepository jobRepository) {
|
||||
this.jobRepository = jobRepository;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create two job executions for same job+parameters tuple. Check both
|
||||
* executions belong to the same job instance and job.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.springframework.batch.core.repository.support;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Repository tests using JDBC DAOs (rather than mocks).
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class SimpleJobRepositoryProxyTests {
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Autowired
|
||||
private Advice advice;
|
||||
|
||||
private JobSupport job = new JobSupport("SimpleJobRepositoryProxyTestsJob");
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testCreateAndFind() throws Exception {
|
||||
assertFalse(advice.invoked);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
assertNotNull(jobExecution);
|
||||
assertTrue(advice.invoked);
|
||||
}
|
||||
|
||||
public static class Advice implements MethodInterceptor {
|
||||
|
||||
private boolean invoked;
|
||||
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
invoked = true;
|
||||
return invocation.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user