use of org.apache.synapse.MessageContext 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.MessageContext 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.MessageContext in project wso2-synapse by wso2.
the class DBLookupMediatorTest method testLookupMediator1.
public void testLookupMediator1() throws Exception {
MessageContext synCtx = TestUtils.getTestContext("<dummy><source>5</source></dummy>");
assertTrue(lookup.mediate(synCtx));
assertEquals(synCtx.getProperty("targetProp"), "svr1");
assertEquals(synCtx.getProperty("categoryProp"), "A");
}
use of org.apache.synapse.MessageContext in project wso2-synapse by wso2.
the class DBLookupMediatorTest method testLookupMediator2.
public void testLookupMediator2() throws Exception {
MessageContext synCtx = TestUtils.getTestContext("<dummy><source>6</source></dummy>");
assertTrue(lookup.mediate(synCtx));
assertEquals(synCtx.getProperty("targetProp"), "svr3");
assertEquals(synCtx.getProperty("categoryProp"), "B");
}
use of org.apache.synapse.MessageContext in project wso2-synapse by wso2.
the class DBReportMediatorTest method testLookupMediator1.
public void testLookupMediator1() throws Exception {
MessageContext synCtx = TestUtils.getTestContext("<dummy><from>me</from><count>5</count><to>you</to><category>GOLD</category></dummy>");
assertTrue(report.mediate(synCtx));
Connection con = report.getDataSource().getConnection();
ResultSet rs = con.createStatement().executeQuery("select fromepr, cnt, toepr, category from audit");
if (rs.next()) {
assertEquals("me", rs.getString("fromepr"));
assertEquals(5, rs.getInt("cnt"));
assertEquals("you", rs.getString("toepr"));
assertEquals("GOLD", rs.getString("category"));
} else {
fail("DB report failed");
}
}
Aggregations