How to use GroovyXmlMessageValidator method of com.consol.citrus.validation.MessageValidatorConfig class

Best Citrus code snippet using com.consol.citrus.validation.MessageValidatorConfig.GroovyXmlMessageValidator

Source:MessageValidatorRegistryTest.java Github

copy

Full Screen

...98 Assert.assertNotNull(matchingValidators);99 Assert.assertEquals(matchingValidators.size(), 4L);100 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);101 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);102 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);103 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);104 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));105 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));106 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));107 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));108 //XML message type and non empty payload109 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage("<id>12345</id>"));110 Assert.assertNotNull(matchingValidators);111 Assert.assertEquals(matchingValidators.size(), 4L);112 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);113 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);114 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);115 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);116 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));117 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));118 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));119 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));120 //script XML validation context121 validationContexts.add(new ScriptValidationContext(MessageType.XML.name()));122 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage(""));123 Assert.assertNotNull(matchingValidators);124 Assert.assertEquals(matchingValidators.size(), 4L);125 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);126 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);127 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);128 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);129 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));130 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));131 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));132 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));133 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage("<id>12345</id>"));134 Assert.assertNotNull(matchingValidators);135 Assert.assertEquals(matchingValidators.size(), 4L);136 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);137 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);138 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);139 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);140 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));141 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));142 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));143 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));144 //xpath message validation context145 validationContexts = new ArrayList<>();146 validationContexts.add(new HeaderValidationContext());147 validationContexts.add(new XmlMessageValidationContext());148 validationContexts.add(new JsonMessageValidationContext());149 validationContexts.add(new XpathMessageValidationContext());150 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage(""));151 Assert.assertNotNull(matchingValidators);152 Assert.assertEquals(matchingValidators.size(), 4L);153 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);154 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);155 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);156 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);157 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));158 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));159 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));160 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));161 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage("<id>12345</id>"));162 Assert.assertNotNull(matchingValidators);163 Assert.assertEquals(matchingValidators.size(), 4L);164 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);165 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);166 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);167 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);168 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));169 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));170 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));171 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));172 }173 @Test174 public void testMessageValidatorRegistryJsonConfig() throws Exception {175 MessageValidatorRegistry messageValidatorRegistry = new MessageValidatorConfig().getMessageValidatorRegistry();176 messageValidatorRegistry.afterPropertiesSet();177 List<ValidationContext> validationContexts = new ArrayList<>();178 validationContexts.add(new HeaderValidationContext());179 validationContexts.add(new XmlMessageValidationContext());180 validationContexts.add(new JsonMessageValidationContext());181 //JSON message type and empty payload182 List<MessageValidator<? extends ValidationContext>> matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage(""));183 Assert.assertNotNull(matchingValidators);184 Assert.assertEquals(matchingValidators.size(), 4L);185 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);186 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);187 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);188 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);189 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));190 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));191 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));192 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));193 //JSON message type and non empty payload194 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage("{ \"id\": 12345 }"));195 Assert.assertNotNull(matchingValidators);196 Assert.assertEquals(matchingValidators.size(), 4L);197 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);198 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);199 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);200 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);201 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));202 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));203 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));204 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));205 //script JSON validation context206 validationContexts.add(new ScriptValidationContext(MessageType.JSON.name()));207 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage(""));208 Assert.assertNotNull(matchingValidators);209 Assert.assertEquals(matchingValidators.size(), 4L);210 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);211 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);212 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);213 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);214 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));215 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));216 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));217 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));218 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage("{ \"id\": 12345 }"));219 Assert.assertNotNull(matchingValidators);220 Assert.assertEquals(matchingValidators.size(), 4L);221 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);222 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);223 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);224 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);225 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));226 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));227 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));228 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));229 //json path message validation context230 validationContexts = new ArrayList<>();231 validationContexts.add(new HeaderValidationContext());232 validationContexts.add(new XmlMessageValidationContext());233 validationContexts.add(new JsonMessageValidationContext());234 validationContexts.add(new JsonPathMessageValidationContext());235 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage(""));236 Assert.assertNotNull(matchingValidators);237 Assert.assertEquals(matchingValidators.size(), 4L);238 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);239 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);240 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);241 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);242 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));243 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));244 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));245 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));246 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage("{ \"id\": 12345 }"));247 Assert.assertNotNull(matchingValidators);248 Assert.assertEquals(matchingValidators.size(), 4L);249 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);250 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);251 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);252 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);253 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));254 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));255 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));256 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));257 }258 @Test259 public void testMessageValidatorRegistryPlaintextConfig() throws Exception {260 MessageValidatorRegistry messageValidatorRegistry = new MessageValidatorConfig().getMessageValidatorRegistry();261 messageValidatorRegistry.afterPropertiesSet();262 List<ValidationContext> validationContexts = new ArrayList<>();263 validationContexts.add(new HeaderValidationContext());264 validationContexts.add(new XmlMessageValidationContext());265 validationContexts.add(new JsonMessageValidationContext());266 //Plaintext message type and empty payload267 List<MessageValidator<? extends ValidationContext>> matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage(""));268 Assert.assertNotNull(matchingValidators);269 Assert.assertEquals(matchingValidators.size(), 3L);270 Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);271 Assert.assertEquals(matchingValidators.get(1).getClass(), DefaultMessageHeaderValidator.class);272 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyScriptMessageValidator.class);273 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));274 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));275 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));276 //Plaintext message type and non empty payload277 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage("id=12345"));278 Assert.assertNotNull(matchingValidators);279 Assert.assertEquals(matchingValidators.size(), 3L);280 Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);281 Assert.assertEquals(matchingValidators.get(1).getClass(), DefaultMessageHeaderValidator.class);282 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyScriptMessageValidator.class);283 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));284 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));285 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));286 //script plaintext validation context287 validationContexts.add(new ScriptValidationContext(MessageType.PLAINTEXT.name()));288 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage(""));289 Assert.assertNotNull(matchingValidators);290 Assert.assertEquals(matchingValidators.size(), 3L);291 Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);292 Assert.assertEquals(matchingValidators.get(1).getClass(), DefaultMessageHeaderValidator.class);293 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyScriptMessageValidator.class);294 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));295 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));296 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));297 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage("id=12345"));298 Assert.assertNotNull(matchingValidators);299 Assert.assertEquals(matchingValidators.size(), 3L);300 Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);301 Assert.assertEquals(matchingValidators.get(1).getClass(), DefaultMessageHeaderValidator.class);302 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyScriptMessageValidator.class);303 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));304 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));305 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));306 }307 @Test308 public void testMessageValidatorRegistryFallback() throws Exception {309 MessageValidatorRegistry messageValidatorRegistry = new MessageValidatorConfig().getMessageValidatorRegistry();310 messageValidatorRegistry.afterPropertiesSet();311 List<ValidationContext> validationContexts = new ArrayList<>();312 validationContexts.add(new HeaderValidationContext());313 validationContexts.add(new XmlMessageValidationContext());314 validationContexts.add(new JsonMessageValidationContext());315 List<MessageValidator<? extends ValidationContext>> matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.XML.name(), new DefaultMessage("{ \"id\": 12345 }"));316 Assert.assertNotNull(matchingValidators);317 Assert.assertEquals(matchingValidators.size(), 4L);318 Assert.assertEquals(matchingValidators.get(0).getClass(), JsonTextMessageValidator.class);319 Assert.assertEquals(matchingValidators.get(1).getClass(), JsonPathMessageValidator.class);320 Assert.assertEquals(matchingValidators.get(2).getClass(), DefaultMessageHeaderValidator.class);321 Assert.assertEquals(matchingValidators.get(3).getClass(), GroovyJsonMessageValidator.class);322 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));323 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));324 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));325 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));326 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.JSON.name(), new DefaultMessage("<id>12345</id>"));327 Assert.assertNotNull(matchingValidators);328 Assert.assertEquals(matchingValidators.size(), 4L);329 Assert.assertEquals(matchingValidators.get(0).getClass(), DomXmlMessageValidator.class);330 Assert.assertEquals(matchingValidators.get(1).getClass(), XpathMessageValidator.class);331 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyXmlMessageValidator.class);332 Assert.assertEquals(matchingValidators.get(3).getClass(), DefaultMessageHeaderValidator.class);333 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));334 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));335 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));336 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(3)).findValidationContext(validationContexts));337 matchingValidators = messageValidatorRegistry.findMessageValidators(MessageType.PLAINTEXT.name(), new DefaultMessage("<id>12345</id>"));338 Assert.assertNotNull(matchingValidators);339 Assert.assertEquals(matchingValidators.size(), 3L);340 Assert.assertEquals(matchingValidators.get(0).getClass(), PlainTextMessageValidator.class);341 Assert.assertEquals(matchingValidators.get(1).getClass(), DefaultMessageHeaderValidator.class);342 Assert.assertEquals(matchingValidators.get(2).getClass(), GroovyScriptMessageValidator.class);343 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(0)).findValidationContext(validationContexts));344 Assert.assertNotNull(((AbstractMessageValidator)matchingValidators.get(1)).findValidationContext(validationContexts));345 Assert.assertNull(((AbstractMessageValidator)matchingValidators.get(2)).findValidationContext(validationContexts));...

Full Screen

Full Screen

Source:MessageValidatorConfig.java Github

copy

Full Screen

...40 private final BinaryBase64MessageValidator defaultBinaryBase64MessageValidator = new BinaryBase64MessageValidator();41 private final GzipBinaryBase64MessageValidator defaultGzipBinaryBase64MessageValidator = new GzipBinaryBase64MessageValidator();42 private final XhtmlMessageValidator defaultXhtmlMessageValidator = new XhtmlMessageValidator();43 private final XhtmlXpathMessageValidator defaultXhtmlXpathMessageValidator = new XhtmlXpathMessageValidator();44 private final GroovyXmlMessageValidator defaultGroovyXmlMessageValidator = new GroovyXmlMessageValidator();45 private final GroovyJsonMessageValidator defaultGroovyJsonMessageValidator = new GroovyJsonMessageValidator();46 private final GroovyScriptMessageValidator defaultGroovyTextMessageValidator = new GroovyScriptMessageValidator();47 @Bean(name = "defaultXmlMessageValidator")48 public DomXmlMessageValidator getDefaultXmlMessageValidator() {49 return defaultXmlMessageValidator;50 }51 @Bean(name = "defaultMessageHeaderValidator")52 public DefaultMessageHeaderValidator getDefaultMessageHeaderValidator() {53 return defaultMessageHeaderValidator;54 }55 @Bean(name = "defaultXpathMessageValidator")56 public XpathMessageValidator getDefaultXpathMessageValidator() {57 return defaultXpathMessageValidator;58 }59 @Bean(name = "defaultJsonMessageValidator")60 public JsonTextMessageValidator getDefaultJsonTextMessageValidator() {61 return defaultJsonMessageValidator;62 }63 @Bean(name = "defaultJsonPathMessageValidator")64 public JsonPathMessageValidator getDefaultJsonPathMessageValidator() {65 return defaultJsonPathMessageValidator;66 }67 @Bean(name = "defaultPlaintextMessageValidator")68 public PlainTextMessageValidator getDefaultPlainTextMessageValidator() {69 return defaultPlaintextMessageValidator;70 }71 @Bean(name = "defaultBinaryMessageValidator")72 public BinaryMessageValidator getDefaultBinaryMessageValidator() {73 return defaultBinaryMessageValidator;74 }75 @Bean(name = "defaultBinaryBase64MessageValidator")76 public BinaryBase64MessageValidator getDefaultBinaryBase64MessageValidator() {77 return defaultBinaryBase64MessageValidator;78 }79 @Bean(name = "defaultGzipBinaryBase64MessageValidator")80 public GzipBinaryBase64MessageValidator getDefaultGzipBinaryBase64MessageValidator() {81 return defaultGzipBinaryBase64MessageValidator;82 }83 @Bean(name = "defaultXhtmlMessageValidator")84 public XhtmlMessageValidator getDefaultXhtmlMessageValidator() {85 return defaultXhtmlMessageValidator;86 }87 @Bean(name = "defaultXhtmlXpathMessageValidator")88 public XhtmlXpathMessageValidator getDefaultXhtmlXpathMessageValidator() {89 return defaultXhtmlXpathMessageValidator;90 }91 @Bean(name = "defaultGroovyXmlMessageValidator")92 public GroovyXmlMessageValidator getDefaultGroovyXmlMessageValidator() {93 return defaultGroovyXmlMessageValidator;94 }95 @Bean(name = "defaultGroovyJsonMessageValidator")96 public GroovyJsonMessageValidator getDefaultGroovyJsonMessageValidator() {97 return defaultGroovyJsonMessageValidator;98 }99 @Bean(name = "defaultGroovyTextMessageValidator")100 public GroovyScriptMessageValidator getDefaultGroovyTextMessageValidator() {101 return defaultGroovyTextMessageValidator;102 }103 @Bean(name = MessageValidatorRegistry.BEAN_NAME)104 public MessageValidatorRegistry getMessageValidatorRegistry() {105 MessageValidatorRegistry citrusMessageValidatorRegistry = new MessageValidatorRegistry();106 citrusMessageValidatorRegistry.getMessageValidators().add(defaultXmlMessageValidator);107 citrusMessageValidatorRegistry.getMessageValidators().add(defaultXpathMessageValidator);108 citrusMessageValidatorRegistry.getMessageValidators().add(defaultGroovyXmlMessageValidator);109 citrusMessageValidatorRegistry.getMessageValidators().add(defaultJsonMessageValidator);110 citrusMessageValidatorRegistry.getMessageValidators().add(defaultJsonPathMessageValidator);111 citrusMessageValidatorRegistry.getMessageValidators().add(defaultPlaintextMessageValidator);112 citrusMessageValidatorRegistry.getMessageValidators().add(defaultMessageHeaderValidator);113 citrusMessageValidatorRegistry.getMessageValidators().add(defaultBinaryMessageValidator);114 citrusMessageValidatorRegistry.getMessageValidators().add(defaultBinaryBase64MessageValidator);115 citrusMessageValidatorRegistry.getMessageValidators().add(defaultGzipBinaryBase64MessageValidator);116 citrusMessageValidatorRegistry.getMessageValidators().add(defaultGroovyJsonMessageValidator);117 citrusMessageValidatorRegistry.getMessageValidators().add(defaultGroovyTextMessageValidator);118 citrusMessageValidatorRegistry.getMessageValidators().add(defaultXhtmlMessageValidator);119 citrusMessageValidatorRegistry.getMessageValidators().add(defaultXhtmlXpathMessageValidator);120 return citrusMessageValidatorRegistry;121 }122}...

Full Screen

Full Screen

GroovyXmlMessageValidator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.message.MessageType;4import org.springframework.http.HttpStatus;5import org.springframework.http.MediaType;6import org.testng.annotations.Test;7public class GroovyXmlMessageValidator extends TestNGCitrusTestDesigner {8 public void groovyXmlMessageValidator() {9 variable("name", "John Doe");10 variable("age", "42");11 variable("street", "Main Street 1");12 variable("city", "Anytown");13 variable("state", "CA");14 variable("zip", "12345");15 variable("country", "US");16 http()17 .client("httpClient")18 .send()19 .post("/services/customerservice")20 .contentType(MediaType.APPLICATION_XML_VALUE)21 "<ns0:Name>${name}</ns0:Name>" +22 "<ns0:Age>${age}</ns0:Age>" +23 "<ns0:Street>${street}</ns0:Street>" +24 "<ns0:City>${city}</ns0:City>" +25 "<ns0:State>${state}</ns0:State>" +26 "<ns0:Zip>${zip}</ns0:Zip>" +27 "<ns0:Country>${country}</ns0:Country>" +28 "</ns0:CustomerRequest>");29 http()30 .client("httpClient")31 .receive()32 .response(HttpStatus.OK)33 .messageType(MessageType.XML)34 .validateScript("com.consol.citrus.samples.GroovyXmlMessageValidator")35 "</ns0:CustomerResponse>");36 }37}38package com.consol.citrus.samples;39import com.consol.c

Full Screen

Full Screen

GroovyXmlMessageValidator

Using AI Code Generation

copy

Full Screen

1public class GroovyXmlMessageValidatorTest {2 public void testGroovyXmlMessageValidator() {3 GroovyXmlMessageValidator groovyXmlMessageValidator = new GroovyXmlMessageValidator();4 MessageValidatorConfig groovyMessageValidatorConfig = new MessageValidatorConfig();5 groovyMessageValidatorConfig.setGroovyScript("assert message.getPayload().getDocument().getDocumentElement().getTagName() == 'root'");6 groovyMessageValidatorConfig.setGroovyContext(new Binding());7 groovyXmlMessageValidator.setMessageValidatorConfig(groovyMessageValidatorConfig);8 groovyXmlMessageValidator.validateMessage(new XmlMessage("<root></root>"), new XmlMessage("<root></root>"));9 }10}11public class GroovyJsonMessageValidatorTest {12 public void testGroovyJsonMessageValidator() {13 GroovyJsonMessageValidator groovyJsonMessageValidator = new GroovyJsonMessageValidator();14 MessageValidatorConfig groovyMessageValidatorConfig = new MessageValidatorConfig();15 groovyMessageValidatorConfig.setGroovyScript("assert message.getPayload().getDocument().getDocumentElement().getTagName() == 'root'");16 groovyMessageValidatorConfig.setGroovyContext(new Binding());17 groovyJsonMessageValidator.setMessageValidatorConfig(groovyMessageValidatorConfig);18 groovyJsonMessageValidator.validateMessage(new JsonMessage("{\"root\": \"\"}"), new JsonMessage("{\"root\": \"\"}"));19 }20}21public class GroovyJsonMessageValidatorTest {22 public void testGroovyJsonMessageValidator() {23 GroovyJsonMessageValidator groovyJsonMessageValidator = new GroovyJsonMessageValidator();24 MessageValidatorConfig groovyMessageValidatorConfig = new MessageValidatorConfig();25 groovyMessageValidatorConfig.setGroovyScript("assert message.getPayload().getDocument().getDocumentElement().getTagName() == 'root'");26 groovyMessageValidatorConfig.setGroovyContext(new Binding());27 groovyJsonMessageValidator.setMessageValidatorConfig(groovyMessageValidatorConfig);28 groovyJsonMessageValidator.validateMessage(new JsonMessage("{\"root\": \"\"}"), new JsonMessage("{\"root\": \"\"}

Full Screen

Full Screen

GroovyXmlMessageValidator

Using AI Code Generation

copy

Full Screen

1public class 4 {2 public static void main(String[] args) {3 MessageValidatorConfig groovyXmlMessageValidator = new MessageValidatorConfig();4 groovyXmlMessageValidator.setGroovyXmlMessageValidator("groovyXmlMessageValidator.groovy");5 groovyXmlMessageValidator.validateMessage(null, null);6 }7}8import com.consol.citrus.message.Message9import com.consol.citrus.validation.xml.XmlMessageValidationContext10import com.consol.citrus.validation.xml.XmlMessageValidator11import com.consol.citrus.context.TestContext12import com.consol.citrus.exceptions.CitrusRuntimeException13import com.consol.citrus.validation.MessageValidator14import com.consol.citrus.validation.xml.XmlMessageValidationContext15import com.consol.citrus.validation.xml.XmlMessageValidationUtils16import com.consol.citrus.exceptions.CitrusRuntimeException17import com.consol.citrus.context.TestContext18import com.consol.citrus.message.Message19import com.consol.citrus.exceptions.ValidationException20import com.consol.citrus.util.XMLUtils21import groovy.transform.CompileStatic22import org.springframework.util.StringUtils23import org.w3c.dom.Document24import org.w3c.dom.Node25import org.w3c.dom.NodeList26import org.xml.sax.SAXException27import javax.xml.parsers.ParserConfigurationException28import javax.xml.xpath.XPathExpressionException29import javax.xml.xpath.XPathFactoryConfigurationException30import java.io.IOException31import java.util.regex.Pattern32class GroovyXmlMessageValidator implements MessageValidator {

Full Screen

Full Screen

GroovyXmlMessageValidator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class GroovyXmlMessageValidatorTest extends TestNGCitrusTestDesigner {5 public void configure() {6 variable("firstName", "John");7 variable("lastName", "Doe");8 variable("age", "25");9 echo("Hello Citrus!");10 http()11 .client("httpClient")12 .send()13 .post("/services/rest/hello")14 .payload("<HelloRequestMessage>" +15 " <firstName>${firstName}</firstName>" +16 " <lastName>${lastName}</lastName>" +17 " <age>${age}</age>" +18 "</HelloRequestMessage>");19 http()20 .client("httpClient")21 .receive()22 .response(HttpStatus.OK)23 .messageType(MessageType.PLAINTEXT)24 .validate(GroovyXmlMessageValidator.class)25 .expression("xpath('/HelloResponseMessage/firstName').string()", "citrus:concat('Hello ', citrus:concat(${firstName}, '!'))")26 .expression("xpath('/HelloResponseMessage/lastName').string()", "citrus:concat('Hello ', citrus:concat(${lastName}, '!'))")27 .expression("xpath('/HelloResponseMessage/age').string()", "citrus:concat('Hello ', citrus:concat(${age}, '!'))");28 }29}30package com.consol.citrus.samples;31import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;32import org.testng.annotations.Test;33public class GroovyJsonMessageValidatorTest extends TestNGCitrusTestDesigner {34 public void configure() {35 variable("firstName", "John");36 variable("lastName", "Doe");37 variable("age", "25");38 echo("Hello Citrus!");39 http()40 .client("httpClient")41 .send()42 .post("/services/rest/hello")43 .payload("{ \"HelloRequestMessage\": { \"firstName\": \"${firstName}\", \"lastName\": \"${lastName}\", \"age\": \"${age}\" } }");44 http()

Full Screen

Full Screen

GroovyXmlMessageValidator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.junit.JUnit4CitrusTest;3import com.consol.citrus.message.MessageType;4import org.springframework.context.annotation.Bean;5import org.springframework.context.annotation.Configuration;6public class GroovyXmlMessageValidatorTest extends JUnit4CitrusTest {7 public static class Config {8 public MessageValidatorConfig groovyXmlMessageValidator() {9 return new MessageValidatorConfig()10 .type(MessageType.XML)11 .groovyScript("classpath:com/consol/citrus/validation/groovyXmlMessageValidator.groovy");12 }13 }14 public void run() {15 variable("citrus_jms_message_selector", "JMSCorrelationID = '${correlationId}'");16 variable("correlationId", "12345");17 variable("name", "citrus:concat('Hello ', citrus:randomNumber(3))");18 variable("age", "citrus:randomNumber(2)");19 variable("id", "citrus:randomNumber(4)");20 variable("citrus_jms_destinationName", "testQueue");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful