//////////////////////////////////////////////////////////////////////////////
// 
//               Copyright 2010, Starting Block Technologies
//                        www.startingblocktech.com
//
//////////////////////////////////////////////////////////////////////////////

package com.startingblocktech.tcases.io;

import org.junit.Test;
import static org.junit.Assert.*;

import org.apache.commons.io.IOUtils;

import java.io.File;

/**
 * Runs tests for the {@link TransformFilter}.
 *
 * @version $Revision$, $Date$
 */
public class TestTransformFilter
  {
  @Test
  public void testWriteFile() throws Exception
    {
    // Given...
    TransformFilter filter =
      new TransformFilter
      ( getClass().getResourceAsStream( "/testDef2Junit.xsl"));

    File target = File.createTempFile( "TestTransformFilter-WriteFile-", ".java");
    target.deleteOnExit();
    filter.setTarget( target);

    // When...
    IOUtils.copy
      ( getClass().getResourceAsStream( "system-test-def-2.xml"),
        filter.getSource());
    filter.getSource().close();
    
    // Then...
    assertEquals( "Output written, target=" + target, true, target.length() > 0);
    }
  }
@@ -417,39 +417,140 @@
 .io.
-IOUtils;%0D%0A%0D%0Aimport java.io.File
+FileUtils;%0D%0Aimport org.apache.commons.io.IOUtils;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.regex.Pattern
 ;%0D%0A%0D
@@ -1253,24 +1253,31 @@
  written
+%22, true
 , target
 =%22 + tar
@@ -1272,46 +1272,1794 @@
 rget
-=%22 + target, true, target.length() %3E 0
+.length() %3E 0);%0D%0A%0D%0A    String result = FileUtils.readFileToString( target);%0D%0A    assertEquals%0D%0A      ( %22System tested=default%22,%0D%0A        true,%0D%0A        contains( result, %22Tests %5C%5C%7B@link System-2#Function-0 Function-0%5C%5C(%5C%5C)%5C%5C%7D%22));%0D%0A    assertEquals%0D%0A      ( %22Throws=default%22,%0D%0A        true,%0D%0A        contains( result, %22public void Function-0_0%5C%5C(%5C%5C)$%22));%0D%0A    %7D%0D%0A  %0D%0A  @Test%0D%0A  public void testWithParams() throws Exception%0D%0A    %7B%0D%0A    // Given...%0D%0A    TransformFilter filter =%0D%0A      new TransformFilter%0D%0A      ( getClass().getResourceAsStream( %22/testDef2Junit.xsl%22));%0D%0A%0D%0A    File target = File.createTempFile( %22TestTransformFilter-WithParams-%22, %22.java%22);%0D%0A    target.deleteOnExit();%0D%0A    filter.setTarget( target);%0D%0A%0D%0A    HashMap%3CString,Object%3E params = new HashMap%3CString,Object%3E();%0D%0A    params.put( %22throws%22, %22true%22);%0D%0A    params.put( %22class%22, %22SUT%22);%0D%0A    filter.setParams( params);%0D%0A%0D%0A    // When...%0D%0A    IOUtils.copy%0D%0A      ( getClass().getResourceAsStream( %22system-test-def-2.xml%22),%0D%0A        filter.getSource());%0D%0A    filter.getSource().close();%0D%0A    %0D%0A    // Then...%0D%0A    assertEquals( %22Output written%22, true, target.length() %3E 0);%0D%0A%0D%0A    String result = FileUtils.readFileToString( target);%0D%0A    assertEquals%0D%0A      ( %22System tested=SUT%22,%0D%0A        true,%0D%0A        contains( result, %22Tests %5C%5C%7B@link SUT#Function-0 Function-0%5C%5C(%5C%5C)%5C%5C%7D%22));%0D%0A    assertEquals%0D%0A      ( %22Throws=Exception%22,%0D%0A        true,%0D%0A        contains( result, %22public void Function-0_0%5C%5C(%5C%5C) throws Exception$%22));%0D%0A    %7D%0D%0A%0D%0A  /**%0D%0A   * Returns true if the given transform result contains a match for the given%0D%0A   * regular expression.%0D%0A   */%0D%0A  private boolean contains( String result, String pattern)%0D%0A    %7B%0D%0A    return%0D%0A      Pattern.compile( pattern, Pattern.MULTILINE)%0D%0A      .matcher( result)%0D%0A      .find(
 );%0D%0A

Add testWithParams