Search in sources :

Example 6 with ResetRequest

use of net.java.slee.resource.diameter.s6a.events.ResetRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testGettersAndSettersRSR.

@Test
public void testGettersAndSettersRSR() throws Exception {
    ResetRequest rsr = s6aMessageFactory.createResetRequest();
    int nFailures = S6aAvpAssistant.INSTANCE.testMethods(rsr, ResetRequest.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : ResetRequest(net.java.slee.resource.diameter.s6a.events.ResetRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with ResetRequest

use of net.java.slee.resource.diameter.s6a.events.ResetRequest in project jain-slee.diameter by RestComm.

the class S6aClientSessionImpl method createResetAnswer.

public ResetAnswer createResetAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof ResetRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        ResetAnswer rsa = (ResetAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, ResetAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(rsa);
        return rsa;
    } catch (InternalException e) {
        logger.error("Failed to create Reset-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ResetAnswer(net.java.slee.resource.diameter.s6a.events.ResetAnswer) ResetRequest(net.java.slee.resource.diameter.s6a.events.ResetRequest) InternalException(org.jdiameter.api.InternalException)

Example 8 with ResetRequest

use of net.java.slee.resource.diameter.s6a.events.ResetRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testMessageFactoryApplicationIdChangeRSR.

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

Example 9 with ResetRequest

use of net.java.slee.resource.diameter.s6a.events.ResetRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method isProxiableCopiedRSA.

@Test
public void isProxiableCopiedRSA() throws Exception {
    ResetRequest rsr = s6aMessageFactory.createResetRequest();
    clientSession.fetchSessionData(rsr);
    ResetAnswer rsa = clientSession.createResetAnswer();
    assertEquals("The 'P' bit is not copied from request in Location-Info-Answer, it should. [RFC3588/6.2]", rsr.getHeader().isProxiable(), rsa.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) rsr).getGenericData().setProxiable(!rsr.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Reset-Request, it should.", rsr.getHeader().isProxiable() != rsa.getHeader().isProxiable());
    clientSession.fetchSessionData(rsr);
    rsa = clientSession.createResetAnswer();
    assertEquals("The 'P' bit is not copied from request in Reset-Answer, it should. [RFC3588/6.2]", rsr.getHeader().isProxiable(), rsa.getHeader().isProxiable());
}
Also used : ResetAnswer(net.java.slee.resource.diameter.s6a.events.ResetAnswer) ResetRequest(net.java.slee.resource.diameter.s6a.events.ResetRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 10 with ResetRequest

use of net.java.slee.resource.diameter.s6a.events.ResetRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testGettersAndSettersRSA.

@Test
public void testGettersAndSettersRSA() throws Exception {
    ResetRequest rsr = s6aMessageFactory.createResetRequest();
    clientSession.fetchSessionData(rsr);
    ResetAnswer rsa = clientSession.createResetAnswer();
    int nFailures = S6aAvpAssistant.INSTANCE.testMethods(rsa, ResetAnswer.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : ResetAnswer(net.java.slee.resource.diameter.s6a.events.ResetAnswer) ResetRequest(net.java.slee.resource.diameter.s6a.events.ResetRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

ResetRequest (net.java.slee.resource.diameter.s6a.events.ResetRequest)13 Test (org.junit.Test)11 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)11 ResetAnswer (net.java.slee.resource.diameter.s6a.events.ResetAnswer)8 ApplicationId (org.jdiameter.api.ApplicationId)2 S6aMessageFactoryImpl (org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl)2 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 InternalException (org.jdiameter.api.InternalException)1