Search in sources :

Example 6 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxFactoriesTest method GxApplicationIdCCR.

@Test
public void GxApplicationIdCCR() throws Exception {
    GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
    assertTrue("Auth-Application-Id AVP in Gx CCR must be 16777224, it is " + ccr.getAuthApplicationId(), ccr.getAuthApplicationId() == 16777224);
}
Also used : GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxFactoriesTest method testMessageFactoryApplicationIdChangeCCR.

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

Example 8 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class AvpFlagsTest method testCorrectFlagsSupportedFeatures.

@Test
public void testCorrectFlagsSupportedFeatures() {
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    DiameterAvp avpFeatureListID = AvpUtilities.createAvp(Avp.FEATURE_LIST_ID, TGPP_VENDOR_ID, 1);
    avps.add(AvpUtilities.createAvp(Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, new DiameterAvp[] { avpFeatureListID }));
    GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
    GxCreditControlAnswer cca = gxMessageFactory.createGxCreditControlAnswer(ccr);
    cca.setExtensionAvps(avps.toArray(avps.toArray(new DiameterAvp[avps.size()])));
    Message msg = ((DiameterMessageImpl) cca).getGenericData();
    AvpUtilities.addAvp(msg, Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, msg.getAvps(), new DiameterAvp[] { avpFeatureListID });
    // Attribute Name AVP Code Section Value Type Must May Should not Must not May Encr.
    // Supported-Features 628 6.3.29 Grouped V M - - - No
    ArrayList<String> failures = checkAvpFlags(msg.getAvps());
    if (failures.size() > 0) {
        System.err.println("The following AVPs flags have failed to check against dictionary:");
        for (String failure : failures) {
            System.err.println(failure);
        }
        Assert.fail(failures.toString());
    }
}
Also used : Message(org.jdiameter.api.Message) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) GxCreditControlAnswer(net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) Test(org.junit.Test)

Example 9 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxClientSessionActivityImpl method sendTerminationGxCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diametergx.GxClientSessionActivity#sendTerminationRoCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)
   */
public void sendTerminationGxCreditControlRequest(final GxCreditControlRequest ccr) throws IOException {
    // This should not be used to terminate sub-sessions!
    validateState(ccr);
    final DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new GxCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Request(org.jdiameter.api.Request) GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) GxReAuthRequest(net.java.slee.resource.diameter.gx.events.GxReAuthRequest) GxCreditControlRequestImpl(org.jdiameter.common.impl.app.gx.GxCreditControlRequestImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 10 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxClientSessionActivityImpl method sendInitialGxCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diametergx.GxClientSessionActivity#sendInitialRoCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)
   */
public void sendInitialGxCreditControlRequest(final GxCreditControlRequest ccr) throws IOException {
    // FIXME: should this affect FSM ?
    validateState(ccr);
    final DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new GxCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Request(org.jdiameter.api.Request) GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) GxReAuthRequest(net.java.slee.resource.diameter.gx.events.GxReAuthRequest) GxCreditControlRequestImpl(org.jdiameter.common.impl.app.gx.GxCreditControlRequestImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Aggregations

GxCreditControlRequest (net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)16 Test (org.junit.Test)10 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)9 GxReAuthRequest (net.java.slee.resource.diameter.gx.events.GxReAuthRequest)5 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)5 IOException (java.io.IOException)4 DiameterException (net.java.slee.resource.diameter.base.DiameterException)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)4 Request (org.jdiameter.api.Request)4 GxCreditControlRequestImpl (org.jdiameter.common.impl.app.gx.GxCreditControlRequestImpl)4 GxCreditControlAnswer (net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer)3 ApplicationId (org.jdiameter.api.ApplicationId)3 GxMessageFactoryImpl (org.mobicents.slee.resource.diameter.gx.GxMessageFactoryImpl)3 GxServerSessionActivityImpl (org.mobicents.slee.resource.diameter.gx.GxServerSessionActivityImpl)2 ArrayList (java.util.ArrayList)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 Message (org.jdiameter.api.Message)1