001: package test.tck.msgflow.callflows.refer;
002:
003: import java.util.EventObject;
004: import java.util.Hashtable;
005: import java.util.Timer;
006: import java.util.TimerTask;
007:
008: import javax.sip.DialogTerminatedEvent;
009: import javax.sip.IOExceptionEvent;
010: import javax.sip.RequestEvent;
011: import javax.sip.ResponseEvent;
012: import javax.sip.SipListener;
013: import javax.sip.SipProvider;
014: import javax.sip.TimeoutEvent;
015: import javax.sip.TransactionTerminatedEvent;
016:
017: import org.apache.log4j.Appender;
018: import org.apache.log4j.ConsoleAppender;
019: import org.apache.log4j.FileAppender;
020: import org.apache.log4j.Logger;
021: import org.apache.log4j.PropertyConfigurator;
022: import org.apache.log4j.SimpleLayout;
023: import org.apache.log4j.helpers.NullEnumeration;
024:
025: import test.tck.msgflow.callflows.ProtocolObjects;
026: import test.tck.msgflow.callflows.ScenarioHarness;
027:
028: import junit.framework.TestCase;
029:
030: /**
031: *
032: * Implements common setup and tearDown sequence for Refer tests
033: *
034: * @author M. Ranganathan
035: * @author Ivelin Ivanov
036: *
037: */
038: public abstract class AbstractReferTestCase extends ScenarioHarness
039: implements SipListener {
040:
041: protected Referee referee;
042:
043: protected Referrer referrer;
044:
045: private static Logger logger = Logger.getLogger("test.tck");
046:
047: static {
048: if (!logger.isAttached(console)) {
049:
050: logger.addAppender(console);
051:
052: }
053: }
054:
055: public AbstractReferTestCase() {
056: super ("refer", true);
057: }
058:
059: public void setUp() throws Exception {
060: try {
061: super .setUp();
062:
063: logger.info("ReferTest: setup()");
064: referee = new Referee(tiProtocolObjects);
065: SipProvider refereeProvider = referee.createProvider();
066: providerTable.put(refereeProvider, referee);
067:
068: referrer = new Referrer(riProtocolObjects);
069: SipProvider referrerProvider = referrer.createProvider();
070: providerTable.put(referrerProvider, referrer);
071:
072: refereeProvider.addSipListener(this );
073: referrerProvider.addSipListener(this );
074:
075: if (tiProtocolObjects != riProtocolObjects)
076: tiProtocolObjects.start();
077: riProtocolObjects.start();
078: } catch (Exception ex) {
079: logger.error("unexpected excecption ", ex);
080: fail("unexpected exception");
081: }
082: }
083:
084: public void tearDown() throws Exception {
085: try {
086: Thread.sleep(2000);
087: tiProtocolObjects.destroy();
088: if (riProtocolObjects != tiProtocolObjects)
089: riProtocolObjects.destroy();
090: Thread.sleep(1000);
091: this .providerTable.clear();
092:
093: logTestCompleted();
094: } catch (Exception ex) {
095: logger.error("unexpected exception", ex);
096: fail("unexpected exception ");
097: }
098: super.tearDown();
099: }
100:
101: }
|