Search in sources :

Example 1 with PushNotificationRequest

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;
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest)

Example 2 with PushNotificationRequest

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());
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) PushNotificationAnswer(net.java.slee.resource.diameter.sh.events.PushNotificationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with PushNotificationRequest

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());
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) PushNotificationAnswer(net.java.slee.resource.diameter.sh.events.PushNotificationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 4 with PushNotificationRequest

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());
}
Also used : ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) ApplicationId(org.jdiameter.api.ApplicationId) PushNotificationAnswer(net.java.slee.resource.diameter.sh.events.PushNotificationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with PushNotificationRequest

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));
}
Also used : PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) UserIdentityAvpImpl(org.mobicents.slee.resource.diameter.sh.events.avp.UserIdentityAvpImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)14 Test (org.junit.Test)10 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)10 PushNotificationAnswer (net.java.slee.resource.diameter.sh.events.PushNotificationAnswer)5 ApplicationId (org.jdiameter.api.ApplicationId)3 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)3 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)2 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)2 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)2 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)2 DiameterShMessageImpl (org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 Request (org.jdiameter.api.Request)1 ClientShSession (org.jdiameter.api.sh.ClientShSession)1 ShClientSessionDataLocalImpl (org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl)1 ShClientSessionImpl (org.jdiameter.client.impl.app.sh.ShClientSessionImpl)1 PushNotificationRequestImpl (org.jdiameter.common.impl.app.sh.PushNotificationRequestImpl)1