You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2004/04/10 20:18:58 UTC

cvs commit: jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/server/runner TestXMLFormatter.java

vmassol     2004/04/10 11:18:58

  Modified:    framework/src/test/share/org/apache/cactus TestAll.java
  Added:       framework/src/test/share/org/apache/cactus/internal
                        TestWebTestResult.java
                        AbstractTestAbstractCactusTestCase.java
                        TestAbstractCactusTestCase.java
               framework/src/test/share/org/apache/cactus/internal/util
                        TestUniqueGenerator.java TestStringUtil.java
                        TestIoUtil.java TestTestCaseImplementChecker.java
                        TestCookieUtil.java
               framework/src/test/share/org/apache/cactus/internal/server
                        TestServletUtil.java
               framework/src/test/share/org/apache/cactus/internal/server/runner
                        TestXMLFormatter.java
  Removed:     framework/src/test/share/org/apache/cactus/util
                        TestStringUtil.java
                        TestTestCaseImplementChecker.java
                        TestUniqueGenerator.java TestCookieUtil.java
                        TestAll.java TestIoUtil.java
               framework/src/test/share/org/apache/cactus
                        TestAbstractTestCase.java TestServletUtil.java
                        AbstractTestAbstractTestCase.java
                        TestWebTestResult.java
               framework/src/test/share/org/apache/cactus/server/runner
                        TestXMLFormatter.java
               framework/src/test/share/org/apache/cactus/internal/client
                        TestAll.java
  Log:
  Moved more internal classes (i.e. non user-public classes) to the internal package
  
  Revision  Changes    Path
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/TestWebTestResult.java
  
  Index: TestWebTestResult.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests of the <code>WebTestResult</code> class.
   *
   * @version $Id: TestWebTestResult.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestWebTestResult extends TestCase
  {
      /**
       * Verify the correctness of the XML representation for a test result with
       * no error.
       */
      public void testToXmlNoException()
      {
          WebTestResult result = new WebTestResult();
  
          assertEquals("<webresult></webresult>", result.toXml());
      }
  
      /**
       * Verify the correctness of the XML representation for a test result with
       * an exception.
       */
      public void testToXmlWithException()
      {
          String expectedStart = "<webresult><exception classname=\""
              + "java.lang.Exception\"><message><![CDATA[test exception]]>"
              + "</message><stacktrace><![CDATA[";
          String expectedEnd = "]]></stacktrace></exception></webresult>";
  
          Exception e = new Exception("test exception");
          WebTestResult result = new WebTestResult(e);
  
          assertTrue("Should have started with [" + expectedStart + "]", 
              result.toXml().startsWith(expectedStart));
          assertTrue("Should have ended with [" + expectedEnd + "]", 
              result.toXml().endsWith(expectedEnd));
      }
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/AbstractTestAbstractCactusTestCase.java
  
  Index: AbstractTestAbstractCactusTestCase.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal;
  
  import java.io.ByteArrayInputStream;
  
  import java.net.URL;
  
  import junit.framework.AssertionFailedError;
  import junit.framework.TestCase;
  
  import org.apache.cactus.WebRequest;
  import org.apache.cactus.internal.client.ClientException;
  import org.apache.cactus.internal.client.ClientTestCaseCaller;
  import org.apache.cactus.internal.client.WebResponseObjectFactory;
  import org.apache.cactus.internal.client.connector.http.HttpProtocolHandler;
  import org.apache.cactus.internal.configuration.ServletConfiguration;
  import org.apache.cactus.internal.util.JUnitVersionHelper;
  import org.apache.cactus.mock.MockHttpURLConnection;
  
  /**
   * Test class that intercepts all exceptions (and assert them) coming from 
   * test case classes that inherits from it. This class is used to unit test 
   * the {@link AbstractCactusTestCase} class.
   *
   * @version $Id: AbstractTestAbstractCactusTestCase.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public abstract class AbstractTestAbstractCactusTestCase extends TestCase 
  {   
      /**
       * Override default method so that configuration checks are not run during
       * these unit tests.
       *
       * @exception Throwable if any exception is thrown during the test. Any
       *            exception will be displayed by the JUnit Test Runner
       * @see AbstractTestCase#runBare()
       */
      public void runBare() throws Throwable
      {
          runTest();
      }
  
      /**
       * Intercepts running test cases to check for normal exceptions.
       *
       * @exception Throwable any error that occurred when calling the test method
       *            for the current test case.
       * @see AbstractTestCase#runTest()
       */
      protected void runTest() throws Throwable
      {
          ClientTestCaseCaller delegator = new ClientTestCaseCaller(
              this, this, new HttpProtocolHandler(new ServletConfiguration()));
  
          try
          {
              // Call the begin method
              WebRequest request = new WebRequestImpl(new ServletConfiguration());
  
              delegator.callBeginMethod(request);
  
              // Create a mock HttpURLConnection as it is needed by HttpUnit
              // for creating a WebResponse
              MockHttpURLConnection connection = new MockHttpURLConnection(
                  new URL("http://something"));
  
              // Set the values expected by Http Unit. Note: only the test
              // cases that have an end method with an HttpUnit WebReponse
              // will use the HttpURLConnection.
              connection.setExpectedGetHeaderField("HTTP/1.1 200 OK");
              connection.setExpectedGetInputStream(
                  new ByteArrayInputStream("".getBytes()));
  
              // Create a WebResponse object and call the end method
              delegator.callEndMethod(request, 
                  new WebResponseObjectFactory(connection));
          }
          catch (AssertionFailedError e)
          {
              // Perform asserts
              if (!verifyBeginMethodsOk(e.getMessage())
                  && !verifyEndMethodsOk(e.getMessage()))
              {
                  throw e;
              }
          }
          catch (ClientException e)
          {
              // Perform asserts
              if (!verifyBeginMethodsOk(e.getMessage())
                  && !verifyEndMethodsOk(e.getMessage()))
              {
                  throw e;
              }
          }
      }
  
      /**
       * @param theTestName the test name to verify
       * @return true if the test name to verify corresponds to the currently
       *         executing test
       */
      private boolean checkName(String theTestName)
      {
          return JUnitVersionHelper.getTestCaseName(this).equals(
              theTestName);
      }
      
      /**
       * Assert begin method tests.
       *
       * @param theMessage the error message from the exception
       * @return false is no test matches
       */
      private boolean verifyBeginMethodsOk(String theMessage)
      {
          // Test that when a begin method for a given test does not have the
          // correct return type (i.e. void), a
          // <code>AssertionFailedError</code> exception is returned.
          if (checkName("testBeginMethodBadReturnType"))
          {
              assertEquals("The method "
                  + "[beginBeginMethodBadReturnType] should return void and "
                  + "not [java.lang.String]", theMessage);
  
              return true;
          }
  
          // Test that when a begin method for a given test is not declared
          // public a <code>AssertionFailedError</code> exception is returned.
          if (checkName("testBeginMethodNotPublic"))
          {
              assertEquals("Method [beginBeginMethodNotPublic] should be "
                  + "declared public", theMessage);
  
              return true;
          }
  
          // Test that when a begin method for a given test has the wrong
          // type of parameters, a <code>AssertionFailedError</code> exception
          // is returned.
          if (checkName("testBeginMethodBadParamType"))
          {
              assertEquals("The method "
                  + "[beginBeginMethodBadParamType] must accept "
                  + "[org.apache.cactus.Request] as 1st parameter, but "
                  + "found a [java.lang.String] parameter instead", theMessage);
  
              return true;
          }
  
          // Test that when a begin method for a given test has the wrong
          // number of parameters, a <code>AssertionFailedError</code>
          // exception is returned.
          if (checkName("testBeginMethodBadParamNumber"))
          {
              assertEquals("The method "
                  + "[beginBeginMethodBadParamNumber] must have "
                  + "1 parameter(s), but 2 parameter(s) were found",
                  theMessage);
  
              return true;
          }
  
          // Verify that the begin method with a
          // <code>WebRequest</code> parameter is called correctly.
          if (checkName("testBeginMethodOK"))
          {
              assertEquals("beginBeginMethodOK", theMessage);
  
              return true;
          }
  
          return false;
      }
  
      /**
       * Assert end method tests.
       *
       * @param theMessage the error message from the exception
       * @return false is no test matches
       */
      private boolean verifyEndMethodsOk(String theMessage)
      {
          // Test that when an end method for a given test does not have the
          // correct return type (i.e. void), a
          // <code>AssertionFailedError</code> exception is returned.
          if (checkName("testEndMethodBadReturnType"))
          {
              assertEquals("The method "
                  + "[endEndMethodBadReturnType] should return void and "
                  + "not [java.lang.String]", theMessage);
  
              return true;
          }
  
          // Test that when an end method for a given test is not declared
          // public a <code>AssertionFailedError</code> exception is returned.
          if (checkName("testEndMethodNotPublic"))
          {
              assertEquals("Method [endEndMethodNotPublic] should be "
                  + "declared public", theMessage);
  
              return true;
          }
  
          // Test that when an end method for a given test has the wrong
          // type of parameters, a <code>AssertionFailedError</code> exception
          // is returned.
          if (checkName("testEndMethodBadParamType"))
          {
              assertEquals("The method [endEndMethodBadParamType] "
                  + "has a bad parameter of type [java.lang.String]", 
                  theMessage);
  
              return true;
          }
  
          // Test that when an end method for a given test has the wrong
          // number of parameters, a <code>AssertionFailedError</code>
          // exception is returned.
          if (checkName("testEndMethodBadParamNumber"))
          {
              assertEquals("The method [endEndMethodBadParamNumber] "
                  + "must have 1 parameter(s), but 2 parameter(s) were found",
                  theMessage);
  
              return true;
          }
  
          // Test that the end method is called correctly when it's signature
          // contains a <code>org.apache.cactus.WebResponse</code>
          // parameter.
          if (checkName("testEndMethodOK1"))
          {
              assertEquals("endEndMethodOK1", theMessage);
  
              return true;
          }
  
          // Test that the end method is called correctly when it's signature
          // contains a <code>com.meterware.httpunit.WebResponse</code>
          // parameter.
          if (checkName("testEndMethodOK2"))
          {
              assertEquals("endEndMethodOK2", theMessage);
  
              return true;
          }
  
          // Test that the deprecated end method with the
          // <code>HttpURLConnection</code> parameter can still be called
          // correctly.
          if (checkName("testEndMethodOK3"))
          {
              assertEquals("endEndMethodOK3", theMessage);
  
              return true;
          }
  
          return false;
      }
  
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/TestAbstractCactusTestCase.java
  
  Index: TestAbstractCactusTestCase.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal;
  
  import java.net.HttpURLConnection;
  
  import org.apache.cactus.WebRequest;
  import org.apache.cactus.WebResponse;
  
  /**
   * Unit tests of the {@link AbstractCactusTestCase} class.
   *
   * @version $Id: TestAbstractCactusTestCase.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestAbstractCactusTestCase 
      extends AbstractTestAbstractCactusTestCase
  {
      /**
       * @see #testBeginMethodBadReturnType()
       */
      public String beginBeginMethodBadReturnType(WebRequest theRequest)
      {
          // Return anything just to make the compiler happy ...
          return "";
      }
  
      /**
       * Test that when a begin method for a given test does not have the correct
       * return type (i.e. void), a <code>AssertionFailedError</code> exception
       * is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testBeginMethodBadReturnType()
      {
          // This method only exist so that a test exist and thus the begin
          // method for that test will be called.
          // Should not reach this point
          fail("Should not reach this point");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * @see #testBeginMethodNotPublic()
       */
      private void beginBeginMethodNotPublic(WebRequest theRequest)
      {
      }
  
      /**
       * Test that when a begin method for a given test is not declared public
       * a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testBeginMethodNotPublic()
      {
          // This method only exist so that a test exist and thus the begin
          // method for that test will be called.
          // Should not reach this point
          fail("Should not reach this point");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * @see #testBeginMethodBadReturnType()
       */
      public void beginBeginMethodBadParamType(String theDummy)
      {
      }
  
      /**
       * Test that when a begin method for a given test has the wrong type of
       * parameters, a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testBeginMethodBadParamType()
      {
          // This method only exist so that a test exist and thus the begin
          // method for that test will be called.
          // Should not reach this point
          fail("Should not reach this point");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * @see #testBeginMethodBadParamNumber()
       */
      public void beginBeginMethodBadParamNumber(WebRequest theRequest, 
          String theString)
      {
      }
  
      /**
       * Test that when a begin method for a given test has the wrong number of
       * parameters, a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testBeginMethodBadParamNumber()
      {
          // This method only exist so that a test exist and thus the begin
          // method for that test will be called.
          // Should not reach this point
          fail("Should not reach this point");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * @see #testBeginMethodOK()
       */
      public void beginBeginMethodOK(WebRequest theRequest)
      {
          // We send an exception just to verify that this code has been reached
          // The exception is intercepted in
          // TestAbstractTestCaseInterceptorTestCase
          fail("beginBeginMethodOK");
      }
  
      /**
       * Verify that the begin method with a
       * <code>WebRequest</code> parameter is called correctly.
       */
      public void testBeginMethodOK()
      {
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that when an end method for a given test does not have the correct
       * return type (i.e. void), a <code>AssertionFailedError</code> exception
       * is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testEndMethodBadReturnType()
      {
          // This method only exist so that a test exist and thus the begin
          // method for that test will be called.
      }
  
      /**
       * @see #testEndMethodBadReturnType()
       */
      public String endEndMethodBadReturnType(WebResponse theResponse)
      {
          // Return anything just to make the compiler happy ...
          return "";
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that when an end method for a given test is not declared public
       * a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testEndMethodNotPublic()
      {
      }
  
      /**
       * @see #testEndMethodNotPublic()
       */
      private void endEndMethodNotPublic(WebResponse theResponse)
      {
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that when an end method for a given test has the wrong type of
       * parameters, a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testEndMethodBadParamType()
      {
      }
  
      /**
       * @see #testEndMethodBadParamType()
       */
      public void endEndMethodBadParamType(String theDummy)
      {
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that when an end method for a given test has the wrong number of
       * parameters, a <code>AssertionFailedError</code> exception is returned.
       * Note: the assert is done in the
       * <code>TestAbstractTestCaseInterceptorTestCase</code> class.
       */
      public void testEndMethodBadParamNumber()
      {
      }
  
      /**
       * @see #testEndMethodBadParamNumber()
       */
      public void endEndMethodBadParamNumber(WebResponse theResponse, 
          String theDummy)
      {
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that the end method is called correctly when it's signature
       * contains a <code>org.apache.cactus.WebResponse</code> parameter.
       */
      public void testEndMethodOK1()
      {
      }
  
      /**
       * @see #testEndMethodOK1()
       */
      public void endEndMethodOK1(WebResponse theResponse)
      {
          // We send an exception just to verify that this code has been reached
          // The exception is intercepted in
          // TestAbstractTestCaseInterceptorTestCase
          fail("endEndMethodOK1");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that the end method is called correctly when it's signature
       * contains a <code>com.meterware.httpunit.WebResponse</code> parameter.
       *
       * Note: We need the Httpunit jar and an XML parser jar on the classpath
       * for this test
       */
      public void testEndMethodOK2()
      {
      }
  
      /**
       * @see #testEndMethodOK2()
       */
      public void endEndMethodOK2(com.meterware.httpunit.WebResponse theResponse)
      {
          // We send an exception just to verify that this code has been reached
          // The exception is intercepted in
          // TestAbstractTestCaseInterceptorTestCase
          fail("endEndMethodOK2");
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Test that the deprecated end method with the
       * <code>HttpURLConnection</code> parameter can still be called correctly.
       */
      public void testEndMethodOK3()
      {
      }
  
      /**
       * @see #testEndMethodOK3()
       */
      public void endEndMethodOK3(HttpURLConnection theResponse)
      {
          // We send an exception just to verify that this code has been reached
          // The exception is intercepted in
          // TestAbstractTestCaseInterceptorTestCase
          fail("endEndMethodOK3");
      }
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/util/TestUniqueGenerator.java
  
  Index: TestUniqueGenerator.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal.util;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  import org.apache.cactus.ServletTestCase;
  import org.apache.cactus.util.ChainedRuntimeException;
  
  import junit.framework.TestCase;
  
  /**
   * Smoke test for the unique id generator.
   * 
   * @version $Id: TestUniqueGenerator.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestUniqueGenerator extends TestCase
  {
      /**
       * @see TestCase#setUp
       */
      protected void setUp()
      {
          // let the generator initialize
          UniqueGenerator.generate(new ServletTestCase("foo"));
      }
  
      /**
       * Simulates several simultaneous id generations using threads.
       * Verifies that there are no duplicates among the generated ids.
       */
      public void testThatSimultaneouslyGeneratedIdsAreUnique()
      {
          final ServletTestCase aTestCase = new ServletTestCase("foo");
  
          Thread[] threads = new Thread[10];
          final List results = Collections.synchronizedList(new ArrayList());
          for (int i = 0; i < threads.length; i++)
          {
              threads[i] = new Thread()
              {
                  public void run()
                  {
                      results.add(UniqueGenerator.generate(aTestCase));
                  }
              };
          }
  
          // loops separate to make their beginning as simultaneous
          // as possible
          for (int i = 0; i < threads.length; i++)
          {
              threads[i].run();
          }
  
          try
          {
              // in case the threads need time to finish
              Thread.sleep(200);
          }
          catch (InterruptedException e)
          {
              throw new ChainedRuntimeException(e);
          }
  
          Set resultSet = new HashSet(results);
          assertEquals(
              "Results contained duplicate ids.",
              results.size(),
              resultSet.size());
      }
  
      /**
       * Sanity check to verify that different IDs are generated for different
       * instances of the test class.
       */
      public void testThatGeneratedIdsForDifferentTestCasesAreUnique()
      {
          final ServletTestCase firstTestCase = new ServletTestCase("foo");
          final ServletTestCase secondTestCase = new ServletTestCase("foo");
          
          String firstId = UniqueGenerator.generate(firstTestCase, 0);
          String secondId = UniqueGenerator.generate(secondTestCase, 0);
  
          assertFalse("IDs not unique", firstId.equals(secondId));
      }
  
      /**
       * Sanity check to verify that different IDs are generated for different
       * test methods/names.
       */
      public void testThatGeneratedIdsForDifferentTestMethodsAreUnique()
      {
          final ServletTestCase aTestCase = new ServletTestCase("foo");
          
          String firstId = UniqueGenerator.generate(aTestCase, 0);
          aTestCase.setName("bar");
          String secondId = UniqueGenerator.generate(aTestCase, 0);
  
          assertFalse("IDs not unique", firstId.equals(secondId));
      }
  
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/util/TestStringUtil.java
  
  Index: TestStringUtil.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal.util;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests for the {@link StringUtil} class.
   *
   * @version $Id: TestStringUtil.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestStringUtil extends TestCase
  {
      /**
       * Verify package-based stack-trace filtering.
       */
      public void testFilterLinePackageTrue()
      {
          String[] filterPatterns = new String[] {"my.package" };
          assertTrue(StringUtil.filterLine(
              "    at my.package.MyClass.method(MyClass.java:100)",
              filterPatterns));
      }
      
      /**
       * Verify package-based stack-trace filtering.
       */
      public void testFilterLinePackageFalse()
      {
          String[] filterPatterns = new String[] {"my.package" };
          assertTrue(!StringUtil.filterLine(
              "    at other.package.MyClass.method(MyClass.java:100)",
              filterPatterns));
      }
  
      /**
       * Verify class-based stack-trace filtering.
       */
      public void testFilterLineClassTrue()
      {
          String[] filterPatterns = new String[] {"my.package.MyClass" };
          assertTrue(StringUtil.filterLine(
              "    at my.package.MyClass.method(MyClass.java:100)",
              filterPatterns));
      }
  
      /**
       * Verify class-based stack-trace filtering.
       */
      public void testFilterLineClassFalse1()
      {
          String[] filterPatterns = new String[] {"my.package.MyClass" };
          assertTrue(!StringUtil.filterLine(
              "    at my.package.OtherClass.method(MyClass.java:100)",
              filterPatterns));
      }
  
      /**
       * Verify class-based stack-trace filtering.
       */
      public void testFilterLineClassFalse2()
      {
          String[] filterPatterns = new String[] {"my.package.MyClass" };
          assertTrue(!StringUtil.filterLine(
              "    at other.package.MyClass.method(MyClass.java:100)",
              filterPatterns));
      }
  
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/util/TestIoUtil.java
  
  Index: TestIoUtil.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2004 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.cactus.internal.util;
  
  import java.io.ByteArrayInputStream;
  import java.io.IOException;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests for the {@link IoUtil} class.
   *
   * @version $Id: TestIoUtil.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestIoUtil extends TestCase
  {
      /**
       * Verify that the <code>getText()</code> method reads properly all bytes 
       * from an input stream.
       * 
       * @exception IOException on error
       */
      public void testGetTextOk() throws IOException
      {
          String expected = 
              "<html><head/>\n<body>A GET request</body>\n</html>\n";
          ByteArrayInputStream in = new ByteArrayInputStream(expected.getBytes());
  
          String result = IoUtil.getText(in);
  
          assertEquals(expected, result);
      }
  
      /**
       * Verify that the <code>getText()</code> method works when the input 
       * stream does not contain any data.
       * 
       * @exception IOException on error
       */
      public void testGetTextEmpty() throws IOException
      {
          ByteArrayInputStream in = new ByteArrayInputStream("".getBytes());
  
          String result = IoUtil.getText(in);
  
          assertEquals("", result);
      }
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/util/TestTestCaseImplementChecker.java
  
  Index: TestTestCaseImplementChecker.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2004 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.cactus.internal.util;
  
  import java.lang.reflect.Method;
  import junit.framework.AssertionFailedError;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import org.apache.cactus.Request;
  import org.apache.cactus.WebResponse;
  
  /**
   * Unit tests for the {@link TestCaseImplementChecker} class.
   *
   * @version $Id: TestTestCaseImplementChecker.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestTestCaseImplementChecker extends TestCase
  {
      /**
       * normal test class for {@link #testCheckTestName}
       */
      class NormalTest extends TestCase
      {
          /**
           * @param theName the name of the test
           */
          public NormalTest(String theName)
          {
              super(theName);
          }
  
          /**
           * dummy test entry
           */
          public void testDummy()
          {
          }
      }
  
      /**
       * illegal test class for {@link #testCheckTestName}
       */
      class NoNameTest extends TestCase
      {
          /**
           * @param theName the name of the test
           */
          public NoNameTest(String theName)
          {
          }
  
          /**
           * dummy test entry
           */
          public void testDummy()
          {
          }
      }
  
      /**
       * declare methods to be used by {@link #testCheckAsBeginMethod} and
       * {@link #testCheckAsEndMethod}
       */
      class MethodHolder
      {
          /**
           */
          public MethodHolder()
          {
          }
          
          // ---- Begin Method ----
          
          /**
           * @param theRequest a Request
           */
          public void beginNormal(Request theRequest)
          {
          }
          
          /**
           * @param theRequest a Request
           * @return a dummy String
           */
          public String beginReturnsString(Request theRequest)
          {
              return "a string";
          }
          
          /**
           * @param theRequest a Request
           */
          protected void beginProtected(Request theRequest)
          {
          }
          
          /**
           * @param theRequest a Request
           */
          private void beginPrivate(Request theRequest)
          {
          }
          
          /**
           */
          public void beginNoParam()
          {
          }
          
          /**
           * @param theRequest a Request
           * @param theObject a Object
           */
          public void beginWithTwoParams(Request theRequest, Object theObject)
          {
          }
          
          /**
           * @param theString a String
           */
          public void beginWithStringParam(String theString)
          {
          }
  
          // ---- End Method ----
          
          /**
           * @param theResponse a WebResponse
           */
          public void endNormal(WebResponse theResponse)
          {
          }
          
          /**
           * @param theResponse a WebResponse
           * @return a dummy String
           */
          public String endReturnsString(WebResponse theResponse)
          {
              return "a string";
          }
          
          /**
           * @param theResponse a WebResponse
           */
          protected void endProtected(WebResponse theResponse)
          {
          }
          
          /**
           * @param theResponse a WebResponse
           */
          private void endPrivate(WebResponse theResponse)
          {
          }
          
          /**
           */
          public void endNoParam()
          {
          }
          
          /**
           * @param theResponse a WebResponse
           * @param theObject a Object
           */
          public void endWithTwoParams(WebResponse theResponse, Object theObject)
          {
          }
          
          /**
           * @param theString a String
           */
          public void endWithStringParam(String theString)
          {
          }
      }
  
      /**
       * @return a "Should not be here" message
       */
      private String shouldNotHere()
      {
          return "shold not be here";
      }
  
      /**
       * @param theThrowable a throwable
       * @return a "Should not be here" message with throwable information
       */
      private String shouldNotHere(Throwable theThrowable)
      {
          return shouldNotHere() + ": " + theThrowable.getClass().getName()
              + "[" + theThrowable.getMessage() + "]";
      }
  
      /**
       * @see {TestCaseImplementChecker#checkTestName(junit.framework.Test)}
       */
      public void testCheckTestName()
      {
          Test test;
          try
          {
              test = new NormalTest("testDummy");
              TestCaseImplementChecker.checkTestName(test);
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          try
          {
              test = new NoNameTest("testDummy");
              TestCaseImplementChecker.checkTestName(test);
              fail(shouldNotHere());
          }
          catch (TestCaseImplementError e)
          {
              assertEquals("No test name found. The test ["
                  + TestTestCaseImplementChecker.NoNameTest.class.getName() 
                  + "] is not properly implemented.", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
      }
  
      /**
       * @see {TestCaseImplementChecker#checkAsBeginMethod}
       */
      public void testCheckAsBeginMethod()
      {
          //--------------------------------------------------------------------
          
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "beginNormal", new Class[]{Request.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "beginReturnsString", new Class[]{Request.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginReturnsString] "
                  + "should return void and not [java.lang.String]",
                  e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getDeclaredMethod(
                  "beginProtected", new Class[]{Request.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginProtected] "
                  + "should be declared public", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getDeclaredMethod(
                  "beginPrivate", new Class[]{Request.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginPrivate] "
                  + "should be declared public", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "beginNoParam", new Class[]{});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginNoParam] must have 1 parameter(s), "
                  + "but 0 parameter(s) were found", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "beginWithTwoParams",
                  new Class[]{Request.class, Object.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginWithTwoParams] "
                  + "must have 1 parameter(s), "
                  + "but 2 parameter(s) were found", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "beginWithStringParam", new Class[]{String.class});
              TestCaseImplementChecker.checkAsBeginMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [beginWithStringParam] "
                  + "must accept [org.apache.cactus.Request] "
                  + "as 1st parameter, but found a "
                  + "[java.lang.String] parameter instead",
                  e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
      }
  
  
      /**
       * @see {TestCaseImplementChecker#checkAsEndMethod
       *       (java.lang.reflect.Method)}
       */
      public void testCheckAsEndMethod()
      {
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "endNormal", new Class[]{WebResponse.class});
              TestCaseImplementChecker.checkAsEndMethod(method);
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "endReturnsString", new Class[]{WebResponse.class});
              TestCaseImplementChecker.checkAsEndMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [endReturnsString] "
                  + "should return void and not [java.lang.String]",
                  e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getDeclaredMethod(
                  "endProtected", new Class[]{WebResponse.class});
              TestCaseImplementChecker.checkAsEndMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [endProtected] "
                  + "should be declared public", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getDeclaredMethod(
                  "endPrivate", new Class[]{WebResponse.class});
              TestCaseImplementChecker.checkAsEndMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [endPrivate] "
                  + "should be declared public", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "endNoParam", new Class[]{});
              TestCaseImplementChecker.checkAsEndMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [endNoParam] must have 1 parameter(s), "
                  + "but 0 parameter(s) were found", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
  
          //---------------------------------------------------------------------
  
          try
          {
              Method method = MethodHolder.class.getMethod(
                  "endWithTwoParams",
                  new Class[]{WebResponse.class, Object.class});
              TestCaseImplementChecker.checkAsEndMethod(method);
              fail(shouldNotHere());
          }
          catch (AssertionFailedError e)
          {
              assertEquals("The method [endWithTwoParams] "
                  + "must have 1 parameter(s), "
                  + "but 2 parameter(s) were found", e.getMessage());
          }
          catch (Throwable t)
          {
              fail(shouldNotHere(t));
          }
      }
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/util/TestCookieUtil.java
  
  Index: TestCookieUtil.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal.util;
  
  import java.net.URL;
  
  import org.apache.cactus.Cookie;
  import org.apache.cactus.WebRequest;
  import org.apache.cactus.internal.WebRequestImpl;
  import org.apache.commons.httpclient.HttpState;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests for the {@link CookieUtil} class.
   *
   * @version $Id: TestCookieUtil.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestCookieUtil extends TestCase
  {
      /**
       * Verify that an HttpClient HttpState object can be created when
       * no Cactus cookies have been defined.
       * 
       * @exception Exception on error
       */
      public void testCreateHttpStateWhenNoCactusCookieDefined()
          throws Exception
      {
          WebRequest request = new WebRequestImpl();
          HttpState state = new HttpState(); 
          state.addCookies(CookieUtil.createHttpClientCookies(request, 
              new URL("http://jakarta.apache.org")));
          assertEquals(0, state.getCookies().length);
      }
  
      /**
       * Verify that an HttpClient HttpState object can be created when
       * several Cactus cookies exist.
       * 
       * @exception Exception on error
       */
      public void testCreateHttpStateWhenSeveralCactusCookieExist()
          throws Exception
      {
          WebRequest request = new WebRequestImpl();
          request.addCookie(new Cookie("domain1", "name1", "value1"));
          request.addCookie(new Cookie("domain2", "name2", "value2"));
          
          HttpState state = new HttpState(); 
          state.addCookies(CookieUtil.createHttpClientCookies(request, 
              new URL("http://jakarta.apache.org")));
  
          assertEquals(2, state.getCookies().length);
      }
  
  }
  
  
  
  1.22      +23 -7     jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAll.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TestAll.java	10 Apr 2004 14:59:59 -0000	1.21
  +++ TestAll.java	10 Apr 2004 18:18:58 -0000	1.22
  @@ -19,8 +19,17 @@
    */
   package org.apache.cactus;
   
  +import org.apache.cactus.internal.TestAbstractCactusTestCase;
  +import org.apache.cactus.internal.TestWebTestResult;
  +import org.apache.cactus.internal.client.TestWebTestResultParser;
   import org.apache.cactus.internal.configuration.ConfigurationInitializer;
  -import org.apache.cactus.server.runner.TestXMLFormatter;
  +import org.apache.cactus.internal.server.TestServletUtil;
  +import org.apache.cactus.internal.server.runner.TestXMLFormatter;
  +import org.apache.cactus.internal.util.TestCookieUtil;
  +import org.apache.cactus.internal.util.TestIoUtil;
  +import org.apache.cactus.internal.util.TestStringUtil;
  +import org.apache.cactus.internal.util.TestTestCaseImplementChecker;
  +import org.apache.cactus.internal.util.TestUniqueGenerator;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -49,17 +58,24 @@
           // tests.
           ConfigurationInitializer.initialize();
           
  -        suite.addTestSuite(TestAbstractTestCase.class);
           suite.addTestSuite(TestNoNameTestCase.class);
           suite.addTestSuite(TestServletURL.class);
  -        suite.addTestSuite(TestServletUtil.class);
  -        suite.addTestSuite(TestWebTestResult.class);
           suite.addTestSuite(TestWebRequest.class);
   
  -        suite.addTest(org.apache.cactus.internal.client.TestAll.suite());
  -        suite.addTest(org.apache.cactus.util.TestAll.suite());
  +        suite.addTestSuite(TestAbstractCactusTestCase.class);
  +        suite.addTestSuite(TestWebTestResult.class);
  +
  +        suite.addTestSuite(TestWebTestResultParser.class);
  +                
  +        suite.addTestSuite(TestServletUtil.class);
   
           suite.addTestSuite(TestXMLFormatter.class);
  +
  +        suite.addTestSuite(TestCookieUtil.class);
  +        suite.addTestSuite(TestIoUtil.class);
  +        suite.addTestSuite(TestStringUtil.class);
  +        suite.addTestSuite(TestTestCaseImplementChecker.class);
  +        suite.addTestSuite(TestUniqueGenerator.class);
           
           return suite;
       }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/server/TestServletUtil.java
  
  Index: TestServletUtil.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2001-2004 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.cactus.internal.server;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests of the {@link ServletUtil} class.
   *
   * @version $Id: TestServletUtil.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public class TestServletUtil extends TestCase
  {
      /**
       * Verify than <code>getQueryStringParameterEmpty()</code> returns an
       * empty string if the parameter existe but has no value defined.
       */
      public void testGetQueryStringParameterEmpty()
      {
          String queryString = "param1=&param2=value2";
          String result = ServletUtil.getQueryStringParameter(queryString, 
              "param1");
  
          assertEquals("", result);
      }
  }
  
  
  
  1.1                  jakarta-cactus/framework/src/test/share/org/apache/cactus/internal/server/runner/TestXMLFormatter.java
  
  Index: TestXMLFormatter.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2004 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.cactus.internal.server.runner;
  
  import junit.framework.TestCase;
  import junit.framework.TestResult;
  
  /**
   * Unit tests for {@link XMLFormatter}.
   *
   * @version $Id: TestXMLFormatter.java,v 1.1 2004/04/10 18:18:58 vmassol Exp $
   */
  public final class TestXMLFormatter extends TestCase
  {   
      /**
       * Instance to unit test 
       */
      private XMLFormatter formatter;
     
      /**
       * TestResult object used for testing
       */
      private TestResult testResult;
      
      /**
       * Set up common mock behaviors.
       */
      public void setUp()
      {
          formatter = new XMLFormatter();
          testResult = new TestResult();
      }
  
      /**
       * Verify that calling {@link XMLFormatter#toXML(TestResult)} works
       * when using the default encoding. 
       */
      public void testToXmlEmptyWithDefaultEncoding()
      {
          String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
              + "<testsuites><testsuite name=\"null\" tests=\"0\" failures=\"0\""
              + " errors=\"0\" time=\"0\"></testsuite></testsuites>";
          
          String result = formatter.toXML(testResult);
          assertEquals(expected, result);
      }
  
      /**
       * Verify that calling {@link XMLFormatter#toXML(TestResult)} works
       * when using a custom encoding of ISO-8859-1. 
       */
      public void testToXmlEmptyWithCustomEncoding()
      {
          String expected = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
          + "<testsuites><testsuite name=\"null\" tests=\"0\" failures=\"0\""
          + " errors=\"0\" time=\"0\"></testsuite></testsuites>";
          
          formatter.setEncoding("ISO-8859-1");
          String result = formatter.toXML(testResult);
          assertEquals(expected, result);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org