Revision: 15523
Author: brainslog
Date: Fri Nov 26 19:17:07 2010
Log: Fixing Testsuite for new Dictionary/Validator changes.
Update Issue #1963
Committed Testsuite fixes. Still some tests failing, Bartosz please have a
look.
http://code.google.com/p/mobicents/source/detail?r=15523
Modified:
/trunk/servers/diameter/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/AvpUtilitiesTest.java
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/MessageValidatorTest.java
=======================================
---
/trunk/servers/diameter/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
Fri Nov 26 03:59:43 2010
+++
/trunk/servers/diameter/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java
Fri Nov 26 19:17:07 2010
@@ -251,7 +251,7 @@
this.enabled = enabled;
}
- void setConfigured(boolean configured) {
+ public void setConfigured(boolean configured) {
this.configured = configured;
}
=======================================
---
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/AvpUtilitiesTest.java
Wed Oct 20 16:01:00 2010
+++
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/AvpUtilitiesTest.java
Fri Nov 26 19:17:07 2010
@@ -5,6 +5,7 @@
import static org.junit.Assert.fail;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -19,9 +20,9 @@
import org.jdiameter.api.RouteException;
import org.jdiameter.api.Session;
import org.jdiameter.api.Stack;
+import org.jdiameter.api.validation.Dictionary;
+import org.jdiameter.client.impl.DictionarySingleton;
import org.jdiameter.client.impl.helpers.EmptyConfiguration;
-import org.jdiameter.common.impl.validation.DiameterMessageValidator;
-import org.jdiameter.common.impl.validation.JAvpNotAllowedException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -52,7 +53,7 @@
private static DiameterMessageFactoryImpl baseFactory;
- private DiameterMessageValidator instance = null;
+ private Dictionary instance = null;
private static Stack stack = null;
private static Stack serverStack = null;
private final static String validatorOnFile = "dictionary.xml";
@@ -61,7 +62,11 @@
static {
stack = new org.jdiameter.client.impl.StackImpl();
serverStack = new org.jdiameter.client.impl.StackImpl();
+ InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream(validatorOnFile);
try {
+
+
+
MyConfigurationClient clientConf= new MyConfigurationClient();
MyConfigurationServer serverConf = new MyConfigurationServer();
@@ -73,18 +78,31 @@
System.out.println("[CLIENT] Configured. Starting ...");
stack.init(clientConf);
+ //conf dict, after stack.
+ DictionarySingleton.getDictionary().configure(is);
stack.start(Mode.ANY_PEER, 5000, TimeUnit.MILLISECONDS);
System.out.println("[CLIENT] Started");
}
catch (Exception e) {
throw new RuntimeException("Failed to initialize the stack.", e);
+ }finally
+ {
+ if(is!=null)
+ {
+ try{
+ is.close();
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
}
baseFactory = new DiameterMessageFactoryImpl(stack);
// DiameterAvpFactoryImpl baseAvpFactory = new
DiameterAvpFactoryImpl();
try {
-
AvpDictionary.INSTANCE.parseDictionary(AvpUtilitiesTest.class.getClassLoader().getResourceAsStream("dictionary.xml"));
+
AvpDictionary.INSTANCE.parseDictionary(AvpUtilitiesTest.class.getClassLoader().getResourceAsStream(validatorOnFile));
}
catch (Exception e) {
throw new RuntimeException("Failed to parse dictionary file.");
@@ -93,7 +111,7 @@
@Before
public void setUp() {
- this.instance = DiameterMessageValidator.getInstance();
+ this.instance = DictionarySingleton.getDictionary();
}
@After
@@ -104,7 +122,9 @@
@Test
public void testOperationsAddWithValidatorOnAndRemovalAllowed() {
AvpUtilities.allowRemove(true);
-
instance.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream(validatorOnFile),
true);
+
instance.configure(this.getClass().getClassLoader().getResourceAsStream(validatorOnFile));
+ instance.setEnabled(true);
+
// It has session id
AccountingRequestImpl request = (AccountingRequestImpl)
baseFactory.createAccountingRequest();
@@ -134,7 +154,7 @@
System.out.println(request);
fail("Should not send this message. Message MUST contain
Accounting-Record-Number AVP (485), and it is not present.");
}
- catch (JAvpNotAllowedException e) {
+ catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
if (e.getAvpCode() != 485 && e.getVendorId() != 0) {
fail("Message Validation failed with wrong AVP Code/Vendor-Id in
Exception. Expected (485:0), Received (" + e.getAvpCode() + ":" +
e.getVendorId() + ").");
}
@@ -144,9 +164,9 @@
boolean wasAvpNotAllowed = false;
while((cause = cause.getCause()) != null) {
- if(cause instanceof JAvpNotAllowedException) {
+ if(cause instanceof
org.jdiameter.api.validation.AvpNotAllowedException) {
wasAvpNotAllowed = true;
- JAvpNotAllowedException exc = (JAvpNotAllowedException)cause;
+ org.jdiameter.api.validation.AvpNotAllowedException exc =
(org.jdiameter.api.validation.AvpNotAllowedException)cause;
if (exc.getAvpCode() != 485 && exc.getVendorId() != 0) {
fail("Message Validation failed with wrong AVP Code/Vendor-Id
in Exception. Expected (485:0), Received (" + exc.getAvpCode() + ":" +
exc.getVendorId() + ").");
}
@@ -239,7 +259,10 @@
@Test
public void testOperationsAddWithValidatorOnAndRemovalNotAllowed() {
AvpUtilities.allowRemove(false);
-
instance.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream(validatorOnFile),
true);
+
+
instance.configure(this.getClass().getClassLoader().getResourceAsStream(validatorOnFile));
+ instance.setEnabled(true);
+
// It has session id
AccountingRequestImpl request = (AccountingRequestImpl)
baseFactory.createAccountingRequest(new DiameterAvpImpl[]{new
DiameterAvpImpl(263, 0L, 0, 1, "xxx".getBytes(),
DiameterAvpType.UTF8_STRING)});
@@ -280,7 +303,7 @@
fail("Should not send this message. Message MUST contain
Accounting-Record-Number AVP (485), and it is not present.");
}
- catch (JAvpNotAllowedException e) {
+ catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
if (e.getAvpCode() != 485 && e.getVendorId() != 0) {
fail("Message Validation failed with wrong AVP Code/Vendor-Id in
Exception. Expected (485:0), Received (" + e.getAvpCode() + ":" +
e.getVendorId() + ").");
}
@@ -290,9 +313,9 @@
boolean wasAvpNotAllowed = false;
while((cause = cause.getCause()) != null) {
- if(cause instanceof JAvpNotAllowedException) {
+ if(cause instanceof
org.jdiameter.api.validation.AvpNotAllowedException) {
wasAvpNotAllowed = true;
- JAvpNotAllowedException exc = (JAvpNotAllowedException)cause;
+ org.jdiameter.api.validation.AvpNotAllowedException exc =
(org.jdiameter.api.validation.AvpNotAllowedException)cause;
if (exc.getAvpCode() != 485 && exc.getVendorId() != 0) {
fail("Message Validation failed with wrong AVP Code/Vendor-Id
in Exception. Expected (485:0), Received (" + exc.getAvpCode() + ":" +
exc.getVendorId() + ").");
}
@@ -394,8 +417,8 @@
@Test
public void testOperationsAddWithValidatorOffAndRemovalAllowed() {
AvpUtilities.allowRemove(true);
-
instance.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream(validatorOffFile),
true);
-
+
instance.configure(this.getClass().getClassLoader().getResourceAsStream(validatorOffFile));
+ instance.setEnabled(false);
// It has session id
AccountingRequestImpl request = (AccountingRequestImpl)
baseFactory.createAccountingRequest(new DiameterAvpImpl[]{new
DiameterAvpImpl(263, 0L, 0, 1, "xxx".getBytes(),
DiameterAvpType.UTF8_STRING)});
=======================================
---
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/MessageValidatorTest.java
Wed Aug 25 15:18:32 2010
+++
/trunk/servers/diameter/testsuite/tests/src/test/java/org/mobicents/slee/resources/diameter/tests/framework/validator/MessageValidatorTest.java
Fri Nov 26 19:17:07 2010
@@ -25,49 +25,23 @@
*/
package org.mobicents.slee.resources.diameter.tests.framework.validator;
-import static org.jdiameter.client.impl.helpers.Parameters.AcctApplId;
-import static org.jdiameter.client.impl.helpers.Parameters.ApplicationId;
-import static org.jdiameter.client.impl.helpers.Parameters.Assembler;
-import static org.jdiameter.client.impl.helpers.Parameters.AuthApplId;
-import static org.jdiameter.client.impl.helpers.Parameters.OwnDiameterURI;
-import static org.jdiameter.client.impl.helpers.Parameters.OwnRealm;
-import static org.jdiameter.client.impl.helpers.Parameters.OwnVendorID;
-import static org.jdiameter.client.impl.helpers.Parameters.PeerName;
-import static org.jdiameter.client.impl.helpers.Parameters.PeerRating;
-import static org.jdiameter.client.impl.helpers.Parameters.PeerTable;
-import static org.jdiameter.client.impl.helpers.Parameters.RealmEntry;
-import static org.jdiameter.client.impl.helpers.Parameters.RealmTable;
-import static org.jdiameter.client.impl.helpers.Parameters.VendorId;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import net.java.slee.resource.diameter.base.events.AccountingAnswer;
-import net.java.slee.resource.diameter.base.events.AccountingRequest;
-import net.java.slee.resource.diameter.base.events.avp.DiameterAvpType;
-import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;
-import net.java.slee.resource.diameter.cca.events.avp.CcMoneyAvp;
-import net.java.slee.resource.diameter.cca.events.avp.CcRequestType;
-import
net.java.slee.resource.diameter.cca.events.avp.GrantedServiceUnitAvp;
-import net.java.slee.resource.diameter.cca.events.avp.UnitValueAvp;
-
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jdiameter.api.AvpDataException;
import org.jdiameter.api.AvpSet;
-import org.jdiameter.api.IllegalDiameterStateException;
-import org.jdiameter.api.InternalException;
-import org.jdiameter.api.Stack;
-import org.jdiameter.client.impl.helpers.EmptyConfiguration;
-import org.jdiameter.common.impl.validation.DiameterMessageValidator;
-import org.jdiameter.common.impl.validation.JAvpNotAllowedException;
+import org.jdiameter.api.Message;
+import org.jdiameter.api.validation.AvpNotAllowedException;
+import org.jdiameter.api.validation.MessageRepresentation;
+import org.jdiameter.api.validation.ValidatorLevel;
+import org.jdiameter.client.impl.parser.MessageParser;
+import org.jdiameter.common.impl.validation.DictionaryImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mobicents.diameter.dictionary.AvpDictionary;
-import org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl;
-import
org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl;
-import
org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl;
-import
org.mobicents.slee.resource.diameter.base.events.avp.DiameterAvpImpl;
-import
org.mobicents.slee.resource.diameter.cca.CreditControlAVPFactoryImpl;
-import
org.mobicents.slee.resource.diameter.cca.CreditControlMessageFactoryImpl;
-import
org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl;
/**
* Start time:14:15:19 2009-05-27<br>
@@ -76,349 +50,1007 @@
* @author <a href="mailto:[email protected]"> Bartosz Baranowski </a>
* @author <a href="mailto:[email protected]"> Alexandre Mendonca </a>
*/
-public class MessageValidatorTest {
-
- private static String clientHost = "127.0.0.1";
- private static String clientPort = "21812";
- private static String clientURI = "aaa://" + clientHost + ":" +
clientPort;
-
- private static String serverHost = "localhost";
- private static String serverPort = "21812";
- private static String serverURI = "aaa://" + serverHost + ":" +
serverPort;
-
- private static String realmName = "mobicents.org";
-
- private static DiameterMessageFactoryImpl baseFactory;
- private static CreditControlMessageFactoryImpl ccaFactory;
- private DiameterMessageValidator instance = null;
-
- @Before
- public void setUp() {
- this.instance = DiameterMessageValidator.getInstance();
- }
-
- @After
- public void tearDown() {
- this.instance = null;
- }
-
- @Test
- public void testBasicOperations() {
- // Yeah, its awkward :) - it already should have session id.
- DiameterAvpImpl sessionIdAvp = new DiameterAvpImpl(263, 0L, 0,
1, "xxx".getBytes(), DiameterAvpType.UTF8_STRING);
- AccountingRequest request = baseFactory.createAccountingRequest(new
DiameterAvpImpl[] { sessionIdAvp });
- AccountingAnswerImpl answer = (AccountingAnswerImpl)
baseFactory.createAccountingAnswer(request);
-
- AvpSet set = answer.getGenericData().getAvps();
-
- // nooooow, lets try some tests
-
- // <avp name="Session-Id" code="263" vendor="0" multiplicity="1"
index="0"/>
- assertTrue("Session-Id is not allowed in this message, it should be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 263, 0));
-
- if (answer.hasSessionId()) {
- assertFalse("We should not allow to add more SessionIds than one,
operation indicates that it could be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 263, 0L));
- }
- else {
- assertTrue("We should allow to add ONE (1) Session-Id AVP, operation
indicates that it could not be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 263, 0L));
- }
-
- // <avp name="Origin-Host" code="264" vendor="0" multiplicity="1"
index="-1"/>
- assertTrue("Origin-Host is not allowed in this message, it should be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 264, 0));
- if (answer.hasOriginHost()) {
- assertFalse("We should allow to add more Origin-Host than zero,
operation indicates that it could not be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 264, 0L));
- }
- else {
- assertTrue("We should not allow to add more than one Origin-Host,
operation indicates that it could be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 264, 0L));
- }
-
- // <avp name="Event-Timestamp" code="55" vendor="0" multiplicity="0-1"
- // index="-1"/>
- assertTrue("Event-Timestamp is not allowed in this message, it should
be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 55, 0));
- assertTrue("We should allow to add more Event-Timestamp than zero,
operation indicates that it could not be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 55, 0L));
-
- set.addAvp(55, 55L, 0L, true, false);
- assertFalse("We should not allow to add more Event-Timestamp than one,
operation indicates that it could be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 55, 0L));
-
- // <avp name="Proxy-Info" code="284" vendor="0" multiplicity="0+"
- // index="-1"/>
- assertTrue("Proxy-Info is not allowed in this message, it should be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 284, 0));
- assertTrue("We should allow to add more Proxy-Info than zero,
operation indicates that it could not note be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 284, 0L));
-
- set.addAvp(284, 284L, 0L, true, false);
-
- assertTrue("We should allow to add more Proxy-Info than one,
operation indicates that it could note be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 284, 0L));
-
- set.addAvp(284, 284L, 0L, true, false);
- assertTrue("We should allow to add more Proxy-Info than two,
operation indicates that it could note be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 284, 0L));
-
- // <!-- FORBBIDEN -->
- // <avp name="Auth-Application-Id" code="258" vendor="0"
multiplicity="0" index="-1"/>
- assertFalse("Auth-Application-Id is allowed in this message, it
should not be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 258, 0));
- assertFalse("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 258, 0L));
-
- // <avp name="Destination-Realm" code="283" vendor="0"
multiplicity="0" index="-1"/>
- assertFalse("Auth-Application-Id is allowed in this message, it
should not be.",
- this.instance.isAllowed(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, 258, 0));
- assertFalse("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
-
this.instance.isCountValidForMultiplicity(AccountingAnswer.commandCode,
answer.getHeader().getApplicationId(), false, set, 258, 0L));
- }
-
- @Test
- public void testGroupedAvpValidationFail() {
- // Yeah, its awkward :) - it already should have session id.
- CreditControlAnswerImpl answer = (CreditControlAnswerImpl)
ccaFactory.createCreditControlAnswer(ccaFactory.createCreditControlRequest("xxxxxxxxxxxx"));
- DiameterMessageValidator instance =
DiameterMessageValidator.getInstance();
- /*AvpSet set = */answer.getGenericData().getAvps();
-
- // nooooow, lets try some tests
- // we should test grouped AVPs bad behavior.
- // Must
- // avp name="Auth-Application-Id" code="258" vendor="0"
multiplicity="1" index="-1" />
-
- // This is set by factory.
- // answer.setAuthApplicationId(5);
- // <avp name="CC-Request-Number" code="415" vendor="0"
multiplicity="1" index="-1" />
-
- // <avp name="Origin-Realm" code="296" vendor="0" multiplicity="1"
index="-1" />
- if (!answer.hasOriginRealm()) {
- answer.setOriginRealm(new DiameterIdentity("aaa://mobicents.org"));
- }
- // <avp name="Result-Code" code="268" vendor="0" multiplicity="1"
index="-1" />
- answer.setResultCode(2066);
- // <avp name="Session-Id" code="263" vendor="0" multiplicity="1"
index="0" />
- // should be there
-
- // MAY, but we add this, since its multi grouped avp
- // <avp name="Granted-Service-Unit" code="431" vendor="0"
multiplicity="0-1" index="-1" />
-
- // here we should fail.
- try {
- instance.validate(answer.getGenericData(), false);
- fail("Validation of message should fails: " + answer);
- }
- catch (JAvpNotAllowedException ex) {
- // we are ok,
- // ex.printStackTrace();
- }
- answer.setCcRequestNumber(1);
- // <avp name="CC-Request-Type" code="416" vendor="0" multiplicity="1"
index="-1" />
- answer.setCcRequestType(CcRequestType.EVENT_REQUEST);
- // <avp name="Origin-Host" code="264" vendor="0" multiplicity="1"
index="-1" />
- if (!answer.hasOriginHost()) {
- answer.setOriginHost(new DiameterIdentity("aaa://127.0.0.1:1818"));
- }
-
- // here we should not fail.
- try {
- instance.validate(answer.getGenericData(), false);
-
- }
- catch (JAvpNotAllowedException ex) {
- ex.printStackTrace();
- fail("Validation of message should not fails: " + answer);
- return;
- }
- // MAY - but we will add this, since its multi gropued avp.
- // <avp name="Granted-Service-Unit" code="431" vendor="0"
multiplicity="0-1" index="-1" />
- CreditControlAVPFactoryImpl ccaAvpFactory = new
CreditControlAVPFactoryImpl(new DiameterAvpFactoryImpl());
- GrantedServiceUnitAvp gsuAVP =
ccaAvpFactory.createGrantedServiceUnit();
-
- // <avp name="Granted-Service-Unit" code="431" mandatory="must"
vendor-bit="mustnot" vendor-id="None" may-encrypt="yes" protected="may">
- // <grouped>
- // <gavp name="Tariff-Time-Change" multiplicity="0-1"/>
- // <gavp name="CC-Time" multiplicity="0-1"/>
- // <gavp name="CC-Money" multiplicity="0-1"/>
- // <gavp name="CC-Total-Octets" multiplicity="0-1"/>
- // <gavp name="CC-Input-Octets" multiplicity="0-1"/>
- // <gavp name="CC-Output-Octets" multiplicity="0-1"/>
- // <gavp name="Cost-Unit" multiplicity="0-1"/>
- // </grouped>
- // </avp>
- // However CC-Money has mandatory field, which should be present -
Unit-Value, which is grouped avp which also has mandatory Value-Digits
- gsuAVP.setCreditControlInputOctets(8);
- UnitValueAvp unitValue = ccaAvpFactory.createUnitValue();
- unitValue.setExponent(12);
- CcMoneyAvp ccMoney = ccaAvpFactory.createCcMoney(unitValue);
- ccMoney.setCurrencyCode(1);
- gsuAVP.setCreditControlMoneyAvp(ccMoney);
-
- // this avp is bad, unit value does not have defined all fields.
- answer.setGrantedServiceUnit(gsuAVP);
-
- try {
- instance.validate(answer.getGenericData(), false);
- fail("Validation of message should fails: " + answer);
- }
- catch (JAvpNotAllowedException ex) {
- // we are ok,
- // ex.printStackTrace();
- }
- }
-
- @Test
- public void testGroupedAvpValidationSuccess() {
- // Yeah, its awkward :) - it already should have session id.
- CreditControlAnswerImpl answer = (CreditControlAnswerImpl)
ccaFactory.createCreditControlAnswer(ccaFactory.createCreditControlRequest("xxxxxxxxxxxx"));
- DiameterMessageValidator instance =
DiameterMessageValidator.getInstance();
- /*AvpSet set = */answer.getGenericData().getAvps();
-
- // nooooow, lets try some tests
- // we should test grouped AVPs bad behavior.
- // Must
- // avp name="Auth-Application-Id" code="258" vendor="0"
multiplicity="1" index="-1" />
-
- // This is set by factory.
- // answer.setAuthApplicationId(5);
- // <avp name="CC-Request-Number" code="415" vendor="0"
multiplicity="1" index="-1" />
-
- // <avp name="Origin-Realm" code="296" vendor="0" multiplicity="1"
index="-1" />
- if (!answer.hasOriginRealm()) {
- answer.setOriginRealm(new DiameterIdentity("aaa://mobicents.org"));
- }
- // <avp name="Result-Code" code="268" vendor="0" multiplicity="1"
index="-1" />
- answer.setResultCode(2066);
- // <avp name="Session-Id" code="263" vendor="0" multiplicity="1"
index="0" />
- // should be there
-
- // MAY, but we add this, since its multi grouped avp
- // <avp name="Granted-Service-Unit" code="431" vendor="0"
multiplicity="0-1" index="-1" />
-
- // here we should fail.
- try {
- instance.validate(answer.getGenericData(), false);
- fail("Validation of message should fails: " + answer);
- }
- catch (JAvpNotAllowedException ex) {
- // we are ok,
- // ex.printStackTrace();
- }
- answer.setCcRequestNumber(1);
- // <avp name="CC-Request-Type" code="416" vendor="0" multiplicity="1"
- // index="-1" />
- answer.setCcRequestType(CcRequestType.EVENT_REQUEST);
- // <avp name="Origin-Host" code="264" vendor="0" multiplicity="1"
- // index="-1" />
- if (!answer.hasOriginHost()) {
- answer.setOriginHost(new DiameterIdentity("aaa://127.0.0.1:1818"));
- }
-
- // here we should not fail.
- try {
- instance.validate(answer.getGenericData(), false);
- }
- catch (JAvpNotAllowedException ex) {
- ex.printStackTrace();
- fail("Validation of message should not fails: " + answer);
- return;
- }
- // MAY - but we will add this, since its multi gropued avp.
- // <avp name="Granted-Service-Unit" code="431" vendor="0"
multiplicity="0-1" index="-1" />
- CreditControlAVPFactoryImpl ccaAvpFactory = new
CreditControlAVPFactoryImpl(new DiameterAvpFactoryImpl());
- GrantedServiceUnitAvp gsuAVP =
ccaAvpFactory.createGrantedServiceUnit();
-
- // <avp name="Granted-Service-Unit" code="431" mandatory="must"
vendor-bit="mustnot" vendor-id="None" may-encrypt="yes" protected="may">
- // <grouped>
- // <gavp name="Tariff-Time-Change" multiplicity="0-1"/>
- // <gavp name="CC-Time" multiplicity="0-1"/>
- // <gavp name="CC-Money" multiplicity="0-1"/>
- // <gavp name="CC-Total-Octets" multiplicity="0-1"/>
- // <gavp name="CC-Input-Octets" multiplicity="0-1"/>
- // <gavp name="CC-Output-Octets" multiplicity="0-1"/>
- // <gavp name="Cost-Unit" multiplicity="0-1"/>
- // </grouped>
- // </avp>
- // However CC-Money has mandatory field, which should be present -
Unit-Value, which is grouped avp which also has mandatory
- // Value-Digits
- gsuAVP.setCreditControlInputOctets(8);
- UnitValueAvp unitValue = ccaAvpFactory.createUnitValue();
- unitValue.setExponent(12);
- CcMoneyAvp ccMoney = ccaAvpFactory.createCcMoney(unitValue);
- ccMoney.setCurrencyCode(1);
- gsuAVP.setCreditControlMoneyAvp(ccMoney);
-
- // this avp is bad, unit value does not have defined all fields.
- answer.setGrantedServiceUnit(gsuAVP);
-
- try {
- instance.validate(answer.getGenericData(), false);
- fail("Validation of message should fails: " + answer);
- }
- catch (JAvpNotAllowedException ex) {
- // we are ok,
- // ex.printStackTrace();
- }
- }
-
- static {
- Stack stack = new org.jdiameter.client.impl.StackImpl();
- try {
- stack.init(new MyConfiguration());
- }
- catch (Exception e) {
- throw new RuntimeException("Failed to initialize the stack.");
- }
-
- baseFactory = new DiameterMessageFactoryImpl(stack);
- // DiameterAvpFactoryImpl baseAvpFactory = new
DiameterAvpFactoryImpl();
- try {
- ccaFactory = new CreditControlMessageFactoryImpl(baseFactory,
stack.getSessionFactory().getNewSession(), stack, new
CreditControlAVPFactoryImpl(new DiameterAvpFactoryImpl()));
- }
- catch (InternalException ie) {
- throw new RuntimeException("Failed to create new sesson from session
factory.", ie);
- }
- catch (IllegalDiameterStateException idse) {
- throw new RuntimeException("Failed to get sesson factory from
stack.", idse);
- }
- try {
-
AvpDictionary.INSTANCE.parseDictionary(MessageValidatorTest.class.getClassLoader().getResourceAsStream("dictionary.xml"));
- }
- catch (Exception e) {
- throw new RuntimeException("Failed to parse dictionary file.", e);
- }
- }
-
- /**
- * Class representing the Diameter Configuration
- */
- public static class MyConfiguration extends EmptyConfiguration {
- public MyConfiguration() {
- super();
-
- add(Assembler, Assembler.defValue());
- add(OwnDiameterURI, clientURI);
- add(OwnRealm, realmName);
- add(OwnVendorID, 193L);
- // Set Ericsson SDK feature
- // add(UseUriAsFqdn, true);
- // Set Common Applications
- add(ApplicationId,
- // AppId 1
- getInstance().add(VendorId, 193L).add(AuthApplId,
0L).add(AcctApplId, 19302L));
- // Set peer table
- add(PeerTable,
- // Peer 1
- getInstance().add(PeerRating, 1).add(PeerName, serverURI));
- // Set realm table
- add(RealmTable,
- // Realm 1
- getInstance().add(RealmEntry, realmName + ":" + clientHost + ","
+ serverHost));
- }
- }
-
-}
+public class MessageValidatorTest extends TestCase {
+
+ private static Logger logger =
Logger.getLogger(MessageValidatorTest.class);
+
+ private DictionaryImpl instance = null;
+
+ @Before
+ public void setUp() {
+
+ this.instance = (DictionaryImpl) DictionaryImpl.INSTANCE;
+ InputStream is =
MessageValidatorTest.class.getClassLoader().getResourceAsStream("dictionary.xml");
+
+ try {
+ this.instance.configure(is);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDown() {
+ this.instance = null;
+ }
+
+ @Test
+ public void testBasicOperations() {
+
+ Message answer = new MessageParser().createEmptyMessage(271, 0);
+ answer.setRequest(false);
+ AvpSet set = answer.getAvps();
+ set.addAvp(263, "SESSION-ID;246t13461346713...@#$sd$@#6",
false);
+ // nooooow, lets try some tests
+ MessageRepresentation msgRep = this.instance.getMessage(271, 0,
false);
+
+ // <avp name="Session-Id" code="263" vendor="0" multiplicity="1"
+ // index="0"/>
+ assertTrue("Session-Id is not allowed in this message, it should be.",
this.instance.getMessage(271, 0, false).isAllowed(263, 0));
+
+ assertTrue("We should allow to add ONE (1) Session-Id AVP, operation
indicates that it could not be done.",
+ msgRep.isCountValidForMultiplicity(set, 263,
0L));
+
+ // <avp name="Origin-Host" code="264" vendor="0"
multiplicity="1"
+ // index="-1"/>
+ assertTrue("Origin-Host is not allowed in this message, it should be.",
msgRep.isAllowed(264, 0));
+
+ assertFalse("We should allow to add more Origin-Host than zero,
operation indicates that it could not be done.",
+ msgRep.isCountValidForMultiplicity(set, 264,
0L));
+
+ // <avp name="Event-Timestamp" code="55" vendor="0"
multiplicity="0-1"
+ // index="-1"/>
+ assertTrue("Event-Timestamp is not allowed in this message, it should
be.", msgRep.isAllowed(55, 0));
+ assertTrue("We should allow to add more Event-Timestamp than zero,
operation indicates that it could not be done.",
+ msgRep.isCountValidForMultiplicity(set, 55,
0L));
+
+ set.addAvp(55, 55L, 0L, true, false);
+ assertFalse("We should not allow to add more Event-Timestamp than one,
operation indicates that it could be done.",
+ msgRep.isCountValidForMultiplicity(set, 55, 0L,
1));
+
+ // <avp name="Proxy-Info" code="284" vendor="0"
multiplicity="0+"
+ // index="-1"/>
+ assertTrue("Proxy-Info is not allowed in this message, it should be.",
msgRep.isAllowed(284, 0));
+ assertTrue("We should allow to add more Proxy-Info than zero, operation
indicates that it could not note be done.",
+ msgRep.isCountValidForMultiplicity(set, 284,
0L));
+
+ set.addAvp(284, 284L, 0L, true, false);
+
+ assertTrue("We should allow to add more Proxy-Info than one, operation
indicates that it could note be done.",
+ msgRep.isCountValidForMultiplicity(set, 284,
0L));
+
+ set.addAvp(284, 284L, 0L, true, false);
+ assertTrue("We should allow to add more Proxy-Info than two, operation
indicates that it could note be done.",
+ msgRep.isCountValidForMultiplicity(set, 284,
0L));
+
+ // <!-- FORBBIDEN -->
+ // <avp name="Auth-Application-Id" code="258" vendor="0"
+ // multiplicity="0" index="-1"/>
+ assertFalse("Auth-Application-Id is allowed in this message, it should
not be.", msgRep.isAllowed(258, 0));
+ assertTrue("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
+ msgRep.isCountValidForMultiplicity(set, 258,
0L));
+ assertFalse("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
+ msgRep.isCountValidForMultiplicity(set, 258,
0L, 1));
+
+ // <avp name="Destination-Realm" code="283" vendor="0"
multiplicity="0"
+ // index="-1"/>
+ assertFalse("Auth-Application-Id is allowed in this message, it should
not be.", msgRep.isAllowed(258, 0));
+ assertTrue("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
+ msgRep.isCountValidForMultiplicity(set, 258,
0L));
+ assertFalse("We should not allow to add more Auth-Application-Id than
zero, operation indicates that it could be done.",
+ msgRep.isCountValidForMultiplicity(set, 258,
0L, 1));
+ }
+
+ @Test
+ public void testGroupedAvpValidationFail() {
+ // Yeah, its awkward :) - it already should have session id.
+ Message msg = createMessage();
+
+ try {
+ instance.validate(msg, false);
+ fail("Validation of message should fail: " + msg);
+ } catch (AvpNotAllowedException ex) {
+ // we are ok
+ logger.info("[*]Valdiation failed properly with: ", ex);
+ }
+
+ fillTopLevelAvps(msg);
+
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ addTopLevelGroupedAvp(msg);
+ try {
+ instance.validate(msg, false);
+ fail("Validation of message should fail: " + msg);
+ } catch (AvpNotAllowedException ex) {
+ // we are ok,
+ logger.info("[*]Valdiation failed properly with: ", ex);
+ }
+ // This should pass.
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ fillTopLevelGroupedAvp(msg);
+
+ try {
+ // this should pass
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+ // This should pass.
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ }
+
+ @Test
+ public void testIncomingValidationLevels() {
+ // here lets test how different levels affect
+ Message msg = createMessage();
+
+ // here we will fail on all levels
+
+ // set all to off.
+ this.instance.setReceiveLevel(ValidatorLevel.OFF);
+ this.instance.setSendLevel(ValidatorLevel.OFF);
+ this.instance.setConfigured(false);
+ this.instance.setEnabled(false);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // enable
+ this.instance.setEnabled(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // configure
+ this.instance.setConfigured(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now lets do level magic
+ this.instance.setReceiveLevel(ValidatorLevel.MESSAGE);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ fail("Validation of message should fail: " + msg);
+ } catch (AvpNotAllowedException ex) {
+
+ }
+
+ // now ALL
+ this.instance.setReceiveLevel(ValidatorLevel.ALL);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ fail("Validation of message should fail: " + msg);
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[*]Valdiation failed properly with: ", ex);
+ }
+
+ fillTopLevelAvps(msg);
+ // set all to off.
+ this.instance.setReceiveLevel(ValidatorLevel.OFF);
+ this.instance.setConfigured(false);
+ this.instance.setEnabled(false);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // enable
+ this.instance.setEnabled(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // configure
+ this.instance.setConfigured(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now lets do level magic
+ this.instance.setReceiveLevel(ValidatorLevel.MESSAGE);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now ALL
+ this.instance.setReceiveLevel(ValidatorLevel.ALL);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ addTopLevelGroupedAvp(msg);
+
+ // set all to off.
+ this.instance.setReceiveLevel(ValidatorLevel.OFF);
+ this.instance.setConfigured(false);
+ this.instance.setEnabled(false);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // enable
+ this.instance.setEnabled(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // configure
+ this.instance.setConfigured(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now lets do level magic
+ this.instance.setReceiveLevel(ValidatorLevel.MESSAGE);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now ALL
+ this.instance.setReceiveLevel(ValidatorLevel.ALL);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ fail("Validation of message should fail: " + msg);
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[*]Valdiation failed properly with: ", ex);
+ }
+
+ fillTopLevelGroupedAvp(msg);
+
+ // set all to off.
+ this.instance.setReceiveLevel(ValidatorLevel.OFF);
+ this.instance.setConfigured(false);
+ this.instance.setEnabled(false);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // enable
+ this.instance.setEnabled(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // configure
+ this.instance.setConfigured(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now lets do level magic
+ this.instance.setReceiveLevel(ValidatorLevel.MESSAGE);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // now ALL
+ this.instance.setReceiveLevel(ValidatorLevel.ALL);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ }
+
+ @Test
+ public void testOutgoingValidationLevels() {
+ // here lets test how different levels affect
+ Message msg = createMessage();
+
+ // here we will fail on all levels
+
+ // set all to off.
+ this.instance.setReceiveLevel(ValidatorLevel.OFF);
+ this.instance.setSendLevel(ValidatorLevel.OFF);
+ this.instance.setConfigured(false);
+ this.instance.setEnabled(false);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // enable
+ this.instance.setEnabled(true);
+ try {
+ instance.validate(msg, false);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ try {
+ instance.validate(msg, true);
+
+ } catch (AvpNotAllowedException ex) {
+ logger.info("[x]Valdiation failed with: ", ex);
+ fail("Validation of message should not fail: " + msg);
+ }
+
+ // configure
+ this.instance.setConfigured(true);
+ try {
+ instance.validate(msg, false);
***The diff for this file has been truncated for email.***