All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.tck.msgflow.callflows.prack.AbstractPrackTestCase Maven / Gradle / Ivy

package test.tck.msgflow.callflows.prack;

import javax.sip.SipListener;
import javax.sip.SipProvider;

import org.apache.log4j.Appender;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;

import test.tck.msgflow.callflows.ScenarioHarness;

/**
 * 
 * Implements common setup and tearDown sequence for PRACK tests 
 * 
 * @author M. Ranganathan
 * @author Ivelin Ivanov
 * 
 */
public abstract class AbstractPrackTestCase extends ScenarioHarness implements
		SipListener {

	
	protected Shootist shootist;

	protected Shootme shootme;

	private static Logger logger = Logger.getLogger("test.tck");

	static {
		if (!logger.isAttached(console)) {
			logger.addAppender(console);
		}
	}

	public AbstractPrackTestCase() {
		super("prack", true);
	}

	public void setUp() throws Exception {
		try {
			super.setUp();

			logger.info("PrackTest: setup()");
			shootist = new Shootist(tiProtocolObjects);
			SipProvider shootistProvider = shootist.createProvider();
			providerTable.put(shootistProvider, shootist);

			shootme = new Shootme(riProtocolObjects);
			SipProvider shootmeProvider = shootme.createProvider();
			providerTable.put(shootmeProvider, shootme);

			shootistProvider.addSipListener(this);
			shootmeProvider.addSipListener(this);

			if (tiProtocolObjects != riProtocolObjects)
				tiProtocolObjects.start();
			riProtocolObjects.start();
		} catch (Exception ex) {
			logger.error("unexpected excecption ", ex);
			fail("unexpected exception");
		}
	}

	public void tearDown() throws Exception {
		try {
			Thread.sleep(2000);
			this.shootist.checkState();
			this.shootme.checkState();
			tiProtocolObjects.destroy();
			if (riProtocolObjects != tiProtocolObjects)
				riProtocolObjects.destroy();
			Thread.sleep(1000);
			this.providerTable.clear();
			
			logTestCompleted();
		} catch (Exception ex) {
			logger.error("unexpected exception", ex);
			fail("unexpected exception ");
		}
		super.tearDown();
	}
	
	

	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy