Package com.consol.citrus

Examples of com.consol.citrus.TestCase


*/
public class TestUtilsTest extends AbstractTestNGUnitTest {

    @Test
    public void testFirstActionFailing() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("sleep");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(failedAction);
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                new MockedActionContainer("iterate", new MockedTestAction("sleep"))));
       
        actions.add(new MockedTestAction("fail"));
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(failedAction);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 1);
View Full Code Here


        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 13L);
    }
   
    @Test
    public void testNestedContainerBeforeFailedAction() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("fail");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                new MockedActionContainer("iterate", new MockedTestAction("sleep"))));
       
        actions.add(failedAction);
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(failedAction);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 1);
View Full Code Here

        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 34L);
    }
   
    @Test
    public void testMiddleActionFailing() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("sleep");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(failedAction);
       
        actions.add(new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                new MockedActionContainer("iterate", new MockedTestAction("sleep"))));
       
        actions.add(new MockedTestAction("fail"));
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(failedAction);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 1);
View Full Code Here

        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 24L);
    }
   
    @Test
    public void testActionFailingInContainer() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("sleep");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(new MockedTestAction("sleep"));
       
        TestAction failedContainer = new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                failedAction,
                new MockedActionContainer("iterate", new MockedTestAction("sleep")));
        ((TestActionContainer)failedContainer).setLastExecutedAction(failedAction);
        actions.add(failedContainer);
       
        actions.add(new MockedTestAction("fail"));
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(failedContainer);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 2);
View Full Code Here

        Assert.assertEquals(failureStackElement.getStackMessage(), "at com/consol/citrus/util/FailureStackExampleTest(sequential:25)");
        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 25L);
    }
   
    public void testActionFailingInContainerHierarchy() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("sleep");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(new MockedTestAction("sleep"));
       
        TestAction failedContainer = new MockedActionContainer("iterate", failedAction);
        ((TestActionContainer)failedContainer).setLastExecutedAction(failedAction);
       
        TestAction nestedContainer = new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                failedContainer);
        ((TestActionContainer)nestedContainer).setLastExecutedAction(failedContainer);
        actions.add(nestedContainer);
       
        actions.add(new MockedTestAction("fail"));
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(nestedContainer);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 3);
View Full Code Here

        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 25L);
    }
   
    @Test
    public void testContainerItselfFailing() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"));
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        TestAction failedContainer = new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                failedAction);
        ((TestActionContainer)failedContainer).setLastExecutedAction(failedAction);
        actions.add(failedContainer);
       
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                new MockedActionContainer("iterate", new MockedTestAction("sleep"))));
       
        actions.add(new MockedTestAction("fail"));
        actions.add(new MockedTestAction("echo"));
       
        test.setActions(actions);
        test.setLastExecutedAction(failedContainer);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 2);
View Full Code Here

        Assert.assertEquals(failureStackElement.getLineNumberStart().longValue(), 14L);
    }

    @Test
    public void testLastActionFailing() {
        TestCase test = new TestCase();
        test.setPackageName("com.consol.citrus.util");
        test.setName("FailureStackExampleTest");

        TestAction failedAction = new MockedTestAction("echo");
       
        List<TestAction> actions = new ArrayList<TestAction>();
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("parallel",
                new MockedTestAction("sleep"),
                new MockedTestAction("fail"),
                new MockedActionContainer("sequential", new MockedTestAction("sleep"), new MockedTestAction("echo"))));
       
        actions.add(new MockedTestAction("sleep"));
       
        actions.add(new MockedActionContainer("sequential",
                new MockedTestAction("echo"),
                new MockedTestAction("sleep"),
                new MockedActionContainer("iterate", new MockedTestAction("sleep"))));
       
        actions.add(new MockedTestAction("fail"));
        actions.add(failedAction);
       
        test.setActions(actions);
        test.setLastExecutedAction(failedAction);
       
        List<FailureStackElement> failureStack = TestUtils.getFailureStack(test);
       
        Assert.assertFalse(failureStack.isEmpty());
        Assert.assertTrue(failureStack.size() == 1);
View Full Code Here

        verify(endpoint, producer, endpointConfiguration);
    }
   
    @Test
    public void testDisabledSendMessage() {
        TestCase testCase = new TestCase();
        SendMessageAction sendAction = new SendMessageAction();
        sendAction.setEndpoint(endpoint);
       
        TestActor disabledActor = new TestActor();
        disabledActor.setDisabled(true);
        sendAction.setActor(disabledActor);
       
        PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
        messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");
       
        sendAction.setMessageBuilder(messageBuilder);

        reset(endpoint, producer, endpointConfiguration);
        expect(endpoint.createProducer()).andReturn(producer).anyTimes();
        expect(endpoint.getEndpointConfiguration()).andReturn(endpointConfiguration).anyTimes();
        expect(endpoint.getActor()).andReturn(null).anyTimes();
        replay(endpoint, producer, endpointConfiguration);

        testCase.addTestAction(sendAction);
        testCase.execute(context);

        verify(endpoint, producer, endpointConfiguration);
    }
View Full Code Here

        verify(endpoint, producer, endpointConfiguration);
    }
   
    @Test
    public void testDisabledSendMessageByEndpointActor() {
        TestCase testCase = new TestCase();
        SendMessageAction sendAction = new SendMessageAction();
        sendAction.setEndpoint(endpoint);
       
        TestActor disabledActor = new TestActor();
        disabledActor.setDisabled(true);
       
        PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
        messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");
       
        sendAction.setMessageBuilder(messageBuilder);

        reset(endpoint, producer, endpointConfiguration);
        expect(endpoint.createProducer()).andReturn(producer).anyTimes();
        expect(endpoint.getEndpointConfiguration()).andReturn(endpointConfiguration).anyTimes();
        expect(endpoint.getActor()).andReturn(disabledActor).times(2);
        replay(endpoint, producer, endpointConfiguration);

        testCase.addTestAction(sendAction);
        testCase.execute(context);

        verify(endpoint, producer, endpointConfiguration);
    }
View Full Code Here

TOP

Related Classes of com.consol.citrus.TestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.