You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2005/10/05 02:06:15 UTC
svn commit: r294950 - in /jakarta/commons/proper/lang/trunk:
project.properties
src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java
Author: ggregory
Date: Tue Oct 4 17:06:11 2005
New Revision: 294950
URL: http://svn.apache.org/viewcvs?rev=294950&view=rev
Log:
A cut at http://issues.apache.org/bugzilla/show_bug.cgi?id=36925: Using ReflectionToStringBuilder and excluding secure fields.
Added:
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java (with props)
Modified:
jakarta/commons/proper/lang/trunk/project.properties
Modified: jakarta/commons/proper/lang/trunk/project.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/project.properties?rev=294950&r1=294949&r2=294950&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/project.properties (original)
+++ jakarta/commons/proper/lang/trunk/project.properties Tue Oct 4 17:06:11 2005
@@ -48,6 +48,6 @@
# 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
Added: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java?rev=294950&view=auto
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java (added)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java Tue Oct 4 17:06:11 2005
@@ -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 <a href="mailto:ggregory@seagullsw.com">ggregory</a>
+ * @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);
+ }
+}
Propchange: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Tue Oct 4 17:06:11 2005
@@ -0,0 +1 @@
+LastChangedDate Date LastChangedRevision Revision Rev LastChangedBy Author HeadURL URL Id
Propchange: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/ReflectionToStringBuilderExcludeTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org