1 16 17 package org.apache.sandesha; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.Message; 21 import org.apache.axis.MessageContext; 22 import org.apache.axis.message.SOAPEnvelope; 23 24 import java.io.File ; 25 import java.io.FileInputStream ; 26 27 30 public abstract class AbstractTestCase 31 extends TestCase { 32 protected String testDir = "test"; 33 protected String testResourceDir = "test-resources"; 37 38 39 43 public String basedir = System.getProperty("basedir"); 44 45 48 public AbstractTestCase(String testName) { 49 super(testName); 50 if (basedir == null) { 51 basedir = new File (".").getAbsolutePath(); 52 } 53 testDir = new File (basedir, testDir).getAbsolutePath(); 54 testResourceDir = new File (basedir, testResourceDir).getAbsolutePath(); 58 } 59 60 61 public File getTestResourceFile(String relativePath) { 62 return new File (testResourceDir, relativePath); 63 } 64 65 public RMMessageContext getRMMessageContext(String relativePath) throws Exception { 66 67 FileInputStream fin = new FileInputStream (getTestResourceFile(relativePath)); 68 SOAPEnvelope sEnv = new SOAPEnvelope(fin); 69 MessageContext msgCtx = new MessageContext(null); 70 msgCtx.setRequestMessage(new Message(sEnv)); 71 msgCtx.setResponseMessage(new Message(new SOAPEnvelope())); 72 RMMessageContext rmMsgCtx = new RMMessageContext(); 73 rmMsgCtx.setMsgContext(msgCtx); 74 return rmMsgCtx; 75 } 76 77 78 } 79 80 | Popular Tags |