|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.io.ByteArrayOutputStream;
|
20 | 20 | import java.io.IOException;
|
21 |
| -import java.util.Collections; |
22 |
| -import java.util.HashSet; |
23 | 21 | import java.util.Iterator;
|
24 | 22 | import java.util.Properties;
|
25 | 23 | import java.util.Set;
|
| 24 | +import java.util.concurrent.ConcurrentHashMap; |
26 | 25 |
|
27 | 26 | import org.apache.commons.logging.Log;
|
28 | 27 | import org.apache.commons.logging.LogFactory;
|
29 | 28 | import org.junit.jupiter.api.RepeatedTest;
|
30 | 29 | import org.junit.jupiter.api.Test;
|
31 | 30 |
|
32 |
| - |
33 | 31 | import static org.assertj.core.api.Assertions.assertThat;
|
34 | 32 |
|
35 | 33 | /**
|
|
38 | 36 | * @author Chris Beams
|
39 | 37 | * @since 08.03.2004
|
40 | 38 | */
|
41 |
| -public class ConcurrentBeanWrapperTests { |
| 39 | +class ConcurrentBeanWrapperTests { |
42 | 40 |
|
43 | 41 | private final Log logger = LogFactory.getLog(getClass());
|
44 | 42 |
|
45 |
| - private Set<TestRun> set = Collections.synchronizedSet(new HashSet<TestRun>()); |
| 43 | + private final Set<TestRun> set = ConcurrentHashMap.newKeySet(); |
46 | 44 |
|
47 | 45 | private Throwable ex = null;
|
48 | 46 |
|
49 | 47 | @RepeatedTest(100)
|
50 |
| - public void testSingleThread() { |
| 48 | + void testSingleThread() { |
51 | 49 | performSet();
|
52 | 50 | }
|
53 | 51 |
|
54 | 52 | @Test
|
55 |
| - public void testConcurrent() { |
| 53 | + void testConcurrent() { |
56 | 54 | for (int i = 0; i < 10; i++) {
|
57 | 55 | TestRun run = new TestRun(this);
|
58 | 56 | set.add(run);
|
@@ -82,7 +80,7 @@ private static void performSet() {
|
82 | 80 |
|
83 | 81 | Properties p = (Properties) System.getProperties().clone();
|
84 | 82 |
|
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(); |
86 | 84 |
|
87 | 85 | for (Iterator<?> i = p.entrySet().iterator(); i.hasNext();) {
|
88 | 86 | i.next();
|
@@ -111,7 +109,7 @@ private static class TestRun implements Runnable {
|
111 | 109 |
|
112 | 110 | private ConcurrentBeanWrapperTests test;
|
113 | 111 |
|
114 |
| - public TestRun(ConcurrentBeanWrapperTests test) { |
| 112 | + TestRun(ConcurrentBeanWrapperTests test) { |
115 | 113 | this.test = test;
|
116 | 114 | }
|
117 | 115 |
|
|
0 commit comments