Search in sources :

Example 6 with ServerAssignmentRequest

use of net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest in project jain-slee.diameter by RestComm.

the class CxDxServerSessionImpl method createServerAssignmentAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createServerAssignmentAnswer()
   */
public ServerAssignmentAnswer createServerAssignmentAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof ServerAssignmentRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        ServerAssignmentAnswer saa = (ServerAssignmentAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, ServerAssignmentAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(saa);
        return saa;
    } catch (InternalException e) {
        logger.error("Failed to create Server-Assignment-Answer.", e);
    }
    return null;
}
Also used : ServerAssignmentRequest(net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ServerAssignmentAnswer(net.java.slee.resource.diameter.cxdx.events.ServerAssignmentAnswer) InternalException(org.jdiameter.api.InternalException)

Example 7 with ServerAssignmentRequest

use of net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method testClientSessionApplicationIdChangeSAR.

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

Example 8 with ServerAssignmentRequest

use of net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method testServerSessionApplicationIdChangeSAA.

@Test
public void testServerSessionApplicationIdChangeSAA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((CxDxMessageFactoryImpl) cxdxMessageFactory).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 CxDx is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    ServerAssignmentRequest sar = cxdxMessageFactory.createServerAssignmentRequest();
    serverSession.fetchSessionData(sar);
    ServerAssignmentAnswer originalSAA = serverSession.createServerAssignmentAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalSAA);
    // now we switch..
    originalSAA = null;
    isVendor = !isVendor;
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    ServerAssignmentAnswer changedSAA = serverSession.createServerAssignmentAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedSAA);
    // revert back to default
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ServerAssignmentRequest(net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest) CxDxMessageFactoryImpl(org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) ServerAssignmentAnswer(net.java.slee.resource.diameter.cxdx.events.ServerAssignmentAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 9 with ServerAssignmentRequest

use of net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method isRequestSAR.

@Test
public void isRequestSAR() throws Exception {
    ServerAssignmentRequest sar = cxdxMessageFactory.createServerAssignmentRequest();
    assertTrue("Request Flag in Server-Assignment-Request is not set.", sar.getHeader().isRequest());
}
Also used : ServerAssignmentRequest(net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 10 with ServerAssignmentRequest

use of net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest in project jain-slee.diameter by RestComm.

the class CxDxFactoriesTest method testMessageFactoryApplicationIdChangeSAR.

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

Aggregations

ServerAssignmentRequest (net.java.slee.resource.diameter.cxdx.events.ServerAssignmentRequest)11 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 ServerAssignmentAnswer (net.java.slee.resource.diameter.cxdx.events.ServerAssignmentAnswer)4 ApplicationId (org.jdiameter.api.ApplicationId)3 CxDxMessageFactoryImpl (org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl)3 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 InternalException (org.jdiameter.api.InternalException)1