001: /**
002: *
003: */package test.tck.msgflow.callflows.forkedinvite;
004:
005: import gov.nist.javax.sip.SipProviderImpl;
006:
007: import java.util.EventObject;
008: import java.util.Hashtable;
009: import java.util.Timer;
010: import java.util.TimerTask;
011:
012: import javax.sip.DialogTerminatedEvent;
013: import javax.sip.IOExceptionEvent;
014: import javax.sip.RequestEvent;
015: import javax.sip.ResponseEvent;
016: import javax.sip.SipListener;
017: import javax.sip.SipProvider;
018: import javax.sip.TimeoutEvent;
019: import javax.sip.TransactionTerminatedEvent;
020:
021: import org.apache.log4j.Appender;
022: import org.apache.log4j.ConsoleAppender;
023: import org.apache.log4j.FileAppender;
024: import org.apache.log4j.Logger;
025: import org.apache.log4j.PropertyConfigurator;
026: import org.apache.log4j.SimpleLayout;
027: import org.apache.log4j.helpers.NullEnumeration;
028:
029: import test.tck.msgflow.callflows.ProtocolObjects;
030: import test.tck.msgflow.callflows.ScenarioHarness;
031:
032: import junit.framework.TestCase;
033:
034: /**
035: * @author M. Ranganathan
036: *
037: */
038: public class AbstractForkedInviteTestCase extends ScenarioHarness
039: implements SipListener {
040:
041: protected Shootist shootist;
042:
043: private static Logger logger = Logger.getLogger("test.tck");
044:
045: protected Shootme shootme;
046:
047: private Shootme shootme2;
048:
049: static {
050: if (!logger.isAttached(console))
051: logger.addAppender(console);
052: }
053:
054: // private Appender appender;
055:
056: public AbstractForkedInviteTestCase() {
057:
058: super ("forkedInviteTest", true);
059:
060: try {
061: providerTable = new Hashtable();
062:
063: } catch (Exception ex) {
064: logger.error("unexpected exception", ex);
065: fail("unexpected exception ");
066: }
067: }
068:
069: public void setUp() {
070:
071: try {
072: super .setUp(false);
073: shootist = new Shootist(5060, 5070, tiProtocolObjects);
074: SipProvider shootistProvider = shootist.createSipProvider();
075: providerTable.put(shootistProvider, shootist);
076:
077: this .shootme = new Shootme(5080, tiProtocolObjects);
078: SipProvider shootmeProvider = shootme.createProvider();
079: providerTable.put(shootmeProvider, shootme);
080: shootistProvider.addSipListener(this );
081: shootmeProvider.addSipListener(this );
082:
083: this .shootme2 = new Shootme(5090, tiProtocolObjects);
084: shootmeProvider = shootme2.createProvider();
085: providerTable.put(shootmeProvider, shootme2);
086: shootistProvider.addSipListener(this );
087: shootmeProvider.addSipListener(this );
088:
089: Proxy proxy = new Proxy(5070, riProtocolObjects);
090: SipProvider provider = proxy.createSipProvider();
091: provider.setAutomaticDialogSupportEnabled(false);
092: providerTable.put(provider, proxy);
093: provider.addSipListener(this );
094:
095: tiProtocolObjects.start();
096: if (tiProtocolObjects != riProtocolObjects)
097: riProtocolObjects.start();
098: } catch (Exception ex) {
099: fail("unexpected exception ");
100: }
101: }
102:
103: public void tearDown() {
104: try {
105: Thread.sleep(4000);
106: this .shootist.checkState();
107: this .shootme.checkState();
108: this .shootme2.checkState();
109: tiProtocolObjects.destroy();
110: if (riProtocolObjects != tiProtocolObjects)
111: riProtocolObjects.destroy();
112: Thread.sleep(2000);
113: this .providerTable.clear();
114:
115: super .logTestCompleted();
116: } catch (Exception ex) {
117: logger.error("unexpected exception", ex);
118: fail("unexpected exception ");
119: }
120: }
121:
122: }
|