Search in sources :

Example 1 with CreditControlRequest

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

the class CreditControlClientSessionImpl method sendInitialCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
   * sendInitialCreditControlRequest
   * (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
   */
public void sendInitialCreditControlRequest(CreditControlRequest ccr) throws IOException {
    // FIXME: should this affect FSM ?
    ccr.setCcRequestType(CcRequestType.INITIAL_REQUEST);
    validateState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new JCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : JCreditControlRequestImpl(org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl) Request(org.jdiameter.api.Request) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) 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) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 2 with CreditControlRequest

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

the class CreditControlClientSessionImpl method sendTerminationCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
   * sendTerminationCreditControlRequest
   * (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
   */
public void sendTerminationCreditControlRequest(CreditControlRequest ccr) throws IOException {
    // This should not be used to terminate sub-sessions!
    // FIXME: Should this come already in the CCR?
    ccr.setCcRequestType(CcRequestType.TERMINATION_REQUEST);
    validateState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new JCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : JCreditControlRequestImpl(org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl) Request(org.jdiameter.api.Request) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) 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) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 3 with CreditControlRequest

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

the class CCAFactoriesTest method testGettersAndSettersCCR.

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

Example 4 with CreditControlRequest

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

the class CCAFactoriesTest method isRequestCCR.

@Test
public void isRequestCCR() throws Exception {
    CreditControlRequest ccr = ccaMessageFactory.createCreditControlRequest();
    assertTrue("Request Flag in Credit-Control-Request is not set.", ccr.getHeader().isRequest());
}
Also used : CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with CreditControlRequest

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

Aggregations

CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)12 Test (org.junit.Test)6 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)6 IOException (java.io.IOException)4 DiameterException (net.java.slee.resource.diameter.base.DiameterException)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)4 Request (org.jdiameter.api.Request)4 JCreditControlRequestImpl (org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl)4 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 CreditControlAnswer (net.java.slee.resource.diameter.cca.events.CreditControlAnswer)3 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)2 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)1 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)1