Skip to content

Commit 919eee4

Browse files
committed
Rename concrete test classes from JUnit 3 names (*TestCase) to JUnit 4+
names (*Test) - The rename causes tests to run in a different order. - Fix an old bug in the tests that didn't setup or tear down cleanly.
1 parent 6c3d29a commit 919eee4

File tree

105 files changed

+351
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+351
-337
lines changed

pom.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
<artifactId>commons-beanutils</artifactId>
2727
<version>1.11.1-SNAPSHOT</version>
2828
<name>Apache Commons BeanUtils</name>
29-
3029
<inceptionYear>2000</inceptionYear>
3130
<description>Apache Commons BeanUtils provides an easy-to-use but flexible wrapper around reflection and introspection.</description>
3231
<url>https://commons.apache.org/proper/commons-beanutils</url>
33-
3432
<properties>
3533
<maven.compiler.source>1.8</maven.compiler.source>
3634
<maven.compiler.target>1.8</maven.compiler.target>
@@ -57,13 +55,11 @@
5755
<commons.release.isDistModule>true</commons.release.isDistModule>
5856
<commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid}</commons.distSvnStagingUrl>
5957
</properties>
60-
6158
<scm>
6259
<connection>scm:git:https://gitbox.apache.org/repos/asf?p=commons-beanutils.git</connection>
6360
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf?p=commons-beanutils.git</developerConnection>
6461
<url>https://gitbox.apache.org/repos/asf?p=commons-beanutils.git</url>
6562
</scm>
66-
6763
<distributionManagement>
6864
<site>
6965
<id>apache.website</id>
@@ -75,7 +71,6 @@
7571
<system>GitHub</system>
7672
<url>https://github.com/apache/commons-beanutils/actions</url>
7773
</ciManagement>
78-
7974
<dependencies>
8075
<dependency>
8176
<groupId>commons-logging</groupId>
@@ -104,7 +99,6 @@
10499
<scope>test</scope>
105100
</dependency>
106101
</dependencies>
107-
108102
<build>
109103
<defaultGoal>clean apache-rat:check verify japicmp:cmp javadoc:javadoc checkstyle:check</defaultGoal>
110104
<plugins>
@@ -116,23 +110,23 @@
116110
<!-- limit memory size see BEANUTILS-291 -->
117111
<argLine>${surefire.argLine}</argLine>
118112
<includes>
113+
<include>**/*Test.java</include>
119114
<include>**/*TestCase.java</include>
120115
</includes>
121116
<excludes>
122117
<!-- This test case is known to fail, and there isn't any proposed fix
123118
- so we will just exclude it until someone comes up with a solution.
124119
-->
120+
<exclude>**/*MemoryTest.java</exclude>
125121
<exclude>**/*MemoryTestCase.java</exclude>
126122
</excludes>
127-
128123
<!-- Configure Logging -->
129124
<redirectTestOutputToFile>true</redirectTestOutputToFile>
130125
<systemPropertyVariables>
131126
<org.apache.commons.logging.LogFactory>org.apache.commons.logging.impl.LogFactoryImpl</org.apache.commons.logging.LogFactory>
132127
<org.apache.commons.logging.Log>org.apache.commons.logging.impl.SimpleLog</org.apache.commons.logging.Log>
133128
<org.apache.commons.logging.simplelog.defaultlog>WARN</org.apache.commons.logging.simplelog.defaultlog>
134129
</systemPropertyVariables>
135-
136130
</configuration>
137131
</plugin>
138132
<plugin>
@@ -173,7 +167,6 @@
173167
</plugins>
174168
</pluginManagement>
175169
</build>
176-
177170
<reporting>
178171
<plugins>
179172
<plugin>

src/test/java/org/apache/commons/beanutils/BasicDynaBeanTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BasicDynaBeanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* </p>
4444
*
4545
*/
46-
public class BasicDynaBeanTestCase {
46+
public class BasicDynaBeanTest {
4747

4848
/**
4949
* The set of property names we expect to have returned when calling {@code getDynaProperties()}. You should update this list when new properties are

src/test/java/org/apache/commons/beanutils/BeanComparatorTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanComparatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Test Case for the BeanComparator class.
3030
*
3131
*/
32-
public class BeanComparatorTestCase {
32+
public class BeanComparatorTest {
3333

3434
/**
3535
* The test beans for each test.

src/test/java/org/apache/commons/beanutils/BeanIntrospectionDataTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanIntrospectionDataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Test class for {@code BeanIntrospectionData}.
2828
*
2929
*/
30-
public class BeanIntrospectionDataTestCase extends TestCase {
30+
public class BeanIntrospectionDataTest extends TestCase {
3131
/** Constant for the test bean class. */
3232
private static final Class<?> BEAN_CLASS = FluentIntrospectionTestBean.class;
3333

src/test/java/org/apache/commons/beanutils/BeanMapTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanMapTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
*/
3737
@SuppressWarnings("deprecation")
38-
public class BeanMapTestCase extends AbstractTestMap {
38+
public class BeanMapTest extends AbstractTestMap {
3939

4040
public static class BeanThrowingExceptions extends BeanWithProperties {
4141
private static final long serialVersionUID = 1L;
@@ -161,7 +161,7 @@ public static void main(final String[] args) {
161161
}
162162

163163
public static Test suite() {
164-
return BulkTest.makeSuite(BeanMapTestCase.class);
164+
return BulkTest.makeSuite(BeanMapTest.class);
165165
}
166166

167167
/**
@@ -172,7 +172,7 @@ public static Test suite() {
172172
**/
173173
private final Object objectInFullMap = new Object();
174174

175-
public BeanMapTestCase(final String testName) {
175+
public BeanMapTest(final String testName) {
176176
super(testName);
177177
}
178178

src/test/java/org/apache/commons/beanutils/BeanPredicateTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanPredicateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
/**
2828
*/
29-
public class BeanPredicateTestCase extends TestCase {
29+
public class BeanPredicateTest extends TestCase {
3030

31-
public BeanPredicateTestCase(final String name) {
31+
public BeanPredicateTest(final String name) {
3232
super(name);
3333
}
3434

src/test/java/org/apache/commons/beanutils/BeanPropertyValueChangeClosureTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanPropertyValueChangeClosureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Test cases for {@code BeanPropertyValueChangeClosure}.
2424
*
2525
*/
26-
public class BeanPropertyValueChangeClosureTestCase extends TestCase {
26+
public class BeanPropertyValueChangeClosureTest extends TestCase {
2727

2828
private static final Integer expectedIntegerValue = Integer.valueOf(123);
2929
private static final Float expectedFloatValue = Float.valueOf(123.123f);
@@ -36,7 +36,7 @@ public class BeanPropertyValueChangeClosureTestCase extends TestCase {
3636
*
3737
* @param name Name of this test case.
3838
*/
39-
public BeanPropertyValueChangeClosureTestCase(final String name) {
39+
public BeanPropertyValueChangeClosureTest(final String name) {
4040
super(name);
4141
}
4242

src/test/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicateTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanPropertyValueEqualsPredicateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Test cases for {@code BeanPropertyValueEqualsPredicateTest}.
2424
*
2525
*/
26-
public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
26+
public class BeanPropertyValueEqualsPredicateTest extends TestCase {
2727

2828
private static final Integer expectedIntegerValue = Integer.valueOf(123);
2929
private static final Float expectedFloatValue = Float.valueOf(123.123f);
@@ -36,7 +36,7 @@ public class BeanPropertyValueEqualsPredicateTestCase extends TestCase {
3636
*
3737
* @param name Name of this test case.
3838
*/
39-
public BeanPropertyValueEqualsPredicateTestCase(final String name) {
39+
public BeanPropertyValueEqualsPredicateTest(final String name) {
4040
super(name);
4141
}
4242

src/test/java/org/apache/commons/beanutils/BeanToPropertyValueTransformerTestCase.java renamed to src/test/java/org/apache/commons/beanutils/BeanToPropertyValueTransformerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Test cases for {@code BeanToPropertyValueTransformer}.
2424
*
2525
*/
26-
public class BeanToPropertyValueTransformerTestCase extends TestCase {
26+
public class BeanToPropertyValueTransformerTest extends TestCase {
2727

2828
private static final Integer expectedIntegerValue = Integer.valueOf(123);
2929
private static final Long expectedLongValue = Long.valueOf(123);
@@ -37,7 +37,7 @@ public class BeanToPropertyValueTransformerTestCase extends TestCase {
3737
*
3838
* @param name Name of this test case.
3939
*/
40-
public BeanToPropertyValueTransformerTestCase(final String name) {
40+
public BeanToPropertyValueTransformerTest(final String name) {
4141
super(name);
4242
}
4343

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.commons.beanutils;
19+
20+
import org.apache.commons.beanutils.locale.LocaleBeanUtilsBean;
21+
22+
public class BeanUtilCaches {
23+
24+
/**
25+
* Clears all the BeanUtils Caches manually.
26+
*
27+
* This is probably overkill, but since we're dealing with static caches
28+
* it seems sensible to ensure that all test cases start with a clean sheet.
29+
*/
30+
public static void clear() {
31+
32+
// Clear BeanUtilsBean's PropertyUtilsBean descriptor caches
33+
BeanUtilsBean.getInstance().getPropertyUtils().clearDescriptors();
34+
35+
// Clear LocaleBeanUtilsBean's PropertyUtilsBean descriptor caches
36+
LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getPropertyUtils().clearDescriptors();
37+
38+
// Clear MethodUtils's method cache
39+
MethodUtils.clearCache();
40+
41+
// Clear WrapDynaClass cache
42+
WrapDynaClass.clear();
43+
44+
// Replace the existing BeanUtilsBean instance for the current class loader with a new, clean instance
45+
BeanUtilsBean.setInstance(new BeanUtilsBean());
46+
47+
// Replace the existing LocaleBeanUtilsBean instance for the current class loader with a new, clean instance
48+
LocaleBeanUtilsBean.setInstance(new LocaleBeanUtilsBean());
49+
}
50+
}

0 commit comments

Comments
 (0)