use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.
the class GxClientSessionActivityImpl method sendEventGxCreditControlRequest.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diametergx.GxClientSessionActivity#sendEventGxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)
*/
public void sendEventGxCreditControlRequest(final GxCreditControlRequest ccr) throws IOException {
// fetchCurrentState(ccr);
final DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
validateState(ccr);
try {
session.sendCreditControlRequest(new GxCreditControlRequestImpl((Request) msg.getGenericData()));
} 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.", e);
}
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.
the class GxFactoriesTest method isRequestCCR.
@Test
public void isRequestCCR() throws Exception {
GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
assertTrue("Request Flag in Credit-Control-Request is not set.", ccr.getHeader().isRequest());
}
use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.
the class GxFactoriesTest method hasTFlagSetCCA.
@Test
public void hasTFlagSetCCA() throws Exception {
GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
((DiameterMessageImpl) ccr).getGenericData().setReTransmitted(true);
assertTrue("The 'T' flag should be set in Credit-Control-Request", ccr.getHeader().isPotentiallyRetransmitted());
((GxServerSessionActivityImpl) gxServerSession).fetchCurrentState(ccr);
GxCreditControlAnswer cca = gxServerSession.createGxCreditControlAnswer();
assertFalse("The 'T' flag should not be set in Credit-Control-Answer", cca.getHeader().isPotentiallyRetransmitted());
}
use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.
the class GxFactoriesTest method testMessageFactoryApplicationIdChangeInClientSessionCCR.
@Test
public void testMessageFactoryApplicationIdChangeInClientSessionCCR() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((GxMessageFactoryImpl) gxMessageFactory).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 Gx is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
GxCreditControlRequest originalCCR = gxClientSession.createGxCreditControlRequest(CcRequestType.EVENT_REQUEST);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCR);
// now we switch..
originalCCR = null;
isVendor = !isVendor;
((GxMessageFactoryImpl) gxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
GxCreditControlRequest changedCCR = gxClientSession.createGxCreditControlRequest(CcRequestType.EVENT_REQUEST);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCR);
// revert back to default
((GxMessageFactoryImpl) gxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.
the class GxFactoriesTest method isProxiableCCR.
@Test
public void isProxiableCCR() throws Exception {
GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
assertTrue("The 'P' bit is not set by default in Gx Credit-Control-Request, it should.", ccr.getHeader().isProxiable());
}
Aggregations