Search in sources :

Example 6 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testServerSessionApplicationIdChangeCCA.

@Test
public void testServerSessionApplicationIdChangeCCA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).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 Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest ccr = roMessageFactory.createRoCreditControlRequest();
    ((RoServerSessionActivityImpl) roServerSession).fetchCurrentState(ccr);
    RoCreditControlAnswer originalCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCA);
    // now we switch..
    originalCCA = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlAnswer changedCCA = roServerSession.createRoCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCA);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RoServerSessionActivityImpl(org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl) RoCreditControlAnswer(net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer) ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method isProxiableCopiedCCA.

@Test
public void isProxiableCopiedCCA() throws Exception {
    RoCreditControlRequest ccr = roMessageFactory.createRoCreditControlRequest();
    ((RoServerSessionActivityImpl) roServerSession).fetchCurrentState(ccr);
    RoCreditControlAnswer cca = roServerSession.createRoCreditControlAnswer();
    assertEquals("The 'P' bit is not copied from request in Ro 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 Ro Credit-Control-Request, it should.", ccr.getHeader().isProxiable() != cca.getHeader().isProxiable());
    ((RoServerSessionActivityImpl) roServerSession).fetchCurrentState(ccr);
    cca = roServerSession.createRoCreditControlAnswer();
    assertEquals("The 'P' bit is not copied from request in Ro Credit-Control-Answer, it should. [RFC3588/6.2]", ccr.getHeader().isProxiable(), cca.getHeader().isProxiable());
}
Also used : RoServerSessionActivityImpl(org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl) RoCreditControlAnswer(net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 8 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method testMessageFactoryApplicationIdChangeCCR.

@Test
public void testMessageFactoryApplicationIdChangeCCR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RoMessageFactoryImpl) roMessageFactory).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 Ro is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RoCreditControlRequest originalCCR = roMessageFactory.createRoCreditControlRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCR);
    // now we switch..
    originalCCR = null;
    isVendor = !isVendor;
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RoCreditControlRequest changedCCR = roMessageFactory.createRoCreditControlRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCR);
    // revert back to default
    ((RoMessageFactoryImpl) roMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) RoMessageFactoryImpl(org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 9 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method hasRoApplicationIdCCR.

@Test
public void hasRoApplicationIdCCR() throws Exception {
    RoCreditControlRequest ccr = roMessageFactory.createRoCreditControlRequest();
    assertTrue("Auth-Application-Id AVP in Ro CCR must be 4, it is " + ccr.getAuthApplicationId(), ccr.getAuthApplicationId() == 4);
}
Also used : RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 10 with RoCreditControlRequest

use of net.java.slee.resource.diameter.ro.events.RoCreditControlRequest in project jain-slee.diameter by RestComm.

the class RoFactoriesTest method hasTFlagSetCCA.

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

Aggregations

RoCreditControlRequest (net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)18 Test (org.junit.Test)9 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)9 IOException (java.io.IOException)5 DiameterException (net.java.slee.resource.diameter.base.DiameterException)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)4 RoCreditControlAnswer (net.java.slee.resource.diameter.ro.events.RoCreditControlAnswer)4 Request (org.jdiameter.api.Request)4 RoCreditControlRequestImpl (org.jdiameter.common.impl.app.ro.RoCreditControlRequestImpl)4 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 ApplicationId (org.jdiameter.api.ApplicationId)3 RoMessageFactoryImpl (org.mobicents.slee.resource.diameter.ro.RoMessageFactoryImpl)3 RoServerSessionActivityImpl (org.mobicents.slee.resource.diameter.ro.RoServerSessionActivityImpl)3 ActivityContextInterface (javax.slee.ActivityContextInterface)2 CreateException (javax.slee.CreateException)2 ArrayList (java.util.ArrayList)1 SLEEException (javax.slee.SLEEException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)1 MultipleServicesCreditControlAvp (net.java.slee.resource.diameter.cca.events.avp.MultipleServicesCreditControlAvp)1