Search in sources :

Example 1 with MProcRuleDefaultImpl

use of org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl in project smscgateway by RestComm.

the class SMSCShellExecutorTest method testShellExecutor_MProc.

@Test(groups = { "ShellExecutor" })
public void testShellExecutor_MProc() throws Exception {
    TT_PersistenceProxy sbb = new TT_PersistenceProxy();
    boolean cassandraDbInited = sbb.testCassandraAccess();
    if (!cassandraDbInited)
        return;
    MProcManagement mProcManagement = MProcManagement.getInstance();
    SmscManagement smscManagement = SmscManagement.getInstance("Test");
    SmppManagement smppManagement = SmppManagement.getInstance("Test");
    smscManagement.setSmppManagement(smppManagement);
    mProcManagement.setSmscManagement(smscManagement);
    smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
    smscManagement.start();
    SMSCShellExecutor exec = new SMSCShellExecutor();
    exec.setSmscManagement(smscManagement);
    mProcManagement.mprocs.clear();
    mProcManagement.store();
    assertEquals(mProcManagement.mprocs.size(), 0);
    String[] args = "smsc mproc add mproc 10 desttonmask 2 destnpimask 3 destdigmask ^[0-9a-zA-Z]* originatingmask SS7_MO networkidmask 21 newnetworkid 22 newdestton 4 newdestnpi 5 adddestdigprefix 47 makecopy true".split(" ");
    String s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    MProcRuleDefaultImpl rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 22);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 10 newnetworkid 23".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 11 newnetworkid 24".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getNewNetworkId(), 23);
    args = "smsc mproc add mproc 9 networkidmask 31 newnetworkid 32".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    assertEquals(mProcManagement.mprocs.size(), 0);
    mProcManagement.load();
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    args = "smsc mproc show 9".split(" ");
    s = exec.execute(args);
    args = "smsc mproc show".split(" ");
    s = exec.execute(args);
    args = "smsc mproc remove 9".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    smscManagement.stop();
}
Also used : MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor) SmppManagement(org.restcomm.smpp.SmppManagement) MProcRuleDefaultImpl(org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl) Test(org.testng.annotations.Test)

Aggregations

SMSCShellExecutor (org.mobicents.smsc.domain.SMSCShellExecutor)1 MProcRuleDefaultImpl (org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl)1 MProcRuleFactoryDefault (org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault)1 SmppManagement (org.restcomm.smpp.SmppManagement)1 Test (org.testng.annotations.Test)1