Skip Headers
Oracle® Communications Services Gatekeeper Platform Test Environment Guide
Release 5.1

E37534-01
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
PDF · Mobi · ePub

3 Adding and Testing Custom Client Modules

This chapter explains how to extend the PTE by adding and testing custom client modules. Client modules serve as the application-facing interfaces for communication services. Client modules are displayed in the PTE GUI when you select the Clients item in the tools selection panel. An example unit test is included with this release that you can use as a model for your own customizations.

Adding Custom PTE Client Modules to the PTE

For instructions on how to create and deploy new client modules (application-facing), network protocol simulators (network-facing), and communication services, see “Extending the ATE and PTE” in Oracle Communications Services Gatekeeper Platform Development Studio Developer's Guide, another document in this set.

Testing New or Changed Client Modules

This section explains how to verify that your new or modified client modules are functioning correctly.

Understanding Communication Service Unit Tests

Unit tests are an essential part of creating or changing a Services Gatekeeper communication service. You add known data to the system, run tests on it, and confirm that the test results are what you expect, all programatically.

You use the Unit Test Framework to create PTE unit tests. Its main tools include:

  • The OCSGBaseTestCase abstract class (located in Middleware_Home/ocsg_pds_5.1/lib/wlng/pte_api.jar) manages the mechanics of using JMX and JMS to connect to the PTE.

  • The test.properties file (located in Middleware_Home/ocsg_pds_5.1/lib/wlng/pte_api.jar) defines the commonly changed properties of the test.

Figure 3-1 An Example SMS Unit Test Workflow

Description of Figure 3-1 follows
Description of "Figure 3-1 An Example SMS Unit Test Workflow"

The workflow of the SMS unit test is as follows:

  1. The test client calls execute on the PTE Module Management MBean. The mechanics of the JMX call are taken care of by the base class.

  2. The MBean calls execute on the specified module; in this case, sendSMS. This request includes a request for delivery receipts.

  3. The sendSMS module sends the request to Services Gatekeeper.

  4. Services Gatekeeper processes the request and submits it to the network simulator module; in this case, the SMPP module.

  5. The simulator module returns a delivery receipt to Services Gatekeeper

  6. Services Gatekeeper sends the receipt on to the Notification module (which represents the client Web Service implementation).

  7. The test client retrieves the result of Services Gatekeeper's submit from the SMPP simulator.

  8. The test client retrieves the delivery receipt from the Notification module.

Understanding the Example Unit Test

To help you understand how unit tests work, PTE includes an example unit test (TestSendData.java), which tests an example communication service using the example clients and simulator. The default location for this file is Middleware_Home/ocsg_pds_5.1/example/unit_test/src/oracle/ocsg/et/example/TestSendData.java. Example 3-1 shows the TestSendData.java file example communication service test.

Example 3-1 A Unit Test for the Example Communication Service

package oracle.ocsg.et.example;
import oracle.ocsg.pte.api.OCSGBaseTestCase;
import java.util.List;
import java.util.Map;
/**
 * This class illustrates how to use the Unit Test Framework to
 * test the Communication Service Example. A few things are assumed before
 * running this class:
 * - the OCSG should be running and configured properly * - the CS example should be deployed and ready * Note: this example uses also the wlngJmx to be able to access the OCSG * MBeans to ask the CS example plugin to connect to the Netex simulator.
 * */public class TestSendData extends OCSGBaseTestCase {  private static final String SEND_DATA_MBEAN = "com.bea.wlcp.wlng.pte:group=traffic,name=example_application_initiated";  private static final String NETWORK_TRIGGERED_MBEAN = "com.bea.wlcp.wlng.pte:group=traffic,name=example_network_triggered";  private static final String NOTIF_MANAGER_MBEAN = "com.bea.wlcp.wlng.pte:group=client,name=example_notif_manager";  private static final String NOTIF_MBEAN = "com.bea.wlcp.wlng.pte:group=client,name=example_notif";  private static final String NETEX_SIMULATOR_MBEAN = "com.bea.wlcp.wlng.pte:group=netex,name=example_simulator";
 // Make sure the InstanceName correspond to the instance name provided // in the PluginManager Mbean when creating the plugin instance. private static final String EXAMPLE_PLUGIN_MBEAN =          "com.bea.wlcp.wlng:AppName=example_enabler#4.0," +                  "InstanceName=example_1," +                          "Type=com.acompany.plugin.example.netex.management.ExampleMBean";  public TestSendData() throws Exception {  }  @Override  protected void setUp() throws Exception {    super.setUp();    ocsgJmx.open("localhost", 8001, "weblogic", "weblogic");    start(NETEX_SIMULATOR_MBEAN);  }  @Override  protected void tearDown() throws Exception {    ocsgJmx.close();    stop(NETEX_SIMULATOR_MBEAN);    super.tearDown();  }  public void testSendData() throws Exception {    assertTrue(isRunning(NETEX_SIMULATOR_MBEAN));    resetStatistics(NETEX_SIMULATOR_MBEAN);    ocsgJmx.invokeOperation(EXAMPLE_PLUGIN_MBEAN, "connect");    String data = "Hello at " + System.currentTimeMillis();    String to = "tel:1234";    putParameter(SEND_DATA_MBEAN, "url", "http://localhost:8001/example/SendData");    putParameter(SEND_DATA_MBEAN, "data.data", data);    putParameter(SEND_DATA_MBEAN, "data.address", to);    start(SESSION_MBEAN);    assertTrue(isRunning(SESSION_MBEAN));    execute(SEND_DATA_MBEAN);    Thread.sleep(2000);    stop(SESSION_MBEAN);    Map<String,String> stats = listAllStatistics(NETEX_SIMULATOR_MBEAN);    System.out.println("Simulator statistics: "+stats);    assertEquals("MessageReceived", "1", stats.get("MessageReceived"));    assertEquals("MessageSent", "0", stats.get("MessageSent"));  }  public void testSendNetworkTriggeredData() throws Exception {    String data = "Hello at " + System.currentTimeMillis();    String from = "tel:1234";    String to = "tel:7878";    String correlator = "1234567890";    assertTrue(isRunning(NETEX_SIMULATOR_MBEAN));    resetStatistics(NETEX_SIMULATOR_MBEAN);    ocsgJmx.invokeOperation(EXAMPLE_PLUGIN_MBEAN, "connect");    start(SESSION_MBEAN);    assertTrue(isRunning(SESSION_MBEAN));    putParameter(NOTIF_MANAGER_MBEAN, "url", "http://localhost:8001/example/NotificationManager");    putParameter(NOTIF_MANAGER_MBEAN, "start.address", "tel:7878");    putParameter(NOTIF_MANAGER_MBEAN, "start.correlator", correlator);    putParameter(NOTIF_MANAGER_MBEAN, "start.endpoint", "http://localhost:13444/jaxws/NetexNotification");    putParameter(NOTIF_MANAGER_MBEAN, "stop.correlator", correlator);    start(NOTIF_MANAGER_MBEAN);    start(NOTIF_MBEAN);    putParameter(NETWORK_TRIGGERED_MBEAN, "data", data);    putParameter(NETWORK_TRIGGERED_MBEAN, "fromAddress", from);    putParameter(NETWORK_TRIGGERED_MBEAN, "toAddress", to);    clearResults(NOTIF_MBEAN);    execute(NETWORK_TRIGGERED_MBEAN);    Thread.sleep(2000);    stop(NOTIF_MBEAN);    stop(NOTIF_MANAGER_MBEAN);    stop(SESSION_MBEAN);    Map<String,String> stats = listAllStatistics(NETEX_SIMULATOR_MBEAN);    System.out.println("Simulator statistics: "+stats);    assertEquals("MessageReceived", "0", stats.get("MessageReceived"));    assertEquals("MessageSent", "1", stats.get("MessageSent"));    List<Map<String,String>> results = listAllResults(NOTIF_MBEAN);    System.out.println("Notification results: "+results);    assertEquals("Correlator", correlator, results.get(0).get("Correlator"));    assertEquals("From Address", from, results.get(0).get("From Address"));    assertEquals("Data", data, results.get(0).get("Data"));  }}

Creating and Running a New Unit Test

To create and run a PTE unit test:

Note:

The PTE should be running in Console (non-GUI) mode when you run your test. See "Starting the PTE" for instructions on starting the PTE in Console mode.
  1. Create any necessary client or simulator modules for the PTE using the required SPI and XML configuration files. See "Adding Custom PTE Client Modules to the PTE" for details.

  2. Implement a test class based on the OCSGBaseTestCase abstract class.

  3. Add the test class to the PTE. For details, see “Extending the ATE and PTE” in Oracle Communications Services Gatekeeper Platform Development Studio Developer's Guide, another document in this set.

  4. Start the PTE and make sure the modules are correctly loaded. For details on starting PTE, see "Starting the PTE". If your new module is correctly loaded, it appears in the PTE GUI.

  5. Run the test class. See "Using the PTE to Test Services Gatekeeper" for details.

Figure 3-1 shows the workflow of a typical unit test; in this case an SMS communication service unit test.