1 17 package org.apache.geronimo.common; 18 19 import java.io.ByteArrayOutputStream ; 20 import java.io.PrintStream ; 21 22 import junit.framework.TestCase; 23 24 27 public class DeploymentExceptionTest extends TestCase { 28 29 public void testCleanse() throws Exception { 30 DeploymentException exception = new DeploymentException("message"); 31 IllegalArgumentException nested1 = new IllegalArgumentException ("nested1"); 32 exception.initCause(nested1); 33 IllegalStateException nested2 = new IllegalStateException ("nested2"); 34 nested1.initCause(nested2); 35 36 ByteArrayOutputStream expected = new ByteArrayOutputStream (); 37 exception.printStackTrace(new PrintStream (expected)); 38 39 ByteArrayOutputStream result = new ByteArrayOutputStream (); 40 DeploymentException newEx = exception.cleanse(); 41 newEx.printStackTrace(new PrintStream (result)); 42 43 byte[] expectedBytes = expected.toByteArray(); 44 byte[] resultBytes = result.toByteArray(); 45 assertEquals(expectedBytes.length, resultBytes.length); 46 for (int i = 0; i < expectedBytes.length; i++) { 47 assertEquals(expectedBytes[i], resultBytes[i]); 48 } 49 } 50 } 51 | Popular Tags |