Search in sources :

Example 1 with CreditControlAnswer

use of net.java.slee.resource.diameter.cca.events.CreditControlAnswer in project jain-slee.diameter by RestComm.

the class CreditControlServerSessionImpl method sendCreditControlAnswer.

/*
   * (non-Javadoc)
   * 
   * @see net.java.slee.resource.diameter.cca.CreditControlServerSession#sendCreditControlAnswer(net.java.slee.resource.diameter.cca.events.CreditControlAnswer)
   */
public void sendCreditControlAnswer(CreditControlAnswer cca) throws IOException {
    fetchCurrentState(cca);
    DiameterMessageImpl msg = (DiameterMessageImpl) cca;
    try {
        session.sendCreditControlAnswer(new JCreditControlAnswerImpl((Answer) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        AvpNotAllowedException anae = new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
        throw anae;
    } catch (Exception e) {
        e.printStackTrace();
        IOException ioe = new IOException("Failed to send message, due to: " + e);
        throw ioe;
    }
}
Also used : CreditControlAnswer(net.java.slee.resource.diameter.cca.events.CreditControlAnswer) Answer(org.jdiameter.api.Answer) JCreditControlAnswerImpl(org.jdiameter.common.impl.app.cca.JCreditControlAnswerImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) 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 2 with CreditControlAnswer

use of net.java.slee.resource.diameter.cca.events.CreditControlAnswer in project jain-slee.diameter by RestComm.

the class CCAFactoriesTest method testGettersAndSettersCCA.

@Test
public void testGettersAndSettersCCA() throws Exception {
    CreditControlAnswer cca = ccaMessageFactory.createCreditControlAnswer(ccaMessageFactory.createCreditControlRequest("582364567346578348"));
    int nFailures = CCAAvpAssistant.INSTANCE.testMethods(cca, CreditControlAnswer.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : CreditControlAnswer(net.java.slee.resource.diameter.cca.events.CreditControlAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with CreditControlAnswer

use of net.java.slee.resource.diameter.cca.events.CreditControlAnswer in project jain-slee.diameter by RestComm.

the class CCAFactoriesTest method hasDestinationHostCCA.

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

Example 4 with CreditControlAnswer

use of net.java.slee.resource.diameter.cca.events.CreditControlAnswer in project jain-slee.diameter by RestComm.

the class CCAFactoriesTest method isProxiableCopiedCCA.

@Test
public void isProxiableCopiedCCA() throws Exception {
    CreditControlRequest ccr = ccaMessageFactory.createCreditControlRequest();
    CreditControlAnswer cca = ccaMessageFactory.createCreditControlAnswer(ccr);
    assertEquals("The 'P' bit is not copied from request in Credit-Control-Answer, it should. [RFC3588/6.2]", ccr.getHeader().isProxiable(), cca.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) ccr).getGenericData().setProxiable(!ccr.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Credit-Control-Request, it should.", ccr.getHeader().isProxiable() != cca.getHeader().isProxiable());
    cca = ccaMessageFactory.createCreditControlAnswer(ccr);
    assertEquals("The 'P' bit is not copied from request in Credit-Control-Answer, it should. [RFC3588/6.2]", ccr.getHeader().isProxiable(), cca.getHeader().isProxiable());
}
Also used : CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) CreditControlAnswer(net.java.slee.resource.diameter.cca.events.CreditControlAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with CreditControlAnswer

use of net.java.slee.resource.diameter.cca.events.CreditControlAnswer in project jain-slee.diameter by RestComm.

the class CCAFactoriesTest method hasTFlagSetCCA.

@Test
public void hasTFlagSetCCA() throws Exception {
    CreditControlRequest ccr = ccaMessageFactory.createCreditControlRequest();
    ((DiameterMessageImpl) ccr).getGenericData().setReTransmitted(true);
    assertTrue("The 'T' flag should be set in Credit-Control-Request", ccr.getHeader().isPotentiallyRetransmitted());
    CreditControlAnswer cca = ccaMessageFactory.createCreditControlAnswer(ccr);
    assertFalse("The 'T' flag should not be set in Credit-Control-Answer", cca.getHeader().isPotentiallyRetransmitted());
}
Also used : CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) CreditControlAnswer(net.java.slee.resource.diameter.cca.events.CreditControlAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

CreditControlAnswer (net.java.slee.resource.diameter.cca.events.CreditControlAnswer)7 Test (org.junit.Test)6 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)6 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)3 IOException (java.io.IOException)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 Answer (org.jdiameter.api.Answer)1 JCreditControlAnswerImpl (org.jdiameter.common.impl.app.cca.JCreditControlAnswerImpl)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1