PageRenderTime 86ms CodeModel.GetById 73ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/jain-mgcp/stack/src/test/java/org/mobicents/protocols/mgcp/stack/test/auditendpoint/CA.java

http://mobicents.googlecode.com/
Java | 109 lines | 61 code | 27 blank | 21 comment | 1 complexity | 5f7c7dd40bc859aba34a4fc553f52a48 MD5 | raw file
  1/*
  2 * JBoss, Home of Professional Open Source
  3 * Copyright 2011, Red Hat, Inc. and individual contributors
  4 * by the @authors tag. See the copyright.txt in the distribution for a
  5 * full listing of individual contributors.
  6 *
  7 * This is free software; you can redistribute it and/or modify it
  8 * under the terms of the GNU Lesser General Public License as
  9 * published by the Free Software Foundation; either version 2.1 of
 10 * the License, or (at your option) any later version.
 11 *
 12 * This software is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 15 * Lesser General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU Lesser General Public
 18 * License along with this software; if not, write to the Free
 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 21 */
 22
 23package org.mobicents.protocols.mgcp.stack.test.auditendpoint;
 24
 25import jain.protocol.ip.mgcp.JainMgcpCommandEvent;
 26import jain.protocol.ip.mgcp.JainMgcpEvent;
 27import jain.protocol.ip.mgcp.JainMgcpResponseEvent;
 28import jain.protocol.ip.mgcp.message.AuditEndpoint;
 29import jain.protocol.ip.mgcp.message.Constants;
 30import jain.protocol.ip.mgcp.message.parms.EndpointIdentifier;
 31import jain.protocol.ip.mgcp.message.parms.InfoCode;
 32
 33import org.apache.log4j.Logger;
 34import org.mobicents.protocols.mgcp.stack.JainMgcpExtendedListener;
 35import org.mobicents.protocols.mgcp.stack.JainMgcpStackProviderImpl;
 36
 37public class CA implements JainMgcpExtendedListener {
 38
 39	private static Logger logger = Logger.getLogger(CA.class);
 40
 41	private JainMgcpStackProviderImpl caProvider;
 42	private int mgStack = 0;
 43	private boolean responseReceived = false;
 44
 45	public CA(JainMgcpStackProviderImpl caProvider, JainMgcpStackProviderImpl mgwProvider) {
 46		this.caProvider = caProvider;
 47		mgStack = mgwProvider.getJainMgcpStack().getPort();
 48	}
 49
 50	public void sendAuditEndpoint() {
 51
 52		try {
 53			caProvider.addJainMgcpListener(this);
 54
 55			EndpointIdentifier endpointID = new EndpointIdentifier("media/trunk/Announcement/enp-1", "127.0.0.1:"
 56					+ mgStack);
 57			
 58			AuditEndpoint auditEndpoint = new AuditEndpoint(this, endpointID, new InfoCode[]{InfoCode.Capabilities});
 59
 60			auditEndpoint.setTransactionHandle(caProvider.getUniqueTransactionHandler());
 61
 62			caProvider.sendMgcpEvents(new JainMgcpEvent[] { auditEndpoint });
 63
 64			logger.debug(" AuditEndpoint command sent for TxId " + auditEndpoint.getTransactionHandle());
 65		} catch (Exception e) {			
 66			e.printStackTrace();
 67			AuditEndpointTest.fail("Unexpected Exception");
 68		}
 69	}
 70
 71	public void checkState() {
 72		AuditEndpointTest.assertTrue("Expect to receive AUEP Response", responseReceived);
 73
 74	}
 75
 76	public void transactionEnded(int handle) {
 77		logger.info("transactionEnded " + handle);
 78
 79	}
 80
 81	public void transactionRxTimedOut(JainMgcpCommandEvent command) {
 82		logger.info("transactionRxTimedOut " + command);
 83
 84	}
 85
 86	public void transactionTxTimedOut(JainMgcpCommandEvent command) {
 87		logger.info("transactionTxTimedOut " + command);
 88
 89	}
 90
 91	public void processMgcpCommandEvent(JainMgcpCommandEvent jainmgcpcommandevent) {
 92		logger.info("processMgcpCommandEvent " + jainmgcpcommandevent);
 93	}
 94
 95	public void processMgcpResponseEvent(JainMgcpResponseEvent jainmgcpresponseevent) {
 96		logger.debug("processMgcpResponseEvent = " + jainmgcpresponseevent);
 97		switch (jainmgcpresponseevent.getObjectIdentifier()) {
 98		case Constants.RESP_AUDIT_ENDPOINT :
 99			responseReceived = true;
100			break;
101		default:
102			logger.warn("This RESPONSE is unexpected " + jainmgcpresponseevent);
103			break;
104
105		}
106
107	}
108
109}