use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy in project tesb-rt-se by Talend.
the class WSDLSchemaPolicyTest method testWSLDConsumerResponseNotValid.
@Test(expected = SOAPFaultException.class)
public void testWSLDConsumerResponseNotValid() throws Exception {
SchemaValidationPolicy policy = new SchemaValidationPolicy();
policy.setAppliesToType(SchemaValidationPolicy.AppliesToType.valueOf("consumer"));
policy.setMessageType(SchemaValidationPolicy.MessageType.valueOf("response"));
policy.setValidationType(ValidationType.valueOf("WSDLSchema"));
customPolicyTest(policy, NOT_VALID_CUSTOMER_NAME);
}
use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy in project tesb-rt-se by Talend.
the class AbstractPolicyTest method customPolicyTest.
public void customPolicyTest(SchemaValidationPolicy assertion, String customerName) throws Exception {
clientCtxt = new ClassPathXmlApplicationContext("classpath:spring/client/policy/client-defaultApplicationContext.xml");
ClientProxyFactoryBean clientFactory = (ClientProxyFactoryBean) clientCtxt.getBean(ClientProxyFactoryBean.class);
Policy policy = new Policy();
policy.addAssertion(assertion);
clientFactory.getProperties().put(PolicyConstants.POLICY_OVERRIDE, policy);
CustomerServiceTester tester = new CustomerServiceTester();
tester.setCustomerService(clientFactory.create(CustomerService.class));
tester.testCustomerService(customerName);
clientCtxt.close();
}
use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy in project tesb-rt-se by Talend.
the class CustomSchemaPolicyTest method testLocalCustomSchemaNotExists.
@Test(expected = SOAPFaultException.class)
public void testLocalCustomSchemaNotExists() throws Exception {
SchemaValidationPolicy policy = new SchemaValidationPolicy();
policy.setAppliesToType(SchemaValidationPolicy.AppliesToType.valueOf("consumer"));
policy.setMessageType(SchemaValidationPolicy.MessageType.valueOf("response"));
policy.setValidationType(ValidationType.valueOf("CustomSchema"));
policy.setCustomSchemaPath("schema/DoesNotExist.xsd");
customPolicyTest(policy, VALID_CUSTOMER_NAME);
}
use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy in project tesb-rt-se by Talend.
the class WSDLSchemaPolicyTest method testWSLDConsumerResponseValid.
@Test
public void testWSLDConsumerResponseValid() throws Exception {
SchemaValidationPolicy policy = new SchemaValidationPolicy();
policy.setAppliesToType(SchemaValidationPolicy.AppliesToType.valueOf("consumer"));
policy.setMessageType(SchemaValidationPolicy.MessageType.valueOf("response"));
policy.setValidationType(ValidationType.valueOf("WSDLSchema"));
customPolicyTest(policy, VALID_CUSTOMER_NAME);
}
use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy in project tesb-rt-se by Talend.
the class SchemaValidationPolicyAbstractInterceptor method handleMessageWithAssertionInfo.
protected void handleMessageWithAssertionInfo(Message message) throws Fault {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
if (null == aim) {
return;
}
Collection<AssertionInfo> ais = aim.get(SchemaValidationPolicyBuilder.SCHEMA_VALIDATION);
if (null == ais) {
return;
}
for (AssertionInfo ai : ais) {
if (ai.getAssertion() instanceof SchemaValidationPolicy) {
SchemaValidationPolicy vPolicy = (SchemaValidationPolicy) ai.getAssertion();
ValidationType vldType = vPolicy.getValidationType();
AppliesToType appliesToType = vPolicy.getApplyToType();
MessageType msgType = vPolicy.getMessageType();
String customSchemaPath = vPolicy.getCustomSchemaPath();
if (vldType != ValidationType.WSDLSchema) {
ai.setAsserted(true);
}
if (shouldSchemaValidate(message, msgType, appliesToType)) {
if (vldType == ValidationType.CustomSchema) {
// load custom schema from external source
try {
loadCustomSchema(message, customSchemaPath, this.getClass());
} catch (IOException ex) {
throw new RuntimeException("Can not load custom schema", ex);
}
}
// do schema validation by setting value to
// "schema-validation-enabled" property
validateBySettingProperty(message);
}
ai.setAsserted(true);
}
ai.setAsserted(true);
}
}
Aggregations