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());
}
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());
}
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);
}
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());
}
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;
}
Aggregations