1 16 17 package com.j2biz.pencil.test.output; 18 19 import java.io.FileInputStream ; 20 import java.io.FileOutputStream ; 21 import java.io.PrintStream ; 22 import java.util.Properties ; 23 24 import junit.framework.TestCase; 25 26 import com.j2biz.pencil.test.stuff.TestCastingCallerClass; 27 import com.j2biz.pencil.test.stuff.TestCastingInstance2; 28 import com.j2biz.pencil.test.stuff.TestCastingInstance3; 29 30 31 37 public class CastingTestCase extends TestCase { 38 39 public void testCasting() throws Exception { 40 PrintStream oldOut = System.err; 41 FileOutputStream dropedOut = new FileOutputStream ( "testCascadingVars.out" ); 42 PrintStream newOut = new PrintStream (dropedOut); 43 System.setErr( newOut ); 44 45 TestCastingCallerClass myVar = new TestCastingCallerClass(); 46 47 System.setErr(oldOut); 48 newOut.flush(); 49 newOut.close(); 50 51 Properties props = new Properties (); 52 props.load(new FileInputStream ("testCascadingVars.out")); 53 54 assertEquals( props.getProperty( "parent.class.public.instance" ), ((TestCastingInstance2) myVar.testVar).field3 ); 55 assertEquals(props.getProperty( "parent.interface.public.instance" ), ((TestCastingInstance3) myVar.testVar).field1 ); 56 } 57 } 58 | Popular Tags |