diff --git a/project.properties b/project.properties index 128b794d3..253983b7d 100644 --- a/project.properties +++ b/project.properties @@ -48,6 +48,6 @@ maven.compile.target = 1.1 # Valid values are 1.3, 1.4, 1.5. maven.compile.source = 1.3 -maven.jar.override=on -maven.jar.clover=1.3.2 -maven.clover.license.path=clover.license +#maven.jar.override=on +#maven.jar.clover=1.3.2 +#maven.clover.license.path=clover.license diff --git a/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java new file mode 100644 index 000000000..4854a4e6d --- /dev/null +++ b/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang.builder; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * @author ggregory + * @version $Id$ + */ +public class ReflectionToStringBuilderExcludeTest extends TestCase { + + class TestFixture { + private String secretField = SECRET_VALUE; + + private String showField = NOT_SECRET_VALUE; + } + + private static final int INDEX_NOT_FOUND = -1; + + private static final String NOT_SECRET_FIELD = "showField"; + + private static final String NOT_SECRET_VALUE = "Hello World!"; + + private static final String SECRET_FIELD = "secretField"; + + private static final String SECRET_VALUE = "secret value"; + + public void test_toStringExcluding() { + String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD); + this.validateToStringValue(toString); + } + + public void test_toStringExcludingArray() { + String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD}); + this.validateToStringValue(toString); + } + + void validateToStringValue(String toString) { + Assert.assertEquals(INDEX_NOT_FOUND, toString.indexOf(SECRET_VALUE)); + Assert.assertTrue(toString.indexOf(NOT_SECRET_FIELD) > INDEX_NOT_FOUND); + Assert.assertTrue(toString.indexOf(NOT_SECRET_VALUE) > INDEX_NOT_FOUND); + } +}