|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* Copyright 2002-2021 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. |
|
|
|
|
@ -18,18 +18,16 @@ package org.springframework.beans;
@@ -18,18 +18,16 @@ package org.springframework.beans;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
import org.junit.jupiter.api.RepeatedTest; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -38,21 +36,21 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -38,21 +36,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
* @author Chris Beams |
|
|
|
|
* @since 08.03.2004 |
|
|
|
|
*/ |
|
|
|
|
public class ConcurrentBeanWrapperTests { |
|
|
|
|
class ConcurrentBeanWrapperTests { |
|
|
|
|
|
|
|
|
|
private final Log logger = LogFactory.getLog(getClass()); |
|
|
|
|
|
|
|
|
|
private Set<TestRun> set = Collections.synchronizedSet(new HashSet<TestRun>()); |
|
|
|
|
private final Set<TestRun> set = ConcurrentHashMap.newKeySet(); |
|
|
|
|
|
|
|
|
|
private Throwable ex = null; |
|
|
|
|
|
|
|
|
|
@RepeatedTest(100) |
|
|
|
|
public void testSingleThread() { |
|
|
|
|
void testSingleThread() { |
|
|
|
|
performSet(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testConcurrent() { |
|
|
|
|
void testConcurrent() { |
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
|
TestRun run = new TestRun(this); |
|
|
|
|
set.add(run); |
|
|
|
|
@ -82,7 +80,7 @@ public class ConcurrentBeanWrapperTests {
@@ -82,7 +80,7 @@ public class ConcurrentBeanWrapperTests {
|
|
|
|
|
|
|
|
|
|
Properties p = (Properties) System.getProperties().clone(); |
|
|
|
|
|
|
|
|
|
assertThat(p.size() != 0).as("The System properties must not be empty").isTrue(); |
|
|
|
|
assertThat(p).as("The System properties must not be empty").isNotEmpty(); |
|
|
|
|
|
|
|
|
|
for (Iterator<?> i = p.entrySet().iterator(); i.hasNext();) { |
|
|
|
|
i.next(); |
|
|
|
|
@ -111,7 +109,7 @@ public class ConcurrentBeanWrapperTests {
@@ -111,7 +109,7 @@ public class ConcurrentBeanWrapperTests {
|
|
|
|
|
|
|
|
|
|
private ConcurrentBeanWrapperTests test; |
|
|
|
|
|
|
|
|
|
public TestRun(ConcurrentBeanWrapperTests test) { |
|
|
|
|
TestRun(ConcurrentBeanWrapperTests test) { |
|
|
|
|
this.test = test; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|