Port to JUnit 4.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1185702 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2011-10-18 14:53:59 +00:00
parent d9ad78065d
commit fa1c89f7e1
1 changed files with 13 additions and 2 deletions

View File

@ -22,14 +22,14 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import junit.framework.Assert; import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
/** /**
* @version $Id$ * @version $Id$
*/ */
public class ReflectionToStringBuilderExcludeTest extends TestCase { public class ReflectionToStringBuilderExcludeTest {
class TestFixture { class TestFixture {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -47,26 +47,31 @@ public class ReflectionToStringBuilderExcludeTest extends TestCase {
private static final String SECRET_VALUE = "secret value"; private static final String SECRET_VALUE = "secret value";
@Test
public void test_toStringExclude() { public void test_toStringExclude() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD);
this.validateSecretFieldAbsent(toString); this.validateSecretFieldAbsent(toString);
} }
@Test
public void test_toStringExcludeArray() { public void test_toStringExcludeArray() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD}); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD});
this.validateSecretFieldAbsent(toString); this.validateSecretFieldAbsent(toString);
} }
@Test
public void test_toStringExcludeArrayWithNull() { public void test_toStringExcludeArrayWithNull() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null}); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null});
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeArrayWithNulls() { public void test_toStringExcludeArrayWithNulls() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null}); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null});
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeCollection() { public void test_toStringExcludeCollection() {
List<String> excludeList = new ArrayList<String>(); List<String> excludeList = new ArrayList<String>();
excludeList.add(SECRET_FIELD); excludeList.add(SECRET_FIELD);
@ -74,6 +79,7 @@ public class ReflectionToStringBuilderExcludeTest extends TestCase {
this.validateSecretFieldAbsent(toString); this.validateSecretFieldAbsent(toString);
} }
@Test
public void test_toStringExcludeCollectionWithNull() { public void test_toStringExcludeCollectionWithNull() {
List<String> excludeList = new ArrayList<String>(); List<String> excludeList = new ArrayList<String>();
excludeList.add(null); excludeList.add(null);
@ -81,6 +87,7 @@ public class ReflectionToStringBuilderExcludeTest extends TestCase {
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeCollectionWithNulls() { public void test_toStringExcludeCollectionWithNulls() {
List<String> excludeList = new ArrayList<String>(); List<String> excludeList = new ArrayList<String>();
excludeList.add(null); excludeList.add(null);
@ -89,21 +96,25 @@ public class ReflectionToStringBuilderExcludeTest extends TestCase {
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeEmptyArray() { public void test_toStringExcludeEmptyArray() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY);
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeEmptyCollection() { public void test_toStringExcludeEmptyCollection() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>()); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeNullArray() { public void test_toStringExcludeNullArray() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null);
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
} }
@Test
public void test_toStringExcludeNullCollection() { public void test_toStringExcludeNullCollection() {
String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null); String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null);
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);