use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerActivityAnswerCreationTest method testShServerActivityAnswerCreation.
@Test
public void testShServerActivityAnswerCreation() throws Exception {
ServerShSession session = new ShServerSessionImpl(new ShServerSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ServerShSessionListenerImpl());
DiameterMessageFactoryImpl msgFactory = new DiameterMessageFactoryImpl(session.getSessions().get(0), stack, null, null);
ShClientMessageFactoryImpl factory = new ShClientMessageFactoryImpl(session.getSessions().get(0), stack);
UserDataRequest udr = factory.createUserDataRequest();
net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest pur = factory.createProfileUpdateRequest();
net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest snr = factory.createSubscribeNotificationsRequest();
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(udr);
list.add(pur);
list.add(snr);
ShServerActivityImpl activity = new ShServerActivityImpl(new ShServerMessageFactoryImpl(msgFactory, session.getSessions().get(0), stack, diameterShAvpFactory), diameterShAvpFactory, session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method hasTFlagSetUDA.
@Test
public void hasTFlagSetUDA() throws Exception {
UserDataRequest udr = shClientFactory.createUserDataRequest();
((DiameterMessageImpl) udr).getGenericData().setReTransmitted(true);
assertTrue("The 'T' flag should be set in User-Data-Request", udr.getHeader().isPotentiallyRetransmitted());
UserDataAnswer uda = shServerFactory.createUserDataAnswer(udr);
assertFalse("The 'T' flag should not be set in User-Data-Answer", uda.getHeader().isPotentiallyRetransmitted());
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method isProxiableCopiedUDA.
@Test
public void isProxiableCopiedUDA() throws Exception {
UserDataRequest udr = shClientFactory.createUserDataRequest();
UserDataAnswer uda = shServerFactory.createUserDataAnswer(udr);
assertEquals("The 'P' bit is not copied from request in User-Data-Answer, it should. [RFC3588/6.2]", udr.getHeader().isProxiable(), uda.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) udr).getGenericData().setProxiable(!udr.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in User-Data-Request, it should.", udr.getHeader().isProxiable() != uda.getHeader().isProxiable());
uda = shServerFactory.createUserDataAnswer(udr);
assertEquals("The 'P' bit is not copied from request in User-Data-Answer, it should. [RFC3588/6.2]", udr.getHeader().isProxiable(), uda.getHeader().isProxiable());
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method testServerSessionApplicationIdChangeUDA.
@Test
public void testServerSessionApplicationIdChangeUDA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((ShServerMessageFactoryImpl) shServerFactory).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 Sh is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
UserDataRequest udr = shClientFactory.createUserDataRequest();
UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
uiAvp.setPublicIdentity("alexandre@mobicents.org");
udr.setUserIdentity(uiAvp);
udr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
serverSession.fetchSessionData(udr, true);
UserDataAnswer originalUDA = serverSession.createUserDataAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUDA);
// now we switch..
originalUDA = null;
isVendor = !isVendor;
((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
UserDataAnswer changedUDA = serverSession.createUserDataAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUDA);
// revert back to default
((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class HSSClientChildSbb method getChargingInformation.
public String getChargingInformation(String publicIdentity, byte[] msisdn, String destinationRealm, String destinationHost) throws IOException {
UserIdentityAvp publicIdentityAvp = createUserIdentityAvp(publicIdentity, msisdn);
UserDataRequest udr = diameterShClientMessageFactory.createUserDataRequest(publicIdentityAvp, DataReferenceType.CHARGING_INFORMATION);
udr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
// Set destination -- Realm is mandatory, host is optional
udr.setDestinationRealm(new DiameterIdentity(destinationRealm));
if (destinationHost != null) {
udr.setDestinationHost(new DiameterIdentity(destinationHost));
}
ShClientActivity activity = getShClientActivity();
activity.sendUserDataRequest(udr);
// Store request for future matching
storeRequestInACI(activity, udr);
// Return Session-Id, may be used as identifier
return activity.getSessionId();
}
Aggregations