Search in sources :

Example 6 with AccountingAnswer

use of net.java.slee.resource.diameter.base.events.AccountingAnswer in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method testGettersAndSettersACA.

@Test
public void testGettersAndSettersACA() throws Exception {
    AccountingAnswer aca = messageFactory.createAccountingAnswer(messageFactory.createAccountingRequest());
    int nFailures = AvpAssistant.INSTANCE.testMethods(aca, AccountingAnswer.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer) Test(org.junit.Test)

Example 7 with AccountingAnswer

use of net.java.slee.resource.diameter.base.events.AccountingAnswer in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method isProxiableCopiedACA.

@Test
public void isProxiableCopiedACA() throws Exception {
    AccountingRequest acr = messageFactory.createAccountingRequest();
    acr.setSessionId("sssxxx");
    AccountingAnswer aca = messageFactory.createAccountingAnswer(acr);
    System.out.println(aca);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) acr).getGenericData().setProxiable(!acr.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Accounting-Request, it should.", acr.getHeader().isProxiable() != aca.getHeader().isProxiable());
    aca = messageFactory.createAccountingAnswer(acr);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer) Test(org.junit.Test)

Example 8 with AccountingAnswer

use of net.java.slee.resource.diameter.base.events.AccountingAnswer in project jain-slee.diameter by RestComm.

the class AccountingServerSessionActivityImpl method createAccountAnswer.

public AccountingAnswer createAccountAnswer(AccountingRequest request, int resultCode) {
    AccountingAnswer answer = this.createAccountingAnswer(request);
    answer.setResultCode(resultCode);
    return answer;
}
Also used : AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer)

Example 9 with AccountingAnswer

use of net.java.slee.resource.diameter.base.events.AccountingAnswer in project jain-slee.diameter by RestComm.

the class AccountingServerSessionActivityImpl method sendAccountingAnswer.

public void sendAccountingAnswer(AccountingAnswer answer) throws IOException {
    try {
        AccountingAnswerImpl aca = (AccountingAnswerImpl) answer;
        this.serverSession.sendAccountAnswer(new AccountAnswerImpl((Answer) aca.getGenericData()));
        // FIXME: check this?
        if (this.serverSession.isStateless()) {
            endActivity();
        } else if (aca.getAccountingRecordType() == AccountingRecordType.STOP_RECORD) {
            endActivity();
        }
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to send message, due to: ", e);
        }
        throw new IOException("Failed to send message, due to: " + e.getMessage());
    }
}
Also used : AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer) Answer(org.jdiameter.api.Answer) AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) AccountAnswerImpl(org.jdiameter.common.impl.app.acc.AccountAnswerImpl) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 10 with AccountingAnswer

use of net.java.slee.resource.diameter.base.events.AccountingAnswer in project jain-slee.diameter by RestComm.

the class DiameterMessageFactoryImpl method createAccountingAnswer.

public AccountingAnswer createAccountingAnswer(AccountingRequest request, DiameterAvp[] avps) throws AvpNotAllowedException {
    AccountingAnswer msg = (AccountingAnswer) this.createDiameterMessage(request.getHeader(), avps, Message.ACCOUNTING_ANSWER, getApplicationId(request));
    // Add Session-Id AVP if not present
    addSessionIdAvp(msg);
    return msg;
}
Also used : AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer)

Aggregations

AccountingAnswer (net.java.slee.resource.diameter.base.events.AccountingAnswer)10 Test (org.junit.Test)6 AccountingRequest (net.java.slee.resource.diameter.base.events.AccountingRequest)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AccountingServerSessionActivity (net.java.slee.resource.diameter.base.AccountingServerSessionActivity)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 GroupedAvp (net.java.slee.resource.diameter.base.events.avp.GroupedAvp)1 Answer (org.jdiameter.api.Answer)1 AccountAnswerImpl (org.jdiameter.common.impl.app.acc.AccountAnswerImpl)1 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)1