/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.lang3.builder;

import org.apache.commons.lang3.ArrayUtils;
import org.junit.Assert;
import org.junit.Test;

/**
 * Test class for ToStringExclude annotation
 * @version $Id$
 */
public class ReflectionToStringBuilderExcludeWithAnnotationTest {

    class TestFixture {
        @ToStringExclude
        private final String secretField = SECRET_VALUE;

        @SuppressWarnings("unused")
        private final String showField = NOT_SECRET_VALUE;
    }

    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";

    @Test
    public void test_toStringExclude() {
        final String toString = ReflectionToStringBuilder.toString(new TestFixture());

        Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(SECRET_FIELD));
        Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(SECRET_VALUE));
        Assert.assertTrue(toString.indexOf(NOT_SECRET_FIELD) > ArrayUtils.INDEX_NOT_FOUND);
        Assert.assertTrue(toString.indexOf(NOT_SECRET_VALUE) > ArrayUtils.INDEX_NOT_FOUND);
    }

}

@@ -853,43 +853,92 @@
 ort 
-org.apa
+static org.hamcrest.Mat
 che
+rs
 .co
-mmons.lang3.ArrayUtils
+ntainsString;%0Aimport static org.hamcrest.Matchers.not
 ;%0Aim
@@ -934,32 +934,39 @@
 ers.not;%0Aimport 
+static 
 org.junit.Assert
@@ -965,17 +965,29 @@
 t.Assert
-;
+.assertThat;%0A
 %0Aimport 
@@ -1760,72 +1760,47 @@
     
-Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf
+assertThat(toString, not(containsString
 (SEC
@@ -1810,16 +1810,17 @@
 _FIELD))
+)
 ;%0A      
@@ -1825,72 +1825,47 @@
     
-Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf
+assertThat(toString, not(containsString
 (SEC
@@ -1875,16 +1875,17 @@
 _VALUE))
+)
 ;%0A      
@@ -1886,33 +1886,26 @@
         
-Assert.
 assertT
-rue
+hat
 (toStrin
@@ -1901,32 +1901,40 @@
 hat(toString
-.indexOf
+, containsString
 (NOT_SECRET_
@@ -1943,37 +1943,8 @@
 ELD)
- %3E ArrayUtils.INDEX_NOT_FOUND
 );%0A 
@@ -1954,25 +1954,18 @@
     
-Assert.
 assertT
-rue
+hat
 (toS
@@ -1973,16 +1973,24 @@
 ring
-.indexOf
+, containsString
 (NOT
@@ -2007,37 +2007,8 @@
 LUE)
- %3E ArrayUtils.INDEX_NOT_FOUND
 );%0A 

Use hamcrest matchers for better readability of assertions