INT-4353: Let to set id for DefaultLockRepository
JIRA: https://jira.spring.io/browse/INT-4353 Updated based on code review * Polishing according PR comments **Cherry-pick to 4.3.x**
This commit is contained in:
committed by
Artem Bilan
parent
e52bf8e8a4
commit
e515a0d643
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -53,11 +53,13 @@ import org.springframework.util.StopWatch;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Artem Bilan
|
||||
* @author Glenn Renfro
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@ContextConfiguration("JdbcLockRegistryTests-context.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext // close at the end after class
|
||||
@DirtiesContext
|
||||
public class JdbcLockRegistryDifferentClientTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(JdbcLockRegistryDifferentClientTests.class);
|
||||
@@ -194,7 +196,11 @@ public class JdbcLockRegistryDifferentClientTests {
|
||||
|
||||
@Test
|
||||
public void testOnlyOneLock() throws Exception {
|
||||
testOnlyOneLock(null);
|
||||
testOnlyOneLock("AABBCCDD");
|
||||
}
|
||||
|
||||
private void testOnlyOneLock(String id) throws Exception {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
final List<String> locked = new ArrayList<String>();
|
||||
@@ -202,7 +208,9 @@ public class JdbcLockRegistryDifferentClientTests {
|
||||
ExecutorService pool = Executors.newFixedThreadPool(6);
|
||||
ArrayList<Callable<Boolean>> tasks = new ArrayList<Callable<Boolean>>();
|
||||
for (int j = 0; j < 20; j++) {
|
||||
final DefaultLockRepository client = new DefaultLockRepository(this.dataSource);
|
||||
final DefaultLockRepository client = (id == null) ?
|
||||
new DefaultLockRepository(this.dataSource) :
|
||||
new DefaultLockRepository(this.dataSource, id);
|
||||
client.afterPropertiesSet();
|
||||
this.context.getAutowireCapableBeanFactory().autowireBean(client);
|
||||
Callable<Boolean> task = () -> {
|
||||
|
||||
Reference in New Issue
Block a user