Search in sources :

Example 1 with MediaSubComponentAvp

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

the class RxFactoriesTest method testAvpFactoryMediaSubComponent.

// Commented out since Gx has different definition.
@Test
public void testAvpFactoryMediaSubComponent() throws Exception {
    String avpName = "Media-Sub-Component";
    // Create AVP with mandatory values
    MediaSubComponentAvp mscAvp1 = rxAvpFactory.createMediaSubComponent();
    // Make sure it's not null
    Assert.assertNotNull("Created " + avpName + " AVP from objects should not be null.", mscAvp1);
    // Create AVP with default constructor
    MediaSubComponentAvp mscAvp2 = rxAvpFactory.createMediaSubComponent();
    // 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.", mscAvp1, mscAvp2);
    // Make new copy
    mscAvp2 = rxAvpFactory.createMediaSubComponent();
    // And set all values using setters
    RxAvpAssistant.INSTANCE.testSetters(mscAvp2);
    // Create empty...
    MediaSubComponentAvp mscAvp3 = rxAvpFactory.createMediaSubComponent();
    // Verify that no values have been set
    RxAvpAssistant.INSTANCE.testHassers(mscAvp3, false);
    // Set all previous values
    mscAvp3.setExtensionAvps(mscAvp2.getExtensionAvps());
    // Verify if values have been set
    RxAvpAssistant.INSTANCE.testHassers(mscAvp3, true);
    // Verify if values have been correctly set
    RxAvpAssistant.INSTANCE.testGetters(mscAvp3);
    // Make sure they match!
    Assert.assertEquals("Created " + avpName + " AVP from default constructor + setExtensionAvps should be equal to original.", mscAvp2, mscAvp3);
}
Also used : 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 MediaSubComponentAvp

use of net.java.slee.resource.diameter.rx.events.avp.MediaSubComponentAvp 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)

Aggregations

MediaSubComponentAvp (net.java.slee.resource.diameter.rx.events.avp.MediaSubComponentAvp)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 MediaComponentDescriptionAvp (net.java.slee.resource.diameter.rx.events.avp.MediaComponentDescriptionAvp)1