Fix connection pool issue in tests: tracked down to not using @Transactional
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2009-2010 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
import org.springframework.batch.core.repository.dao.JdbcJobInstanceDaoTests;
|
||||
import org.springframework.batch.core.step.tasklet.AsyncChunkOrientedStepIntegrationTests;
|
||||
|
||||
/**
|
||||
* A test suite that is ignored, but can be resurrected to help debug ordering
|
||||
* issues in tests.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(value = { AsyncChunkOrientedStepIntegrationTests.class, JdbcJobInstanceDaoTests.class })
|
||||
@Ignore
|
||||
public class IgnoredTestSuite {
|
||||
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testFindJobInstanceByExecution() {
|
||||
|
||||
@@ -69,6 +70,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
assertEquals(jobInstance, returnedInstance);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testCreateJobKey() {
|
||||
|
||||
@@ -80,6 +82,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testCreateJobKeyWithNullParameter() {
|
||||
|
||||
@@ -94,6 +97,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testCreateJobKeyOrdering() {
|
||||
|
||||
|
||||
@@ -15,16 +15,17 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import org.springframework.batch.core.repository.dao.NoSuchObjectException;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class NoSuchBatchDomainObjectExceptionTests extends TestCase {
|
||||
public class NoSuchBatchDomainObjectExceptionTests {
|
||||
|
||||
@Test
|
||||
public void testCreateException() throws Exception {
|
||||
NoSuchObjectException e = new NoSuchObjectException("Foo");
|
||||
assertEquals("Foo", e.getMessage());
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -72,12 +73,26 @@ public class AsyncChunkOrientedStepIntegrationTests {
|
||||
|
||||
private RepeatTemplate chunkOperations;
|
||||
|
||||
private int maxActive;
|
||||
|
||||
private int maxIdle;
|
||||
|
||||
private ItemReader<String> getReader(String[] args) {
|
||||
return new ListItemReader<String>(Arrays.asList(args));
|
||||
}
|
||||
|
||||
@After
|
||||
public void reset() {
|
||||
// Reset concurrency settings to something reasonable
|
||||
dataSource.setMaxActive(maxActive);
|
||||
dataSource.setMaxIdle(maxIdle);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUp() throws Exception {
|
||||
public void init() throws Exception {
|
||||
|
||||
maxActive = dataSource.getMaxActive();
|
||||
maxIdle = dataSource.getMaxIdle();
|
||||
|
||||
// Force deadlock with batch waiting for DB pool and vice versa
|
||||
dataSource.setMaxActive(1);
|
||||
|
||||
Reference in New Issue
Block a user