Search in sources :

Example 1 with RfMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method testMessageFactoryApplicationIdChangeACR.

@Test
public void testMessageFactoryApplicationIdChangeACR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).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 Rf is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RfAccountingRequest originalACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACR);
    // now we switch..
    originalACR = null;
    isVendor = !isVendor;
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RfAccountingRequest changedACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACR);
    // revert back to default
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RfMessageFactoryImpl(org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with RfMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method testServerSessionApplicationIdChangeACA.

@Test
public void testServerSessionApplicationIdChangeACA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).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 Rf is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    ((RfServerSessionActivityImpl) rfServerSession).fetchSessionData(acr, true);
    RfAccountingAnswer originalACA = rfServerSession.createRfAccountingAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACA);
    // now we switch..
    originalACA = null;
    isVendor = !isVendor;
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RfAccountingAnswer changedACA = rfServerSession.createRfAccountingAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
    changedACA = rfServerSession.createRfAccountingAnswer(acr);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACA);
    // revert back to default
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RfServerSessionActivityImpl(org.mobicents.slee.resource.diameter.rf.RfServerSessionActivityImpl) RfMessageFactoryImpl(org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl) RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

RfAccountingRequest (net.java.slee.resource.diameter.rf.events.RfAccountingRequest)2 ApplicationId (org.jdiameter.api.ApplicationId)2 Test (org.junit.Test)2 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)2 RfMessageFactoryImpl (org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl)2 RfAccountingAnswer (net.java.slee.resource.diameter.rf.events.RfAccountingAnswer)1 RfServerSessionActivityImpl (org.mobicents.slee.resource.diameter.rf.RfServerSessionActivityImpl)1