01: package test.tck.msgflow.callflows.prack;
02:
03: import javax.sip.SipListener;
04: import javax.sip.SipProvider;
05:
06: import org.apache.log4j.Appender;
07: import org.apache.log4j.ConsoleAppender;
08: import org.apache.log4j.Logger;
09: import org.apache.log4j.SimpleLayout;
10:
11: import test.tck.msgflow.callflows.ScenarioHarness;
12:
13: /**
14: *
15: * Implements common setup and tearDown sequence for PRACK tests
16: *
17: * @author M. Ranganathan
18: * @author Ivelin Ivanov
19: *
20: */
21: public abstract class AbstractPrackTestCase extends ScenarioHarness
22: implements SipListener {
23:
24: protected Shootist shootist;
25:
26: protected Shootme shootme;
27:
28: private static Logger logger = Logger.getLogger("test.tck");
29:
30: static {
31: if (!logger.isAttached(console)) {
32: logger.addAppender(console);
33: }
34: }
35:
36: public AbstractPrackTestCase() {
37: super ("prack", true);
38: }
39:
40: public void setUp() throws Exception {
41: try {
42: super .setUp();
43:
44: logger.info("PrackTest: setup()");
45: shootist = new Shootist(tiProtocolObjects);
46: SipProvider shootistProvider = shootist.createProvider();
47: providerTable.put(shootistProvider, shootist);
48:
49: shootme = new Shootme(riProtocolObjects);
50: SipProvider shootmeProvider = shootme.createProvider();
51: providerTable.put(shootmeProvider, shootme);
52:
53: shootistProvider.addSipListener(this );
54: shootmeProvider.addSipListener(this );
55:
56: if (tiProtocolObjects != riProtocolObjects)
57: tiProtocolObjects.start();
58: riProtocolObjects.start();
59: } catch (Exception ex) {
60: logger.error("unexpected excecption ", ex);
61: fail("unexpected exception");
62: }
63: }
64:
65: public void tearDown() throws Exception {
66: try {
67: Thread.sleep(2000);
68: this .shootist.checkState();
69: this .shootme.checkState();
70: tiProtocolObjects.destroy();
71: if (riProtocolObjects != tiProtocolObjects)
72: riProtocolObjects.destroy();
73: Thread.sleep(1000);
74: this .providerTable.clear();
75:
76: logTestCompleted();
77: } catch (Exception ex) {
78: logger.error("unexpected exception", ex);
79: fail("unexpected exception ");
80: }
81: super.tearDown();
82: }
83:
84: }
|