Search in sources :

Example 1 with RoMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testServerSessionApplicationIdChangeCCA.

@Test
public void testServerSessionApplicationIdChangeCCA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest ccr = roMessageFactory.createRoCreditControlRequest();
    ((RoServerSessionActivityImpl) roServerSession).fetchCurrentState(ccr);
    RoCreditControlAnswer originalCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCA);
    // now we switch..
    originalCCA = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlAnswer changedCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCA);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RoServerSessionActivityImpl(org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl) RoCreditControlAnswer(net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer) ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with RoMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testMessageFactoryApplicationIdChangeCCR.

@Test
public void testMessageFactoryApplicationIdChangeCCR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest originalCCR = roMessageFactory.createRoCreditControlRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCR);
    // now we switch..
    originalCCR = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlRequest changedCCR = roMessageFactory.createRoCreditControlRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCR);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with RoMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testClientSessionApplicationIdChangeCCR.

@Test
public void testClientSessionApplicationIdChangeCCR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest originalCCR = roClientSession.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCR);
    // now we switch..
    originalCCR = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlRequest changedCCR = roClientSession.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCR);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

RoCreditControlRequest (net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)3 ApplicationId (org.jdiameter.api.ApplicationId)3 Test (org.junit.Test)3 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)3 RoMessageFactoryImpl (org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl)3 RoCreditControlAnswer (net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer)1 RoServerSessionActivityImpl (org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl)1