This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 959a522f1ee Revise #18867 (#18871)
959a522f1ee is described below
commit 959a522f1ee6ccd14ad139ed90426558ff5abc1c
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jul 5 21:05:09 2022 +0800
Revise #18867 (#18871)
---
.../manager/switcher/SwitchingResourceTest.java | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
index 1f3e800569b..ccbd2eb1842 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/switcher/SwitchingResourceTest.java
@@ -23,26 +23,16 @@ import org.junit.Test;
import java.util.Collections;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.times;
public final class SwitchingResourceTest {
@Test
- public void assertCloseStaleDataSources() throws InterruptedException {
- MockedDataSource dataSource = new MockedDataSource();
- ShardingSphereResource shardingSphereResource = new
ShardingSphereResource(Collections.singletonMap("foo_ds", dataSource));
- ShardingSphereResource spyResource = spy(shardingSphereResource);
- SwitchingResource switchingResource = new
SwitchingResource(spyResource,
- Collections.singletonMap("foo_ds", dataSource),
Collections.singletonMap("foo_ds", dataSource));
- switchingResource.closeStaleDataSources();
- while (null == dataSource.getClosed() || !dataSource.getClosed()) {
- Thread.sleep(10L);
- }
- assertTrue(dataSource.getClosed());
- verify(spyResource, times(1)).close(dataSource);
+ public void assertCloseStaleDataSources() {
+ MockedDataSource staleDataSource = new MockedDataSource();
+ ShardingSphereResource resource = mock(ShardingSphereResource.class);
+ new SwitchingResource(resource, Collections.singletonMap("new_ds", new
MockedDataSource()), Collections.singletonMap("stale_ds",
staleDataSource)).closeStaleDataSources();
+ verify(resource).close(staleDataSource);
}
-
}