Search in sources :

Example 6 with CitrusTest

use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.

the class PlaceOrdersJmsIT method placeBlueberryCookieOrder.

@CitrusTest
public void placeBlueberryCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    send(bakeryOrderEndpoint).payload("<order><type>blueberry</type><id>${orderId}</id><amount>1</amount></order>");
    repeatOnError().until(new IteratingConditionExpression() {

        @Override
        public boolean evaluate(int index, TestContext context) {
            return index > 20;
        }
    }).autoSleep(100L).actions(http().client(reportingClient).send().get("/reporting/order").queryParam("id", "${orderId}"), http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload("{\"status\": true}"));
}
Also used : IteratingConditionExpression(com.consol.citrus.container.IteratingConditionExpression) TestContext(com.consol.citrus.context.TestContext) JmsEndpoint(com.consol.citrus.jms.endpoint.JmsEndpoint) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 7 with CitrusTest

use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.

the class IncidentManager_Http_IT method testIncidentManager_Http_SchemaInvalid.

@CitrusTest(name = "IncidentManager_Http_SchemaInvalid_IT")
public void testIncidentManager_Http_SchemaInvalid() {
    OpenIncident incident = new OpenIncident();
    incident.setIncident(new IncidentType());
    incident.getIncident().setCaptured(Calendar.getInstance());
    incident.getIncident().setComponent(ComponentType.SOFTWARE);
    incident.getIncident().setState(StateType.NEW);
    incident.getIncident().setDescription("Something missing!");
    assertSoapFault().faultCode("{http://schemas.xmlsoap.org/soap/envelope/}Client").faultString("@startsWith('Unmarshalling Error')@").when(send(incidentHttpClient).payloadModel(incident).header(SoapMessageHeaders.SOAP_ACTION, "/IncidentManager/openIncident"));
}
Also used : IncidentType(org.citrusframework.schema.samples.incidentmanager.v1.IncidentType) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 8 with CitrusTest

use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.

the class IncidentManager_Jms_IT method testIncidentManager_Jms_SchemaInvalid.

@CitrusTest(name = "IncidentManager_Jms_SchemaInvalid_IT")
public void testIncidentManager_Jms_SchemaInvalid() {
    OpenIncident incident = new OpenIncident();
    incident.setIncident(new IncidentType());
    incident.getIncident().setCaptured(Calendar.getInstance());
    incident.getIncident().setComponent(ComponentType.SOFTWARE);
    incident.getIncident().setState(StateType.NEW);
    incident.getIncident().setDescription("Something missing!");
    send(incidentJmsEndpoint).payloadModel(incident).header(SoapMessageHeaders.SOAP_ACTION, "/IncidentManager/openIncident");
    receive(incidentJmsEndpoint).payload("<SOAP-ENV:Fault xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<faultcode>@contains('Client')@</faultcode>" + "<faultstring>@startsWith('Unmarshalling Error')@</faultstring>" + "</SOAP-ENV:Fault>").header("SOAPJMS_isFault", "true");
}
Also used : IncidentType(org.citrusframework.schema.samples.incidentmanager.v1.IncidentType) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 9 with CitrusTest

use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.

the class TodoListIT method testObjectMarshalling.

@Test
@CitrusTest
public void testObjectMarshalling() {
    final UUID uuid = UUID.randomUUID();
    variable("todoId", uuid.toString());
    variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
    variable("todoDescription", "Description: ${todoName}");
    http().client(todoClient).send().post("/api/todolist").contentType(ContentType.APPLICATION_XML.getMimeType()).payload(new TodoEntry(uuid, "${todoName}", "${todoDescription}"), marshaller);
    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("${todoId}");
    http().client(todoClient).send().get("/api/todo/${todoId}").accept(ContentType.APPLICATION_XML.getMimeType());
    http().client(todoClient).receive().response(HttpStatus.OK).validationCallback(new XmlMarshallingValidationCallback<TodoEntry>(marshaller) {

        @Override
        public void validate(TodoEntry todoEntry, Map<String, Object> headers, TestContext context) {
            Assert.assertNotNull(todoEntry);
            Assert.assertEquals(todoEntry.getId(), uuid);
        }
    });
}
Also used : TestContext(com.consol.citrus.context.TestContext) UUID(java.util.UUID) TodoEntry(com.consol.citrus.samples.todolist.model.TodoEntry) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 10 with CitrusTest

use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.

the class GetImageIT method testGetImageMtom.

@Test
@CitrusTest
public void testGetImageMtom() {
    SoapAttachment attachment = new SoapAttachment();
    attachment.setContentId("IMAGE");
    attachment.setContentType("image/png");
    attachment.setCharsetName("utf-8");
    attachment.setContentResourcePath("image/logo.png");
    soap().client(imageClient).send().fork(true).soapAction("getImage").payload("<image:getImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>IMAGE</image:id>" + "</image:getImage>");
    soap().server(imageServer).receive().soapAction("getImage").payload("<image:getImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>IMAGE</image:id>" + "</image:getImage>");
    soap().server(imageServer).send().payload("<image:getImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:image>cid:IMAGE</image:image>" + "</image:getImageResponse>").attachment(attachment).mtomEnabled(true);
    soap().client(imageClient).receive().schemaValidation(false).payload("<image:getImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:image>" + "<xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\" href=\"cid:IMAGE\"/>" + "</image:image>" + "</image:getImageResponse>").attachmentValidator(new BinarySoapAttachmentValidator()).attachment(attachment);
}
Also used : SoapAttachment(com.consol.citrus.ws.message.SoapAttachment) BinarySoapAttachmentValidator(com.consol.citrus.ws.validation.BinarySoapAttachmentValidator) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Aggregations

CitrusTest (com.consol.citrus.annotations.CitrusTest)22 Test (org.testng.annotations.Test)12 TestContext (com.consol.citrus.context.TestContext)8 ClassPathResource (org.springframework.core.io.ClassPathResource)7 IteratingConditionExpression (com.consol.citrus.container.IteratingConditionExpression)6 SoapAttachment (com.consol.citrus.ws.message.SoapAttachment)4 JmsEndpoint (com.consol.citrus.jms.endpoint.JmsEndpoint)3 TodoEntry (com.consol.citrus.samples.todolist.model.TodoEntry)2 BinarySoapAttachmentValidator (com.consol.citrus.ws.validation.BinarySoapAttachmentValidator)2 UUID (java.util.UUID)2 IncidentType (org.citrusframework.schema.samples.incidentmanager.v1.IncidentType)2 Message (com.consol.citrus.message.Message)1