Search in sources :

Example 1 with ShClientMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShClientFactoriesTest method testMessageFactoryApplicationIdChangePUR.

@Test
public void testMessageFactoryApplicationIdChangePUR() 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...
    ProfileUpdateRequest originalPUR = shClientFactory.createProfileUpdateRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPUR);
    // now we switch..
    originalPUR = null;
    isVendor = !isVendor;
    ((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    ProfileUpdateRequest changedPUR = shClientFactory.createProfileUpdateRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPUR);
    // 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) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with ShClientMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl 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 3 with ShClientMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl 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);
}
Also used : UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShServerActivityImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerActivityImpl) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) ShServerSessionImpl(org.jdiameter.server.impl.app.sh.ShServerSessionImpl) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) ServerShSession(org.jdiameter.api.sh.ServerShSession) ShServerSessionDataLocalImpl(org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl) Test(org.junit.Test) ShClientActivityAnswerCreationTest(org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)

Example 4 with ShClientMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShServerActivityAnswerCreationTest method testShServerSubscriptionActivityAnswerCreation.

@Test
public void testShServerSubscriptionActivityAnswerCreation() 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);
    ShServerSubscriptionActivityImpl activity = new ShServerSubscriptionActivityImpl(new ShServerMessageFactoryImpl(msgFactory, session.getSessions().get(0), stack, diameterShAvpFactory), diameterShAvpFactory, session, null, null);
    DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Also used : ShServerSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerSubscriptionActivityImpl) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) ShServerSessionImpl(org.jdiameter.server.impl.app.sh.ShServerSessionImpl) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) ServerShSession(org.jdiameter.api.sh.ServerShSession) ShServerSessionDataLocalImpl(org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl) Test(org.junit.Test) ShClientActivityAnswerCreationTest(org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)

Example 5 with ShClientMessageFactoryImpl

use of org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl in project jain-slee.diameter by RestComm.

the class ShClientActivityAnswerCreationTest method testShClientActivityAnswerCreation.

@Test
public void testShClientActivityAnswerCreation() throws Exception {
    ClientShSession session = new ShClientSessionImpl(new ShClientSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ClientShSessionListenerImpl());
    PushNotificationRequest pnr = new PushNotificationRequestImpl(stack.getSessionFactory().getNewSession().createRequest(PushNotificationRequest.commandCode, SH_APP_ID, "mobicents.org", "hss.mobicents"));
    ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
    list.add(pnr);
    ShClientSubscriptionActivityImpl activity = new ShClientSubscriptionActivityImpl(new ShClientMessageFactoryImpl(session.getSessions().get(0), stack), new DiameterShAvpFactoryImpl(diameterAvpFactory), session, null, null);
    DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Also used : PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ClientShSession(org.jdiameter.api.sh.ClientShSession) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientSessionImpl(org.jdiameter.client.impl.app.sh.ShClientSessionImpl) ShClientSessionDataLocalImpl(org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) ShClientSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientSubscriptionActivityImpl) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

Test (org.junit.Test)8 ShClientMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)6 ApplicationId (org.jdiameter.api.ApplicationId)5 ArrayList (java.util.ArrayList)3 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)3 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)3 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)3 PushNotificationAnswer (net.java.slee.resource.diameter.sh.events.PushNotificationAnswer)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 ShClientActivityAnswerCreationTest (org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)2 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)2 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)1 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)1 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)1 ClientShSession (org.jdiameter.api.sh.ClientShSession)1 ShClientSessionDataLocalImpl (org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl)1