001: /*
002: * Conditions Of Use
003: *
004: * This software was developed by employees of the National Institute of
005: * Standards and Technology (NIST), and others.
006: * This software is has been contributed to the public domain.
007: * As a result, a formal license is not needed to use the software.
008: *
009: * This software is provided "AS IS."
010: * NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
011: * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
012: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
013: * AND DATA ACCURACY. NIST does not warrant or make any representations
014: * regarding the use of the software or the results thereof, including but
015: * not limited to the correctness, accuracy, reliability or usefulness of
016: * the software.
017: *
018: *
019: */
020: package test.tck.msgflow.callflows.subsnotify;
021:
022: import javax.sip.SipListener;
023: import javax.sip.SipProvider;
024:
025: import org.apache.log4j.Appender;
026: import org.apache.log4j.ConsoleAppender;
027: import org.apache.log4j.Logger;
028: import org.apache.log4j.SimpleLayout;
029:
030: import test.tck.msgflow.callflows.ScenarioHarness;
031:
032: /**
033: *
034: * Implements common setup and tearDown sequence for Subsnotify tests
035: *
036: *
037: * @author M. Ranganathan
038: * @author Ivelin Ivanov
039: *
040: */
041: public abstract class AbstractSubsnotifyTestCase extends
042: ScenarioHarness implements SipListener {
043:
044: protected Notifier notifier1;
045:
046: protected Subscriber subscriber;
047:
048: private Notifier notifier2;
049:
050: protected Forker forker;
051:
052: private static Logger logger = Logger.getLogger("test.tck");
053:
054: static {
055: if (!logger.isAttached(console)) {
056:
057: logger.addAppender(console);
058:
059: }
060: }
061:
062: public AbstractSubsnotifyTestCase() {
063: super ("subsnotify", true);
064: }
065:
066: public void setUp() throws Exception {
067: try {
068: super .setUp();
069:
070: logger.info("SubsNotifyTest: setup()");
071:
072: notifier1 = new Notifier(tiProtocolObjects);
073: SipProvider notifier1Provider = notifier1
074: .createProvider(5070);
075: providerTable.put(notifier1Provider, notifier1);
076:
077: notifier2 = new Notifier(tiProtocolObjects);
078: SipProvider notifier2Provider = notifier2
079: .createProvider(5071);
080: providerTable.put(notifier2Provider, notifier2);
081:
082: forker = new Forker(riProtocolObjects);
083: SipProvider forkerProvider = forker.createProvider(5065);
084: providerTable.put(forkerProvider, forker);
085:
086: subscriber = new Subscriber(tiProtocolObjects);
087: SipProvider subscriberProvider = subscriber
088: .createProvider(5080);
089: providerTable.put(subscriberProvider, subscriber);
090:
091: notifier1Provider.addSipListener(this );
092: notifier2Provider.addSipListener(this );
093: forkerProvider.addSipListener(this );
094: subscriberProvider.addSipListener(this );
095:
096: if (tiProtocolObjects != riProtocolObjects)
097: tiProtocolObjects.start();
098: riProtocolObjects.start();
099: } catch (Exception ex) {
100: logger.error("unexpected excecption ", ex);
101: fail("unexpected exception");
102: }
103: }
104:
105: public void tearDown() throws Exception {
106: try {
107: Thread.sleep(5000);
108: tiProtocolObjects.destroy();
109: if (riProtocolObjects != tiProtocolObjects)
110: riProtocolObjects.destroy();
111: this .providerTable.clear();
112: Thread.sleep(100);
113: subscriber.checkState();
114: notifier1.checkState();
115: notifier2.checkState();
116: logTestCompleted();
117: } catch (Exception ex) {
118: logger.error("unexpected exception", ex);
119: fail("unexpected exception ");
120: }
121: super.tearDown();
122: }
123:
124: }
|