Package com.consol.citrus

Examples of com.consol.citrus.TestCase


    /** Default package to search for Xml test case files */
    private String packageName = "com.consol.citrus.tests";

    @Override
    public Message dispatchMessage(final Message request, String mappingName) {
        final TestCase test;
        final TestContext testContext;

        try {
            testContext = testContextFactory.getObject();
            test = getTestCase(testContext, mappingName);
        } catch (NoSuchBeanDefinitionException e) {
            throw new CitrusRuntimeException("Unable to find test builder with name '" +
                    mappingName + "' in Spring bean context", e);
        }

        taskExecutor.execute(new Runnable() {
            public void run() {
                prepareExecution(request, test);
                test.execute(testContext);
            }
        });

        return endpointAdapterDelegate.handleMessage(request);
    }
View Full Code Here


     */
    protected TestCase getTestCase(TestContext context, String testName) {
        ClassPathXmlApplicationContext ctx = createApplicationContext(context, packageName, testName);

        try {
            TestCase testCase = ctx.getBean(testName, TestCase.class);
            testCase.setPackageName(packageName);
            return testCase;
        } catch (NoSuchBeanDefinitionException e) {
            throw context.handleError(testName, packageName, "Could not find test with name '" + testName + "'", e);
        }
    }
View Full Code Here

     * Gets the test case from application context.
     * @return the new test case.
     */
    protected TestCase getTestCase(TestContext context) {
        ClassPathXmlApplicationContext ctx = createApplicationContext(context);
        TestCase testCase;
        try {
            testCase = ctx.getBean(testClass.getSimpleName(), TestCase.class);
            testCase.setPackageName(testClass.getPackage().getName());
        } catch (NoSuchBeanDefinitionException e) {
            throw context.handleError(getClass().getSimpleName(), getClass().getPackage().getName(), "Could not find test with name '" + testClass.getSimpleName() + "'", e);
        }
        return testCase;
    }
View Full Code Here

     * @param cause
     * @return
     */
    public CitrusRuntimeException handleError(String testName, String packageName, String message, Exception cause) {
        // Create empty dummy test case for logging purpose
        TestCase dummyTest = new TestCase();
        dummyTest.setName(testName);
        dummyTest.setPackageName(packageName);

        CitrusRuntimeException exception = new CitrusRuntimeException(message, cause);

        // inform test listeners with failed test
        testListeners.onTestStart(dummyTest);
View Full Code Here

     * @param testContext the test context.
     */
    protected void executeTest(ITestContext testContext) {
        TestContext ctx = prepareTestContext(createTestContext());

        TestCase testCase = getTestCase(ctx);
        if (citrusDataProviderParameters != null) {
            handleTestParameters(Reporter.getCurrentTestResult().getMethod(), testCase,
                    citrusDataProviderParameters[Reporter.getCurrentTestResult().getMethod().getCurrentInvocationCount()]);
        }

        testCase.execute(ctx);
    }
View Full Code Here

     * @param testName
     * @return the new test case.
     */
    protected TestCase getTestCase(TestContext context, String packageName, String testName) {
        ClassPathXmlApplicationContext ctx = createApplicationContext(context, packageName, testName);
        TestCase testCase;
       
        try {
            testCase = ctx.getBean(testName, TestCase.class);
            testCase.setPackageName(packageName);
        } catch (NoSuchBeanDefinitionException e) {
            throw context.handleError(testName, packageName, "Could not find test with name '" + testName + "'", e);
        }
       
        return testCase;
View Full Code Here

        reporter.onStart();
        reporter.onStartSuccess();
        reporter.onTestStart(test);
        reporter.onTestFinish(test);
        reporter.onTestSuccess(test);
        reporter.onTestSkipped(new TestCase());
        reporter.onFinish();
        reporter.onFinishSuccess();
        reporter.generateTestResults();
    }
View Full Code Here

    private Testcase getJavaDslTest(TestNGCitrusTestBuilder builder, Method method) {
        builder.init();
        ReflectionUtils.invokeMethod(method, builder);

        TestCase testCase = builder.getTestCase(null);
        return new TestcaseModelConverter().convert(testCase);
    }
View Full Code Here

   
    @Test
    public void testDefaultVariables() {
        globalVariables.getVariables().put("defaultVar", "123");
       
        TestCase testcase = new TestCase();
        testcase.setName("MyTestCase");
       
        testcase.setVariableDefinitions(Collections.singletonMap("test1Var", "456"));

        TestContext testContext = createTestContext();
        testcase.execute(testContext);

        Assert.assertEquals(testContext.getVariables().get(CitrusConstants.TEST_NAME_VARIABLE), "MyTestCase");
        Assert.assertEquals(testContext.getVariables().get(CitrusConstants.TEST_PACKAGE_VARIABLE), TestCase.class.getPackage().getName());
        Assert.assertTrue(testContext.getVariables().containsKey("defaultVar"));
        Assert.assertEquals(testContext.getVariables().get("defaultVar"), "123");
        Assert.assertTrue(testContext.getVariables().containsKey("test1Var"));
        Assert.assertEquals(testContext.getVariables().get("test1Var"), "456");
       
        TestCase testcase2 = new TestCase();
        testcase2.setName("MyTestCase2");
        testcase2.setPackageName("com.consol.citrus");
       
        testcase2.setVariableDefinitions(Collections.singletonMap("test2Var", "456"));

        testContext = createTestContext();
        testcase2.execute(testContext);

        Assert.assertEquals(testContext.getVariables().get(CitrusConstants.TEST_NAME_VARIABLE), "MyTestCase2");
        Assert.assertEquals(testContext.getVariables().get(CitrusConstants.TEST_PACKAGE_VARIABLE), "com.consol.citrus");
        Assert.assertTrue(testContext.getVariables().containsKey("defaultVar"));
        Assert.assertEquals(testContext.getVariables().get("defaultVar"), "123");
View Full Code Here

   
    @Test
    public void testDefaultVariablesChange() {
        globalVariables.getVariables().put("defaultVar", "123");
       
        TestCase testcase = new TestCase();
        testcase.setName("MyTestCase");
       
        CreateVariablesAction varSetting = new CreateVariablesAction();
        varSetting.setVariables(Collections.singletonMap("defaultVar", "ABC"));
        testcase.addTestAction(varSetting);

        TestContext testContext = createTestContext();
        testcase.execute(testContext);
       
        Assert.assertTrue(testContext.getVariables().containsKey("defaultVar"));
        Assert.assertEquals(testContext.getVariables().get("defaultVar"), "ABC");
       
        TestCase testcase2 = new TestCase();
        testcase2.setName("MyTestCase2");

        testContext = createTestContext();
        testcase2.execute(testContext);
       
        Assert.assertTrue(testContext.getVariables().containsKey("defaultVar"));
        Assert.assertEquals(testContext.getVariables().get("defaultVar"), "123");
    }
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.