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