Search in sources :

Example 1 with SessionTerminationAnswer

use of net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method hasTFlagSetSTA.

@Test
public void hasTFlagSetSTA() throws Exception {
    SessionTerminationRequest str = rxMessageFactory.createSessionTerminationRequest();
    ((DiameterMessageImpl) str).getGenericData().setReTransmitted(true);
    assertTrue("The 'T' flag should be set in Session-Termination-Request", str.getHeader().isPotentiallyRetransmitted());
    SessionTerminationAnswer sta = rxMessageFactory.createSessionTerminationAnswer(str);
    assertFalse("The 'T' flag should not be set in Session-Termination-Answer", sta.getHeader().isPotentiallyRetransmitted());
}
Also used : SessionTerminationAnswer(net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer) SessionTerminationRequest(net.java.slee.resource.diameter.rx.events.SessionTerminationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with SessionTerminationAnswer

use of net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method testMessageFactoryApplicationIdChangeSTA.

@Test
public void testMessageFactoryApplicationIdChangeSTA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RxMessageFactoryImpl) rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    SessionTerminationAnswer originalSTA = rxMessageFactory.createSessionTerminationAnswer(rxMessageFactory.createSessionTerminationRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSTA);
    // now we switch..
    originalSTA = null;
    isVendor = !isVendor;
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SessionTerminationAnswer changedSTA = rxMessageFactory.createSessionTerminationAnswer(rxMessageFactory.createSessionTerminationRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSTA);
    // revert back to default
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : SessionTerminationAnswer(net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer) RxMessageFactoryImpl(org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with SessionTerminationAnswer

use of net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method testServerSessionApplicationIdChangeSTA.

@Test
public void testServerSessionApplicationIdChangeSTA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RxMessageFactoryImpl) rxMessageFactory).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 Rx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    SessionTerminationRequest str = rxMessageFactory.createSessionTerminationRequest();
    rxServerSession.fetchCurrentState(str);
    SessionTerminationAnswer originalSTA = rxServerSession.createSessionTermAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSTA);
    // now we switch..
    originalSTA = null;
    isVendor = !isVendor;
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    SessionTerminationAnswer changedSTA = rxServerSession.createSessionTermAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSTA);
    // revert back to default
    ((RxMessageFactoryImpl) rxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : SessionTerminationAnswer(net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer) RxMessageFactoryImpl(org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) SessionTerminationRequest(net.java.slee.resource.diameter.rx.events.SessionTerminationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 4 with SessionTerminationAnswer

use of net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method isProxiableCopiedSTA.

@Test
public void isProxiableCopiedSTA() throws Exception {
    SessionTerminationRequest str = rxMessageFactory.createSessionTerminationRequest();
    SessionTerminationAnswer sta = rxMessageFactory.createSessionTerminationAnswer(str);
    assertEquals("The 'P' bit is not copied from request in Session-Termination-Answer, it should. [RFC3588/6.2]", str.getHeader().isProxiable(), sta.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) str).getGenericData().setProxiable(!str.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Session-Termination-Request, it should.", str.getHeader().isProxiable() != sta.getHeader().isProxiable());
    sta = rxMessageFactory.createSessionTerminationAnswer(str);
    assertEquals("The 'P' bit is not copied from request in Session-Termination-Answer, it should. [RFC3588/6.2]", str.getHeader().isProxiable(), sta.getHeader().isProxiable());
}
Also used : SessionTerminationAnswer(net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer) SessionTerminationRequest(net.java.slee.resource.diameter.rx.events.SessionTerminationRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with SessionTerminationAnswer

use of net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method hasDestinationHostSTA.

@Test
public void hasDestinationHostSTA() throws Exception {
    SessionTerminationAnswer sta = rxMessageFactory.createSessionTerminationAnswer(rxMessageFactory.createSessionTerminationRequest());
    assertNull("The Destination-Host and Destination-Realm AVPs MUST NOT be present in the answer message. [RFC3588/6.2]", sta.getDestinationHost());
}
Also used : SessionTerminationAnswer(net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

SessionTerminationAnswer (net.java.slee.resource.diameter.rx.events.SessionTerminationAnswer)10 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 SessionTerminationRequest (net.java.slee.resource.diameter.rx.events.SessionTerminationRequest)3 ApplicationId (org.jdiameter.api.ApplicationId)2 RxMessageFactoryImpl (org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl)2 IOException (java.io.IOException)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 AAAnswer (net.java.slee.resource.diameter.rx.events.AAAnswer)1 Answer (org.jdiameter.api.Answer)1 RxSessionTermAnswerImpl (org.jdiameter.common.impl.app.rx.RxSessionTermAnswerImpl)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1