PageRenderTime 31ms CodeModel.GetById 13ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

/protocols/ss7/map/load/src/main/java/org/mobicents/protocols/ss7/map/load/TestHarness.java

http://mobicents.googlecode.com/
Java | 123 lines | 68 code | 25 blank | 30 comment | 2 complexity | 60c60bcfb75707279b26860d75c7bc43 MD5 | raw file
  1/*
  2 * JBoss, Home of Professional Open Source
  3 * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
  4 * contributors as indicated by the @authors tag. All rights reserved.
  5 * See the copyright.txt in the distribution for a full listing
  6 * of individual contributors.
  7 * 
  8 * This copyrighted material is made available to anyone wishing to use,
  9 * modify, copy, or redistribute it subject to the terms and conditions
 10 * of the GNU General Public License, v. 2.0.
 11 * 
 12 * This program 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 * General Public License for more details.
 16 * 
 17 * You should have received a copy of the GNU General Public License,
 18 * v. 2.0 along with this distribution; if not, write to the Free 
 19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 20 * MA 02110-1301, USA.
 21 */
 22package org.mobicents.protocols.ss7.map.load;
 23
 24import java.io.FileNotFoundException;
 25import java.io.IOException;
 26import java.io.InputStream;
 27import java.util.Properties;
 28
 29import org.apache.log4j.BasicConfigurator;
 30import org.apache.log4j.FileAppender;
 31import org.apache.log4j.Logger;
 32import org.apache.log4j.PropertyConfigurator;
 33import org.apache.log4j.SimpleLayout;
 34import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
 35import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl;
 36import org.mobicents.protocols.ss7.map.api.MAPDialogListener;
 37import org.mobicents.protocols.ss7.map.api.service.supplementary.MAPServiceSupplementaryListener;
 38import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
 39
 40/**
 41 * @author abhayani
 42 * 
 43 */
 44public abstract class TestHarness implements MAPDialogListener, MAPServiceSupplementaryListener  {
 45
 46	private static final Logger logger = Logger.getLogger("map.test");
 47
 48	protected static final String LOG_FILE_NAME = "log.file.name";
 49	protected static String logFileName = "maplog.txt";
 50
 51	protected static int NDIALOGS = 50000;
 52
 53	protected static int MAXCONCURRENTDIALOGS = 15;
 54
 55	// MTP Details
 56	protected final int CLIENT_SPC = 1;
 57	protected final int SERVET_SPC = 2;
 58	protected final int NETWORK_INDICATOR = 2;
 59	protected final int SERVICE_INIDCATOR = 3; //SCCP
 60	protected final int SSN = 8;
 61
 62	// M3UA details
 63	//protected final String CLIENT_IP = "172.31.96.40";
 64	protected final String CLIENT_IP = "127.0.0.1";
 65	protected final int CLIENT_PORT = 2345;
 66
 67	//protected final String SERVER_IP = "172.31.96.41";
 68	protected final String SERVER_IP = "127.0.0.1";
 69	protected final int SERVER_PORT = 3434;
 70
 71	protected final int ROUTING_CONTEXT = 100;
 72	
 73	protected final String SERVER_ASSOCIATION_NAME = "serverAsscoiation";
 74	protected final String CLIENT_ASSOCIATION_NAME = "clientAsscoiation";
 75	
 76	protected final String SERVER_NAME = "testserver";
 77	
 78	protected final SccpAddress SCCP_CLIENT_ADDRESS = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, CLIENT_SPC, null, SSN);
 79	protected final SccpAddress SCCP_SERVER_ADDRESS = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, SERVET_SPC, null, SSN);
 80	
 81	protected final ParameterFactoryImpl factory = new ParameterFactoryImpl();
 82
 83	protected TestHarness() {
 84		init();
 85	}
 86
 87	public void init() {
 88		try {
 89			Properties tckProperties = new Properties();
 90
 91			InputStream inStreamLog4j = TestHarness.class.getResourceAsStream("/log4j.properties");
 92			
 93			System.out.println("Input Stream = " + inStreamLog4j);
 94			
 95			Properties propertiesLog4j = new Properties();
 96			try {
 97				propertiesLog4j.load(inStreamLog4j);
 98				PropertyConfigurator.configure(propertiesLog4j);
 99			} catch (IOException e) {
100				e.printStackTrace();
101				BasicConfigurator.configure();
102			}
103
104			logger.debug("log4j configured");
105
106			String lf = System.getProperties().getProperty(LOG_FILE_NAME);
107			if (lf != null) {
108				logFileName = lf;
109			}
110
111			// If already created a print writer then just use it.
112			try {
113				logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
114			} catch (FileNotFoundException fnfe) {
115
116			}
117		} catch (Exception ex) {
118			ex.printStackTrace();
119			throw new RuntimeException(ex);
120		}
121
122	}
123}