1 package hudson.remoting; 2 3 import junit.framework.TestCase; 4 import junit.framework.Test; 5 import junit.framework.TestSuite; 6 7 import java.io.IOException ; 8 import java.io.PipedInputStream ; 9 import java.io.PipedOutputStream ; 10 import java.util.concurrent.ExecutorService ; 11 import java.util.concurrent.Executors ; 12 13 import hudson.remoting.ChannelRunner.InProcess; 14 15 20 public abstract class RmiTestBase extends TestCase { 21 22 protected Channel channel; 23 private ChannelRunner channelRunner = new InProcess(); 24 25 protected void setUp() throws Exception { 26 channel = channelRunner.start(); 27 } 28 29 protected void tearDown() throws Exception { 30 channelRunner.stop(channel); 31 } 32 33 void setChannelRunner(Class <? extends ChannelRunner> runner) { 34 try { 35 this.channelRunner = runner.newInstance(); 36 } catch (InstantiationException e) { 37 throw new Error (e); 38 } catch (IllegalAccessException e) { 39 throw new Error (e); 40 } 41 } 42 43 public String getName() { 44 return super.getName()+"-"+channelRunner.getName(); 45 } 46 47 52 protected static Test buildSuite(Class <? extends RmiTestBase> testClass) { 53 TestSuite suite = new TestSuite(); 54 for( Class <? extends ChannelRunner> r : ChannelRunner.LIST ) { 55 suite.addTest(new ChannelTestSuite(testClass,r)); 56 } 57 return suite; 58 } 59 } 60 | Popular Tags |