Search in sources :

Example 6 with PushProfileAnswer

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

the class CxDxFactoriesTest method testClientSessionApplicationIdChangePPA.

@Test
public void testClientSessionApplicationIdChangePPA() 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...
    PushProfileRequest ppr = cxdxMessageFactory.createPushProfileRequest();
    clientSession.fetchSessionData(ppr);
    PushProfileAnswer originalPPA = clientSession.createPushProfileAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPPA);
    // now we switch..
    originalPPA = null;
    isVendor = !isVendor;
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    PushProfileAnswer changedPPA = clientSession.createPushProfileAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPPA);
    // revert back to default
    ((CxDxMessageFactoryImpl) cxdxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) CxDxMessageFactoryImpl(org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl) ApplicationId(org.jdiameter.api.ApplicationId) PushProfileRequest(net.java.slee.resource.diameter.cxdx.events.PushProfileRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with PushProfileAnswer

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

the class CxDxFactoriesTest method testGettersAndSettersPPA.

@Test
public void testGettersAndSettersPPA() throws Exception {
    clientSession.fetchSessionData(cxdxMessageFactory.createPushProfileRequest());
    PushProfileAnswer ppa = clientSession.createPushProfileAnswer();
    int nFailures = CxDxAvpAssistant.INSTANCE.testMethods(ppa, PushProfileAnswer.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 8 with PushProfileAnswer

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

the class CxDxClientSessionImpl method sendPushProfileAnswer.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#sendPushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer)
   */
public void sendPushProfileAnswer(PushProfileAnswer pushProfileAnswer) throws IOException {
    try {
        DiameterMessageImpl msg = (DiameterMessageImpl) pushProfileAnswer;
        appSession.sendPushProfileAnswer(new JPushProfileAnswerImpl((Answer) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException anae) {
        throw new AvpNotAllowedException(anae.getMessage(), anae.getAvpCode(), anae.getVendorId());
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}
Also used : RegistrationTerminationAnswer(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer) Answer(org.jdiameter.api.Answer) PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) JPushProfileAnswerImpl(org.jdiameter.common.impl.app.cxdx.JPushProfileAnswerImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IOException(java.io.IOException)

Example 9 with PushProfileAnswer

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

the class CxDxFactoriesTest method hasDestinationHostPPA.

@Test
public void hasDestinationHostPPA() throws Exception {
    clientSession.fetchSessionData(cxdxMessageFactory.createPushProfileRequest());
    PushProfileAnswer ppa = clientSession.createPushProfileAnswer();
    assertNull("The Destination-Host and Destination-Realm AVPs MUST NOT be present in the answer message. [RFC3588/6.2]", ppa.getDestinationHost());
}
Also used : PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

PushProfileAnswer (net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer)9 Test (org.junit.Test)7 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)7 PushProfileRequest (net.java.slee.resource.diameter.cxdx.events.PushProfileRequest)4 InternalException (org.jdiameter.api.InternalException)2 IOException (java.io.IOException)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 RegistrationTerminationAnswer (net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer)1 Answer (org.jdiameter.api.Answer)1 ApplicationId (org.jdiameter.api.ApplicationId)1 JPushProfileAnswerImpl (org.jdiameter.common.impl.app.cxdx.JPushProfileAnswerImpl)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1 CxDxMessageFactoryImpl (org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl)1