Search in sources :

Example 6 with ShServerMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method testMessageFactoryApplicationIdChangeSNA.

@Test
public void testMessageFactoryApplicationIdChangeSNA() 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...
    SubscribeNotificationsAnswer originalSNA = shServerFactory.createSubscribeNotificationsAnswer(shClientFactory.createSubscribeNotificationsRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSNA);
    // now we switch..
    originalSNA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SubscribeNotificationsAnswer changedSNA = shServerFactory.createSubscribeNotificationsAnswer(shClientFactory.createSubscribeNotificationsRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSNA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with ShServerMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method testServerSessionApplicationIdChangePUA.

@Test
public void testServerSessionApplicationIdChangePUA() 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...
    ProfileUpdateRequest pur = shClientFactory.createProfileUpdateRequest();
    UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
    uiAvp.setPublicIdentity("alexandre@mobicents.org");
    pur.setUserIdentity(uiAvp);
    pur.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    serverSession.fetchSessionData(pur, true);
    ProfileUpdateAnswer originalPUA = serverSession.createProfileUpdateAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPUA);
    // now we switch..
    originalPUA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    ProfileUpdateAnswer changedPUA = serverSession.createProfileUpdateAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPUA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 8 with ShServerMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method testMessageFactoryApplicationIdChangeUDA.

@Test
public void testMessageFactoryApplicationIdChangeUDA() 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...
    UserDataAnswer originalUDA = shServerFactory.createUserDataAnswer(shClientFactory.createUserDataRequest());
    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 = shServerFactory.createUserDataAnswer(shClientFactory.createUserDataRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUDA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : UserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 9 with ShServerMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method testServerSessionApplicationIdChangeSNA.

@Test
public void testServerSessionApplicationIdChangeSNA() 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...
    SubscribeNotificationsRequest snr = shClientFactory.createSubscribeNotificationsRequest();
    UserIdentityAvp uiAvp = shAvpFactory.createUserIdentity();
    uiAvp.setPublicIdentity("alexandre@mobicents.org");
    snr.setUserIdentity(uiAvp);
    snr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    serverSession.fetchSessionData(snr, true);
    SubscribeNotificationsAnswer originalSNA = serverSession.createSubscribeNotificationsAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSNA);
    // now we switch..
    originalSNA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SubscribeNotificationsAnswer changedSNA = serverSession.createSubscribeNotificationsAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSNA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : SubscribeNotificationsRequest(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

Test (org.junit.Test)9 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)9 ApplicationId (org.jdiameter.api.ApplicationId)7 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)7 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)3 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)3 ArrayList (java.util.ArrayList)2 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)2 ProfileUpdateAnswer (net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)2 SubscribeNotificationsAnswer (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer)2 UserDataAnswer (net.java.slee.resource.diameter.sh.events.UserDataAnswer)2 ServerShSession (org.jdiameter.api.sh.ServerShSession)2 ShServerSessionDataLocalImpl (org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl)2 ShServerSessionImpl (org.jdiameter.server.impl.app.sh.ShServerSessionImpl)2 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)2 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)2 ShClientActivityAnswerCreationTest (org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)2 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)1 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)1 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)1