/******************************************************************
 * File:        UtilForTests.java
 * Created by:  Dave Reynolds
 * Created on:  14-Jan-03
 * 
 * (c) Copyright 2003, Hewlett-Packard Development Company, LP
 * [See end of file]
 * $Id: TestUtil.java,v 1.7 2003-08-27 13:11:15 andy_seaborne Exp $
 *****************************************************************/
package com.hp.hpl.jena.reasoner.test;

import junit.framework.TestCase;
import java.util.Iterator;
import org.apache.log4j.Logger;

/**
 * Collection of utilities to assist with unit testing.
 * 
 * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
 * @version $Revision: 1.7 $ on $Date: 2003-08-27 13:11:15 $
 */
public class TestUtil {
    
    /** log4j logger*/
    static Logger logger = Logger.getLogger(TestUtil.class);

    /** Helper function test an iterator against a list of objects - order independent */
    public static void assertIteratorValues(TestCase testCase, Iterator it, Object[] vals) {
        boolean[] found = new boolean[vals.length];
        for (int i = 0; i < vals.length; i++) found[i] = false;
        while (it.hasNext()) {
            Object n = it.next();
            boolean gotit = false;
            for (int i = 0; i < vals.length; i++) {
                if (n.equals(vals[i])) {
                    gotit = true;
                    found[i] = true;
                }
            }
            if (!gotit) {
                logger.debug("TestUtil found unexpected value: " + n);
            }
            TestCase.assertTrue(gotit);
        }
        for (int i = 0; i < vals.length; i++) {
            if (!found[i]) {
                logger.debug("TestUtil failed to find expected value: " + vals[i]);
            }
            TestCase.assertTrue(found[i]);
        }
    }
    

    /**
     * Replace all blocks of white space by a single space character, just
     * used for creating test cases.
     * 
     * @param src the original string
     * @return normalized version of src
     */
    public static String normalizeWhiteSpace(String src) {
        StringBuffer result = new StringBuffer(src.length());
        boolean inWhitespaceBlock = false;
        for (int i = 0; i < src.length(); i++) {
            char c = src.charAt(i);
            if (Character.isWhitespace(c)) {
                if (!inWhitespaceBlock) {
                    result.append(" ");
                    inWhitespaceBlock = true;
                }
            } else {
                inWhitespaceBlock = false;
                result.append(c);
            }
        }
        return result.toString();
    }
    
    /**
     * Check the length of an iterator.
     */
    public static void assertIteratorLength(Iterator it, int expectedLength) {
        int length = 0;
        while (it.hasNext()) {
            it.next();
            length++;
        }
        TestCase.assertEquals(expectedLength, length);
    }
}

/*
    (c) Copyright 2003 Hewlett-Packard Development Company, LP
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.

    3. The name of the author may not be used to endorse or promote products
       derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


@@ -269,43 +269,43 @@
 v 1.
-7
+8
  2003-
-08-27 13:11:1
+12-08 09:29:3
 5 
+i
 an
-dy_seaborne
+_dickinson
  Exp
@@ -663,17 +663,17 @@
 sion: 1.
-7
+8
  $ on $D
@@ -686,21 +686,21 @@
 003-
-08-27 13:11:1
+12-08 09:29:3
 5 $%0A
@@ -736,93 +736,8 @@
    %0A
-    /** log4j logger*/%0A    static Logger logger = Logger.getLogger(TestUtil.class);%0A%0A
     
@@ -911,24 +911,98 @@
 t%5B%5D vals) %7B%0A
+        Logger logger = Logger.getLogger( testCase.getClass() );%0A        %0A
         bool
@@ -1456,25 +1456,39 @@
 r.debug(
-%22TestUtil
+ testCase.getName() + %22
  found u
@@ -1489,32 +1489,41 @@
 ound unexpected 
+iterator 
 value: %22 + n);%0A 
@@ -1567,16 +1567,74 @@
 ertTrue(
+ testCase.getName() + %22 found unexpected iterator value%22, 
 gotit);%0A
@@ -1753,17 +1753,31 @@
 bug(
-%22TestUtil
+ testCase.getName() + %22
  fai
@@ -1797,16 +1797,25 @@
 xpected 
+iterator 
 value: %22
@@ -1873,16 +1873,80 @@
 ertTrue(
+testCase.getName() + %22 failed to find expected iterator value%22, 
 found%5Bi%5D

Minor change to use a logger based on the given test class