use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createPushNotificationRequest.
public PushNotificationRequest createPushNotificationRequest(UserIdentityAvp userIdentity, byte[] userData) {
PushNotificationRequest pnr = this.createPushNotificationRequest();
pnr.setUserIdentity(userIdentity);
pnr.setUserData(userData);
return pnr;
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method isProxiableCopiedPNA.
@Test
public void isProxiableCopiedPNA() throws Exception {
PushNotificationRequest pnr = createPushNotificationRequest();
PushNotificationAnswer pna = shClientFactory.createPushNotificationAnswer(pnr);
assertEquals("The 'P' bit is not copied from request in Push-Notification-Answer, it should. [RFC3588/6.2]", pnr.getHeader().isProxiable(), pna.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) pnr).getGenericData().setProxiable(!pnr.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in Push-Notification-Request, it should.", pnr.getHeader().isProxiable() != pna.getHeader().isProxiable());
pna = shClientFactory.createPushNotificationAnswer(pnr);
assertEquals("The 'P' bit is not copied from request in Push-Notification-Answer, it should. [RFC3588/6.2]", pnr.getHeader().isProxiable(), pna.getHeader().isProxiable());
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method hasTFlagSetPNA.
@Test
public void hasTFlagSetPNA() throws Exception {
PushNotificationRequest pnr = createPushNotificationRequest();
((DiameterMessageImpl) pnr).getGenericData().setReTransmitted(true);
assertTrue("The 'T' flag should be set in Push-Notification-Request", pnr.getHeader().isPotentiallyRetransmitted());
PushNotificationAnswer pna = shClientFactory.createPushNotificationAnswer(pnr);
assertFalse("The 'T' flag should not be set in Push-Notification-Answer", pna.getHeader().isPotentiallyRetransmitted());
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method testClientSessionApplicationIdChangePNA.
@Test
public void testClientSessionApplicationIdChangePNA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((ShClientMessageFactoryImpl) shClientFactory).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...
PushNotificationRequest pnr = createPushNotificationRequest();
UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
uiAvp.setPublicIdentity("alexandre@mobicents.org");
pnr.setUserIdentity(uiAvp);
pnr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
clientSubsSession.fetchSessionData(pnr, true);
PushNotificationAnswer originalPNA = clientSubsSession.createPushNotificationAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPNA);
// now we switch..
originalPNA = null;
isVendor = !isVendor;
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
PushNotificationAnswer changedPNA = clientSubsSession.createPushNotificationAnswer();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPNA);
// revert back to default
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method isPNRPublicIdentityAccessibleTwice.
@Test
public void isPNRPublicIdentityAccessibleTwice() throws Exception {
String originalValue = "sip:alexandre@diameter.mobicents.org";
UserIdentityAvpImpl uiAvp = new UserIdentityAvpImpl(DiameterShAvpCodes.USER_IDENTITY, 10415L, 1, 0, new byte[] {});
uiAvp.setPublicIdentity(originalValue);
PushNotificationRequest udr = shServerFactory.createPushNotificationRequest(uiAvp, new byte[1]);
String obtainedValue1 = udr.getUserIdentity().getPublicIdentity();
String obtainedValue2 = udr.getUserIdentity().getPublicIdentity();
assertTrue("Obtained value for Public-Identity AVP differs from original.", obtainedValue1.equals(originalValue));
assertTrue("Obtained #1 value for Public-Identity AVP differs from Obtained #2.", obtainedValue1.equals(obtainedValue2));
}
Aggregations