use of org.apache.synapse.TestMessageContextBuilder in project wso2-synapse by wso2.
the class ValidateMediatorTest method testValidateMediatorInvalidCaseTwoSchemas.
public void testValidateMediatorInvalidCaseTwoSchemas() throws Exception {
// create a validate mediator
ValidateMediator validate = new ValidateMediator();
// set the schema url, source xpath and any name spaces
validate.setSchemaKeys(createKeyListFromMoreKeys("xsd-key-1", "xsd-key-2"));
validate.setSource(createXPath("//m1:Outer"));
MessageContext synCtx = new TestMessageContextBuilder().setRequireAxis2MessageContext(true).addFileEntry("xsd-key-1", "./../../repository/conf/sample/resources/validate/validate.xsd").addFileEntry("xsd-key-2", "./../../repository/conf/sample/resources/validate/validate2.xsd").setBodyFromString(INVALID_ENVELOPE_TWO_SCHEMAS).build();
// test validate mediator, with static enveope
test(validate, synCtx, true);
}
use of org.apache.synapse.TestMessageContextBuilder in project wso2-synapse by wso2.
the class ValidateMediatorTest method testValidateMediatorInvalidCaseNoNS.
public void testValidateMediatorInvalidCaseNoNS() throws Exception {
// create a validate mediator
ValidateMediator validate = new ValidateMediator();
// set the schema url, source xpath and any name spaces
validate.setSchemaKeys(createKeyListFromStaticKey("xsd-key-1"));
validate.setSource(createXPath("//m0:CheckPriceRequest"));
MessageContext synCtx = new TestMessageContextBuilder().setRequireAxis2MessageContext(true).addFileEntry("xsd-key-1", "./../../repository/conf/sample/resources/validate/validate.xsd").setBodyFromString(IN_VALID_ENVELOPE_NO_NS).build();
// test validate mediator, with static enveope
test(validate, synCtx, true);
}
use of org.apache.synapse.TestMessageContextBuilder in project wso2-synapse by wso2.
the class ValidateMediatorTest method testValidateMediatorValidCaseNoNS.
public void testValidateMediatorValidCaseNoNS() throws Exception {
// create a validate mediator
ValidateMediator validate = new ValidateMediator();
// set the schema url, source xpath and any name spaces
validate.setSchemaKeys(createKeyListFromStaticKey("xsd-key-1"));
validate.setSource(createXPath("//m0:CheckPriceRequest"));
MessageContext synCtx = new TestMessageContextBuilder().setRequireAxis2MessageContext(true).addFileEntry("xsd-key-1", "./../../repository/conf/sample/resources/validate/validate.xsd").setBodyFromString(VALID_ENVELOPE_NO_NS).build();
// test validate mediator, with static enveope
test(validate, synCtx, false);
}
use of org.apache.synapse.TestMessageContextBuilder in project wso2-synapse by wso2.
the class ValidateMediatorTest method testValidateMediatorValidCase.
public void testValidateMediatorValidCase() throws Exception {
// create a validate mediator
ValidateMediator validate = new ValidateMediator();
// set the schema url, source xpath and any name spaces
validate.setSchemaKeys(createKeyListFromStaticKey("xsd-key"));
validate.setSource(createXPath("//m0:CheckPriceRequest"));
MessageContext synCtx = new TestMessageContextBuilder().setRequireAxis2MessageContext(true).addFileEntry("xsd-key", "./../../repository/conf/sample/resources/validate/validate.xsd").setBodyFromString(VALID_ENVELOPE).build();
// test validate mediator, with static enveope
test(validate, synCtx, false);
}
use of org.apache.synapse.TestMessageContextBuilder in project wso2-synapse by wso2.
the class TestUtils method getTestContextJson.
public static MessageContext getTestContextJson(String bodyText, Map<String, Entry> props) throws Exception {
TestMessageContextBuilder builder = new TestMessageContextBuilder();
builder.setRequireAxis2MessageContext(true);
builder.setJsonBodyFromString(bodyText);
if (props != null) {
for (Map.Entry<String, Entry> mapEntry : props.entrySet()) {
builder.addEntry(mapEntry.getKey(), mapEntry.getValue());
}
}
return builder.build();
}
Aggregations