/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. */
  22. package org.mobicents.protocols.ss7.map.load;
  23. import java.io.FileNotFoundException;
  24. import java.io.IOException;
  25. import java.io.InputStream;
  26. import java.util.Properties;
  27. import org.apache.log4j.BasicConfigurator;
  28. import org.apache.log4j.FileAppender;
  29. import org.apache.log4j.Logger;
  30. import org.apache.log4j.PropertyConfigurator;
  31. import org.apache.log4j.SimpleLayout;
  32. import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
  33. import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl;
  34. import org.mobicents.protocols.ss7.map.api.MAPDialogListener;
  35. import org.mobicents.protocols.ss7.map.api.service.supplementary.MAPServiceSupplementaryListener;
  36. import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
  37. /**
  38. * @author abhayani
  39. *
  40. */
  41. public abstract class TestHarness implements MAPDialogListener, MAPServiceSupplementaryListener {
  42. private static final Logger logger = Logger.getLogger("map.test");
  43. protected static final String LOG_FILE_NAME = "log.file.name";
  44. protected static String logFileName = "maplog.txt";
  45. protected static int NDIALOGS = 50000;
  46. protected static int MAXCONCURRENTDIALOGS = 15;
  47. // MTP Details
  48. protected final int CLIENT_SPC = 1;
  49. protected final int SERVET_SPC = 2;
  50. protected final int NETWORK_INDICATOR = 2;
  51. protected final int SERVICE_INIDCATOR = 3; //SCCP
  52. protected final int SSN = 8;
  53. // M3UA details
  54. //protected final String CLIENT_IP = "172.31.96.40";
  55. protected final String CLIENT_IP = "127.0.0.1";
  56. protected final int CLIENT_PORT = 2345;
  57. //protected final String SERVER_IP = "172.31.96.41";
  58. protected final String SERVER_IP = "127.0.0.1";
  59. protected final int SERVER_PORT = 3434;
  60. protected final int ROUTING_CONTEXT = 100;
  61. protected final String SERVER_ASSOCIATION_NAME = "serverAsscoiation";
  62. protected final String CLIENT_ASSOCIATION_NAME = "clientAsscoiation";
  63. protected final String SERVER_NAME = "testserver";
  64. protected final SccpAddress SCCP_CLIENT_ADDRESS = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, CLIENT_SPC, null, SSN);
  65. protected final SccpAddress SCCP_SERVER_ADDRESS = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, SERVET_SPC, null, SSN);
  66. protected final ParameterFactoryImpl factory = new ParameterFactoryImpl();
  67. protected TestHarness() {
  68. init();
  69. }
  70. public void init() {
  71. try {
  72. Properties tckProperties = new Properties();
  73. InputStream inStreamLog4j = TestHarness.class.getResourceAsStream("/log4j.properties");
  74. System.out.println("Input Stream = " + inStreamLog4j);
  75. Properties propertiesLog4j = new Properties();
  76. try {
  77. propertiesLog4j.load(inStreamLog4j);
  78. PropertyConfigurator.configure(propertiesLog4j);
  79. } catch (IOException e) {
  80. e.printStackTrace();
  81. BasicConfigurator.configure();
  82. }
  83. logger.debug("log4j configured");
  84. String lf = System.getProperties().getProperty(LOG_FILE_NAME);
  85. if (lf != null) {
  86. logFileName = lf;
  87. }
  88. // If already created a print writer then just use it.
  89. try {
  90. logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
  91. } catch (FileNotFoundException fnfe) {
  92. }
  93. } catch (Exception ex) {
  94. ex.printStackTrace();
  95. throw new RuntimeException(ex);
  96. }
  97. }
  98. }