Skip to content

Commit ffbc537

Browse files
committed
Polish ConcurrentBeanWrapperTests
1 parent 9295bcc commit ffbc537

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,18 +18,16 @@
1818

1919
import java.io.ByteArrayOutputStream;
2020
import java.io.IOException;
21-
import java.util.Collections;
22-
import java.util.HashSet;
2321
import java.util.Iterator;
2422
import java.util.Properties;
2523
import java.util.Set;
24+
import java.util.concurrent.ConcurrentHashMap;
2625

2726
import org.apache.commons.logging.Log;
2827
import org.apache.commons.logging.LogFactory;
2928
import org.junit.jupiter.api.RepeatedTest;
3029
import org.junit.jupiter.api.Test;
3130

32-
3331
import static org.assertj.core.api.Assertions.assertThat;
3432

3533
/**
@@ -38,21 +36,21 @@
3836
* @author Chris Beams
3937
* @since 08.03.2004
4038
*/
41-
public class ConcurrentBeanWrapperTests {
39+
class ConcurrentBeanWrapperTests {
4240

4341
private final Log logger = LogFactory.getLog(getClass());
4442

45-
private Set<TestRun> set = Collections.synchronizedSet(new HashSet<TestRun>());
43+
private final Set<TestRun> set = ConcurrentHashMap.newKeySet();
4644

4745
private Throwable ex = null;
4846

4947
@RepeatedTest(100)
50-
public void testSingleThread() {
48+
void testSingleThread() {
5149
performSet();
5250
}
5351

5452
@Test
55-
public void testConcurrent() {
53+
void testConcurrent() {
5654
for (int i = 0; i < 10; i++) {
5755
TestRun run = new TestRun(this);
5856
set.add(run);
@@ -82,7 +80,7 @@ private static void performSet() {
8280

8381
Properties p = (Properties) System.getProperties().clone();
8482

85-
assertThat(p.size() != 0).as("The System properties must not be empty").isTrue();
83+
assertThat(p).as("The System properties must not be empty").isNotEmpty();
8684

8785
for (Iterator<?> i = p.entrySet().iterator(); i.hasNext();) {
8886
i.next();
@@ -111,7 +109,7 @@ private static class TestRun implements Runnable {
111109

112110
private ConcurrentBeanWrapperTests test;
113111

114-
public TestRun(ConcurrentBeanWrapperTests test) {
112+
TestRun(ConcurrentBeanWrapperTests test) {
115113
this.test = test;
116114
}
117115

0 commit comments

Comments
 (0)