Search in sources :

Example 1 with CitrusTest

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

the class TodoListIT method testXmlValidationWithFileResource.

@Test
@CitrusTest
public void testXmlValidationWithFileResource() {
    variable("todoId", "citrus:randomUUID()");
    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 ClassPathResource("templates/todo.xml"));
    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).payload(new ClassPathResource("templates/todo.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 2 with CitrusTest

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

the class TodoListIT method testObjectMapping.

@Test
@CitrusTest
public void testObjectMapping() {
    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_JSON.getMimeType()).payload(new TodoEntry(uuid, "${todoName}", "${todoDescription}"), objectMapper);
    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).validationCallback(new JsonMappingValidationCallback<TodoEntry>(TodoEntry.class, objectMapper) {

        @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 3 with CitrusTest

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

the class PlaceOrdersHttpIT method placeChocolateCookieOrder.

@CitrusTest
public void placeChocolateCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    http().client(bakeryClient).send().post("/order").contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"order\": { \"type\": \"chocolate\", \"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 4 with CitrusTest

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

the class PlaceOrdersJmsIT method placeChocolateCookieOrder.

@CitrusTest
public void placeChocolateCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    send(bakeryOrderEndpoint).payload("<order><type>chocolate</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 5 with CitrusTest

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

the class PlaceOrdersJmsIT method placeCaramelCookieOrder.

@CitrusTest
public void placeCaramelCookieOrder() {
    variable("orderId", Functions.randomNumber(10L, null));
    send(bakeryOrderEndpoint).payload("<order><type>caramel</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)

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