Search in sources :

Example 6 with RfAccountingAnswer

use of net.java.slee.resource.diameter.rf.events.RfAccountingAnswer 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)

Example 7 with RfAccountingAnswer

use of net.java.slee.resource.diameter.rf.events.RfAccountingAnswer in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method hasDestinationHostACA.

@Test
public void hasDestinationHostACA() throws Exception {
    RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer();
    assertNull("The Destination-Host and Destination-Realm AVPs MUST NOT be present in the answer message. [RFC3588/6.2]", aca.getDestinationHost());
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 8 with RfAccountingAnswer

use of net.java.slee.resource.diameter.rf.events.RfAccountingAnswer in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method hasRfApplicationIdACA.

@Test
public void hasRfApplicationIdACA() throws Exception {
    RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer();
    assertTrue("Acct-Application-Id AVP in Ro ACA must be 3, it is " + aca.getAcctApplicationId(), aca.getAcctApplicationId() == 3);
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 9 with RfAccountingAnswer

use of net.java.slee.resource.diameter.rf.events.RfAccountingAnswer in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method isAnswerACA.

@Test
public void isAnswerACA() throws Exception {
    RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer();
    assertFalse("Request Flag in Accounting-Answer is set.", aca.getHeader().isRequest());
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 10 with RfAccountingAnswer

use of net.java.slee.resource.diameter.rf.events.RfAccountingAnswer in project jain-slee.diameter by RestComm.

the class RfServerSessionActivityImpl method createRfAccountingAnswer.

public RfAccountingAnswer createRfAccountingAnswer() {
    RfAccountingAnswer answer = null;
    for (int index = 0; index < stateMessages.size(); index++) {
        if (stateMessages.get(index).getCommand().getCode() == RfAccountingRequest.commandCode) {
            RfAccountingRequest msg = (RfAccountingRequest) stateMessages.get(index);
            answer = createRfAccountingAnswer(msg);
            if (!answer.hasSessionId() && session != null) {
                answer.setSessionId(session.getSessionId());
            }
            ((DiameterMessageImpl) answer).setData(msg);
            break;
        }
    }
    return answer;
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)

Aggregations

RfAccountingAnswer (net.java.slee.resource.diameter.rf.events.RfAccountingAnswer)11 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 RfAccountingRequest (net.java.slee.resource.diameter.rf.events.RfAccountingRequest)4 IOException (java.io.IOException)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 Answer (org.jdiameter.api.Answer)1 ApplicationId (org.jdiameter.api.ApplicationId)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1 RfMessageFactoryImpl (org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl)1 RfServerSessionActivityImpl (org.mobicents.slee.resource.diameter.rf.RfServerSessionActivityImpl)1 RfAccountingAnswerImpl (org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl)1