Search in sources :

Example 16 with CitrusTest

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

the class TodoListIT method testJsonValidationWithFileResource.

@Test
@CitrusTest
public void testJsonValidationWithFileResource() {
    variable("todoId", "citrus:randomUUID()");
    variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
    variable("todoDescription", "Description: ${todoName}");
    http().client(todoClient).send().post("/api/todolist").messageType(MessageType.JSON).contentType(ContentType.APPLICATION_JSON.getMimeType()).payload(new ClassPathResource("templates/todo.json"));
    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("${todoId}");
    http().client(todoClient).send().get("/api/todo/${todoId}").accept(ContentType.APPLICATION_JSON.getMimeType());
    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload(new ClassPathResource("templates/todo.json"));
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 17 with CitrusTest

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

the class TodoListIT method testAddTodoEntry.

@Test
@CitrusTest
public void testAddTodoEntry() {
    variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
    variable("todoDescription", "Description: ${todoName}");
    soap().client(todoClient).send().soapAction("addTodoEntry").payload(new ClassPathResource("templates/addTodoEntryRequest.xml"));
    soap().client(todoClient).receive().payload(new ClassPathResource("templates/addTodoEntryResponse.xml"));
    soap().client(todoClient).send().soapAction("getTodoList").payload(new ClassPathResource("templates/getTodoListRequest.xml"));
    soap().client(todoClient).receive().payload(new ClassPathResource("templates/getTodoListResponse.xml"));
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 18 with CitrusTest

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

the class AddImageIT method testAddImageMtom.

@Test
@CitrusTest
public void testAddImageMtom() {
    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("addImage").payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>logo</image:id>" + "<image:image>cid:IMAGE</image:image>" + "</image:addImage>").attachment(attachment).mtomEnabled(true);
    soap().server(imageServer).receive().soapAction("addImage").schemaValidation(false).payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>logo</image:id>" + "<image:image>" + "<xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\" href=\"cid:IMAGE\"/>" + "</image:image>" + "</image:addImage>").attachmentValidator(new BinarySoapAttachmentValidator()).attachment(attachment);
    soap().server(imageServer).send().payload("<image:addImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:success>true</image:success>" + "</image:addImageResponse>");
    soap().client(imageClient).receive().payload("<image:addImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:success>true</image:success>" + "</image:addImageResponse>");
}
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)

Example 19 with CitrusTest

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

the class AddImageIT method testAddImageMtomInline.

@Test
@CitrusTest
public void testAddImageMtomInline() {
    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("addImage").payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>logo</image:id>" + "<image:image>cid:IMAGE</image:image>" + "</image:addImage>").attachment(attachment).mtomEnabled(true);
    soap().server(imageServer).receive().soapAction("addImage").payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:id>logo</image:id>" + "<image:image>citrus:readFile(image/logo.base64)</image:image>" + "</image:addImage>");
    soap().server(imageServer).send().payload("<image:addImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:success>true</image:success>" + "</image:addImageResponse>");
    soap().client(imageClient).receive().payload("<image:addImageResponse xmlns:image=\"http://www.citrusframework.org/imageService\">" + "<image:success>true</image:success>" + "</image:addImageResponse>");
}
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 20 with CitrusTest

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

the class TodoListIT method testMailReportXml.

@Test
@CitrusTest
public void testMailReportXml() {
    variable("todoId", "citrus:randomUUID()");
    variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
    variable("todoDescription", "Description: ${todoName}");
    mailServer.getMarshaller().setType(MessageType.XML.name());
    clearTodoList();
    http().client(todoClient).send().post("/api/todolist").messageType(MessageType.JSON).contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"id\": \"${todoId}\", \"title\": \"${todoName}\", \"description\": \"${todoDescription}\"}");
    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("${todoId}");
    variable("entryCount", "1");
    http().client(todoClient).send().get("/api/reporting/mail");
    echo("Receive reporting mail");
    receive(mailServer).payload(new ClassPathResource("templates/mail.xml")).header(CitrusMailMessageHeaders.MAIL_SUBJECT, "ToDo report");
    send(mailServer).payload(new ClassPathResource("templates/mail-response.xml"));
    http().client(todoClient).receive().response(HttpStatus.OK);
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) 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