Search in sources :

Example 11 with CitrusTest

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

the class GetImageIT method testGetImageMtomInline.

@Test
@CitrusTest
public void testGetImageMtomInline() {
    SoapAttachment attachment = new SoapAttachment();
    attachment.setContentId("IMAGE");
    attachment.setContentType("image/png");
    attachment.setCharsetName("utf-8");
    attachment.setContentResourcePath("image/logo.png");
    attachment.setMtomInline(true);
    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().payload("<image:getImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:image>citrus:readFile(image/logo.base64)</image:image>" + "</image:getImageResponse>");
}
Also used : SoapAttachment(com.consol.citrus.ws.message.SoapAttachment) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 12 with CitrusTest

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

the class PlaceBulkOrderIT method placeBulkCookieOrder.

@CitrusTest
public void placeBulkCookieOrder() {
    echo("Add 1000+ order and receive mail");
    variable("orderType", "chocolate");
    variable("orderId", Functions.randomNumber(10L, null));
    variable("amount", 1001L);
    send(bakeryOrderEndpoint).payload("<order><type>${orderType}</type><id>${orderId}</id><amount>${amount}</amount></order>");
    echo("Receive report mail for 1000+ order");
    receive(mailServer).payload(new ClassPathResource("templates/mail.xml")).header(CitrusMailMessageHeaders.MAIL_SUBJECT, "Congratulations!").header(CitrusMailMessageHeaders.MAIL_FROM, "cookie-report@example.com").header(CitrusMailMessageHeaders.MAIL_TO, "stakeholders@example.com");
    send(mailServer).payload(new ClassPathResource("templates/mail_response.xml"));
    echo("Receive report with 1000+ order");
    http().client(reportingClient).send().get("/reporting/json");
    http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload("{\"caramel\": \"@ignore@\",\"blueberry\": \"@ignore@\",\"chocolate\": \"@greaterThan(1000)@\"}");
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 13 with CitrusTest

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

the class PlaceOrdersHttpIT method placeCaramelCookieOrder.

@CitrusTest
public void placeCaramelCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    http().client(bakeryClient).send().post("/order").contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"order\": { \"type\": \"caramel\", \"id\": ${orderId}, \"amount\": 1}}");
    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}"));
    http().client(bakeryClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT);
}
Also used : IteratingConditionExpression(com.consol.citrus.container.IteratingConditionExpression) TestContext(com.consol.citrus.context.TestContext) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 14 with CitrusTest

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

the class PlaceOrdersHttpIT method placeBlueberryCookieOrder.

@CitrusTest
public void placeBlueberryCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    http().client(bakeryClient).send().post("/order").contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"order\": { \"type\": \"blueberry\", \"id\": ${orderId}, \"amount\": 1}}");
    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}"));
    http().client(bakeryClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT);
}
Also used : IteratingConditionExpression(com.consol.citrus.container.IteratingConditionExpression) TestContext(com.consol.citrus.context.TestContext) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 15 with CitrusTest

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

the class ReportOrderMailIT method shouldSendMail.

@CitrusTest
public void shouldSendMail() {
    echo("Add 1000+ order and receive mail");
    variable("orderType", "chocolate");
    http().client(reportingClient).send().put("/reporting").queryParam("id", "citrus:randomNumber(10)").queryParam("name", "${orderType}").queryParam("amount", "1001");
    http().client(reportingClient).receive().response(HttpStatus.OK);
    echo("Receive report mail for 1000+ order");
    receive(mailServer).payload(new ClassPathResource("templates/mail.xml")).header(CitrusMailMessageHeaders.MAIL_SUBJECT, "Congratulations!").header(CitrusMailMessageHeaders.MAIL_FROM, "cookie-report@example.com").header(CitrusMailMessageHeaders.MAIL_TO, "stakeholders@example.com");
    send(mailServer).payload(new ClassPathResource("templates/mail_response.xml"));
    echo("Receive report with 1000+ order");
    http().client(reportingClient).send().get("/reporting/json");
    http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload("{\"caramel\": \"@ignore@\",\"blueberry\": \"@ignore@\",\"chocolate\": \"@greaterThan(1000)@\"}");
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) 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