Search in sources :

Example 1 with GxCreditControlAnswer

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

the class GxFactoriesTest method testGettersAndSettersCCA.

@Test
public void testGettersAndSettersCCA() throws Exception {
    GxCreditControlAnswer cca = gxServerSession.createGxCreditControlAnswer();
    int nFailures = GxAvpAssistant.INSTANCE.testMethods(cca, GxCreditControlAnswer.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : GxCreditControlAnswer(net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with GxCreditControlAnswer

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

the class GxFactoriesTest method testMessageFactoryApplicationIdChangeInServerSessionCCA.

@Test
public void testMessageFactoryApplicationIdChangeInServerSessionCCA() 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...
    GxCreditControlAnswer originalCCA = gxServerSession.createGxCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalCCA);
    // now we switch..
    originalCCA = null;
    isVendor = !isVendor;
    ((GxMessageFactoryImpl) gxMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    GxCreditControlAnswer changedCCA = gxServerSession.createGxCreditControlAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedCCA);
    // revert back to default
    ((GxMessageFactoryImpl) gxMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId) GxMessageFactoryImpl(org.mobicents.slee.resource.diameter.gx.GxMessageFactoryImpl) GxCreditControlAnswer(net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with GxCreditControlAnswer

use of net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer 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 4 with GxCreditControlAnswer

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

the class GxServerSessionActivityImpl method sendGxCreditControlAnswer.

/**
 * {@inheritDoc}
 */
@Override
public void sendGxCreditControlAnswer(final GxCreditControlAnswer cca) throws IOException {
    fetchCurrentState(cca);
    final DiameterMessageImpl msg = (DiameterMessageImpl) cca;
    try {
        session.sendCreditControlAnswer(new GxCreditControlAnswerImpl((Answer) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        final AvpNotAllowedException anae = new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
        throw anae;
    } catch (Exception e) {
        throw new IOException("Failed to send message.", e);
    }
}
Also used : GxCreditControlAnswer(net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer) Answer(org.jdiameter.api.Answer) GxCreditControlAnswerImpl(org.jdiameter.common.impl.app.gx.GxCreditControlAnswerImpl) 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) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 5 with GxCreditControlAnswer

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

the class GxFactoriesTest method hasDestinationHostCCA.

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

Aggregations

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