Search in sources :

Example 1 with MediaComponentDescriptionAvp

use of net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method testMediaComponentDescription.

@Test
public void testMediaComponentDescription() {
    AARequest aar = rxMessageFactory.createAARequest();
    MediaComponentDescriptionAvp mcdAvp = rxAvpFactory.createMediaComponentDescription();
    MediaSubComponentAvp mscAvp = rxAvpFactory.createMediaSubComponent();
    mscAvp.setFlowUsage(FlowUsage.AF_SIGNALLING);
    IPFilterRule fd1Avp = new IPFilterRule("permit in ip from 192.168.0.0/24 10,11,12,20-30 to 192.168.1.1 99 frag established");
    IPFilterRule fd2Avp = new IPFilterRule("permit out 2 from 192.1.0.0/24 to 192.1.1.1/0 frag established setup tcpoptions mrss");
    IPFilterRule fd3Avp = new IPFilterRule("permit out 4 from 10.0.1.91 4060 to 10.0.0.190 43772 ");
    mscAvp.setFlowDescriptions(new IPFilterRule[] { fd1Avp, fd2Avp, fd3Avp });
    mcdAvp.setMediaSubComponent(mscAvp);
    aar.setMediaComponentDescription(mcdAvp);
    // from Richard Good
    if (aar.hasMediaComponentDescription()) {
        System.err.println("Has media component description");
        MediaComponentDescriptionAvp[] mcd = aar.getMediaComponentDescriptions();
        if (mcd[0].hasMediaSubComponent()) {
            System.err.println("Has media sub component");
            MediaSubComponentAvp[] msc = mcd[0].getMediaSubComponents();
            if (msc[0].hasFlowUsage()) {
                System.err.println("Has flow usage");
            }
            System.err.println("msc[0] flow usage: " + msc[0].getFlowUsage());
            System.err.println("msc[0] flow usage value: " + msc[0].getFlowUsage().getValue());
            // other from Richarg Good
            IPFilterRule[] ipf = msc[0].getFlowDescriptions();
            System.err.println("msc[0] flow descriptions " + ipf.toString());
            System.err.println("msc[0] flow description length " + ipf.length);
            for (int b = 0; b < ipf.length; b++) {
                // THIS DOES NOT PRINT!
                System.err.println("msc[0] flow description " + ipf[b].toString());
            }
        }
    }
}
Also used : MediaComponentDescriptionAvp(net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp) IPFilterRule(net.java.slee.resource.diameter.base.events.avp.IPFilterRule) AARequest(net.java.slee.resource.diameter.rx.events.AARequest) MediaSubComponentAvp(net.java.slee.resource.diameter.rx.events.avp.MediaSubComponentAvp) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 2 with MediaComponentDescriptionAvp

use of net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp in project jain-slee.diameter by RestComm.

the class RxFactoriesTest method testAvpFactoryMediaComponentDescription.

@Test
public void testAvpFactoryMediaComponentDescription() throws Exception {
    String avpName = "Media-Component-Description";
    // Create AVP with mandatory values
    MediaComponentDescriptionAvp fgAvp1 = rxAvpFactory.createMediaComponentDescription();
    // Make sure it's not null
    Assert.assertNotNull("Created " + avpName + " AVP from objects should not be null.", fgAvp1);
    // Create AVP with default constructor
    MediaComponentDescriptionAvp fgAvp2 = rxAvpFactory.createMediaComponentDescription();
    // Should not contain mandatory values
    // Set mandatory values
    // Make sure it's equal to the one created with mandatory values constructor
    Assert.assertEquals("Created " + avpName + " AVP from default constructor + set<Mandatory-AVPs> should be equal to original.", fgAvp1, fgAvp2);
    // Make new copy
    fgAvp2 = rxAvpFactory.createMediaComponentDescription();
    // And set all values using setters
    RxAvpAssistant.INSTANCE.testSetters(fgAvp2);
    // Create empty...
    MediaComponentDescriptionAvp fgAvp3 = rxAvpFactory.createMediaComponentDescription();
    // Verify that no values have been set
    RxAvpAssistant.INSTANCE.testHassers(fgAvp3, false);
    // Set all previous values
    fgAvp3.setExtensionAvps(fgAvp2.getExtensionAvps());
    // Verify if values have been set
    RxAvpAssistant.INSTANCE.testHassers(fgAvp3, true);
    // Verify if values have been correctly set
    RxAvpAssistant.INSTANCE.testGetters(fgAvp3);
    // Make sure they match!
    Assert.assertEquals("Created " + avpName + " AVP from default constructor + setExtensionAvps should be equal to original.", fgAvp2, fgAvp3);
}
Also used : MediaComponentDescriptionAvp(net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

MediaComponentDescriptionAvp (net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp)2 Test (org.junit.Test)2 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)2 IPFilterRule (net.java.slee.resource.diameter.base.events.avp.IPFilterRule)1 AARequest (net.java.slee.resource.diameter.rx.events.AARequest)1 MediaSubComponentAvp (net.java.slee.resource.diameter.rx.events.avp.MediaSubComponentAvp)1