Search in sources :

Example 6 with AccountingRequest

use of net.java.slee.resource.diameter.base.events.AccountingRequest in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method testGettersAndSettersACR.

@Test
public void testGettersAndSettersACR() throws Exception {
    AccountingRequest acr = messageFactory.createAccountingRequest();
    int nFailures = AvpAssistant.INSTANCE.testMethods(acr, AccountingRequest.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) Test(org.junit.Test)

Example 7 with AccountingRequest

use of net.java.slee.resource.diameter.base.events.AccountingRequest in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method testMessageCreationApplicationIdAvp.

@Test
public void testMessageCreationApplicationIdAvp() {
    // Relates to Issue #1555 (http://code.google.com/p/mobicents/issues/detail?id=1555)
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    try {
        long acctApplicationId = 23121L;
        DiameterAvp avpAcctApplicationId = avpFactory.createAvp(DiameterAvpCodes.ACCT_APPLICATION_ID, acctApplicationId);
        avps.add(avpAcctApplicationId);
        DiameterAvp[] avpArray = new DiameterAvp[avps.size()];
        avpArray = avps.toArray(avpArray);
        AccountingRequest acr = messageFactory.createAccountingRequest(avpArray);
        VendorSpecificApplicationIdAvp vsaidAvp = acr.getVendorSpecificApplicationId();
        assertNull("Vendor-Specific-Application-Id should not be present in message.", vsaidAvp);
        long msgAppId = acr.getAcctApplicationId();
        assertTrue("Acct-Application-Id should be [" + acctApplicationId + "] it is [" + msgAppId + "]", acctApplicationId == msgAppId);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getLocalizedMessage());
    }
}
Also used : VendorSpecificApplicationIdAvp(net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp) AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with AccountingRequest

use of net.java.slee.resource.diameter.base.events.AccountingRequest in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method isProxiableACR.

@Test
public void isProxiableACR() throws Exception {
    AccountingRequest acr = messageFactory.createAccountingRequest();
    assertTrue("The 'P' bit is not set by default in Accounting-Request, it should.", acr.getHeader().isProxiable());
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) Test(org.junit.Test)

Example 9 with AccountingRequest

use of net.java.slee.resource.diameter.base.events.AccountingRequest in project jain-slee.diameter by RestComm.

the class BaseFactoriesTest method isProxiableCopiedACA.

@Test
public void isProxiableCopiedACA() throws Exception {
    AccountingRequest acr = messageFactory.createAccountingRequest();
    acr.setSessionId("sssxxx");
    AccountingAnswer aca = messageFactory.createAccountingAnswer(acr);
    System.out.println(aca);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) acr).getGenericData().setProxiable(!acr.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Accounting-Request, it should.", acr.getHeader().isProxiable() != aca.getHeader().isProxiable());
    aca = messageFactory.createAccountingAnswer(acr);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) AccountingAnswer(net.java.slee.resource.diameter.base.events.AccountingAnswer) Test(org.junit.Test)

Example 10 with AccountingRequest

use of net.java.slee.resource.diameter.base.events.AccountingRequest in project jain-slee.diameter by RestComm.

the class AvpFlagsTest method testCorrectFlagsBaseExample.

@Test
public void testCorrectFlagsBaseExample() throws NoSuchAvpException {
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.SESSION_ID, "accesspoint7.acme.com;1876543210;523;mobile@200.1.1.88".getBytes()));
    DiameterAvp avpVendorId = baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_ID, 193);
    DiameterAvp avpAcctApplicationId = baseAvpFactory.createAvp(DiameterAvpCodes.ACCT_APPLICATION_ID, 19302);
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[] { avpVendorId, avpAcctApplicationId }));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_HOST, "127.0.0.1".getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_REALM, "mobicents.org".getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_HOST, ("127.0.0.1" + ":" + "3868").getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_REALM, "mobicents.org".getBytes()));
    // Subscription ID
    DiameterAvp subscriptionIdType = baseAvpFactory.createAvp(193, 555, 0);
    DiameterAvp subscriptionIdData = baseAvpFactory.createAvp(193, 554, "00001000");
    avps.add(baseAvpFactory.createAvp(193, 553, new DiameterAvp[] { subscriptionIdType, subscriptionIdData }));
    // Requested Service Unit
    DiameterAvp unitType = baseAvpFactory.createAvp(193, 611, 2);
    DiameterAvp valueDigits = baseAvpFactory.createAvp(193, 617, 10L);
    DiameterAvp unitValue = baseAvpFactory.createAvp(193, 612, new DiameterAvp[] { valueDigits });
    avps.add(baseAvpFactory.createAvp(193, 606, new DiameterAvp[] { unitType, unitValue }));
    // Record Number and Type
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_NUMBER, 0));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_TYPE, 1));
    // Requested action
    avps.add(baseAvpFactory.createAvp(193, 615, 0));
    // Service Parameter Type
    DiameterAvp serviceParameterType = baseAvpFactory.createAvp(193, 608, 0);
    DiameterAvp serviceParameterValue = baseAvpFactory.createAvp(193, 609, "510");
    avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType, serviceParameterValue }));
    // Service Parameter Type
    DiameterAvp serviceParameterType2 = baseAvpFactory.createAvp(193, 608, 14);
    DiameterAvp serviceParameterValue2 = baseAvpFactory.createAvp(193, 609, "20");
    avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType2, serviceParameterValue2 }));
    DiameterAvp[] avpArray = new DiameterAvp[avps.size()];
    avpArray = avps.toArray(avpArray);
    AccountingRequest acr = baseMessageFactory.createAccountingRequest();
    acr.setExtensionAvps(avpArray);
    ArrayList<String> failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().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());
    }
    // Test going through other way for adding avp's
    acr = baseMessageFactory.createAccountingRequest(avpArray);
    failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().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 : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) Test(org.junit.Test)

Aggregations

AccountingRequest (net.java.slee.resource.diameter.base.events.AccountingRequest)10 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)3 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)3 AccountingAnswer (net.java.slee.resource.diameter.base.events.AccountingAnswer)2 VendorSpecificApplicationIdAvp (net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp)2 ApplicationId (org.jdiameter.api.ApplicationId)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1