Package org.easetech.easytest.annotation

Examples of org.easetech.easytest.annotation.DataLoader


        if (testClass == null && method == null) {
            Assert
                .fail("The framework should provide either the testClass parameter or the method parameter in order to load the test data.");
        }
        // We give priority to Class Loading and then to method loading
        DataLoader testData = null;
        if (testClass != null) {
            testData = testClass.getAnnotation(DataLoader.class);
        } else {
            testData = method.getAnnotation(DataLoader.class);
        }
View Full Code Here


            List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(AfterClass.class);
            // THere would always be atleast on method associated with the Runner, else validation would fail.
            FrameworkMethod method = frameworkMethods.get(0);
            // Only if the return type of the Method is not VOID, we try to determine the right loader and data files.
            if (method.getMethod().getReturnType() != Void.TYPE) {
                DataLoader loaderAnnotation = method.getAnnotation(DataLoader.class);
                if (loaderAnnotation != null) {
                    determineLoader(loaderAnnotation);

                } else {
                    loaderAnnotation = getTestClass().getJavaClass().getAnnotation(DataLoader.class);
                    if (loaderAnnotation != null) {
                        determineLoader(loaderAnnotation);
                    }
                }
                if (dataLoader == null) {
                    Assert.fail("The framework currently does not support the specified Loader type. "
                        + "You can provide the custom Loader by choosing LoaderType.CUSTOM in TestData "
                        + "annotation and providing your custom loader using DataLoader annotation.");
                }
                dataFiles = loaderAnnotation.filePaths();
            } else {
                dataLoader = null;
            }

            return new RunAftersWithOutputData(statement, afters, null, dataLoader, dataFiles, writableData);
View Full Code Here

        if (testClass == null && method == null) {
            Assert
                .fail("The framework should provide either the testClass parameter or the method parameter in order to load the test data.");
        }
        // We give priority to Class Loading and then to method loading
        DataLoader testData = null;
        if (testClass != null) {
            testData = testClass.getAnnotation(DataLoader.class);
        } else {
            testData = method.getAnnotation(DataLoader.class);
        }
View Full Code Here

            List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(AfterClass.class);
            // THere would always be atleast on method associated with the Runner, else validation would fail.
            FrameworkMethod method = frameworkMethods.get(0);
            // Only if the return type of the Method is not VOID, we try to determine the right loader and data files.
            if (method.getMethod().getReturnType() != Void.TYPE) {
                DataLoader loaderAnnotation = method.getAnnotation(DataLoader.class);
                if (loaderAnnotation != null) {
                    determineLoader(loaderAnnotation);

                } else {
                    loaderAnnotation = getTestClass().getJavaClass().getAnnotation(DataLoader.class);
                    if (loaderAnnotation != null) {
                        determineLoader(loaderAnnotation);
                    }
                }
                if (dataLoader == null) {
                    Assert.fail("The framework currently does not support the specified Loader type. "
                        + "You can provide the custom Loader by choosing LoaderType.CUSTOM in TestData "
                        + "annotation and providing your custom loader using DataLoader annotation.");
                }
                dataFiles = loaderAnnotation.filePaths();
            } else {
                dataLoader = null;
            }

            return new RunAftersWithOutputData(statement, afters, null, dataLoader, dataFiles, writableData);
View Full Code Here

        for (FrameworkMethod method : testMethods) {
            TestInfo testInfo = null;

            // Only if the return type of the Method is not VOID, we try to determine the right loader and data
            // files.
            DataLoader loaderAnnotation = method.getAnnotation(DataLoader.class);
            if (loaderAnnotation != null) {
                testInfo = DataLoaderUtil.determineLoader(loaderAnnotation, getTestClass());

            } else {
                loaderAnnotation = getTestClass().getJavaClass().getAnnotation(DataLoader.class);
View Full Code Here

        if (testClass == null && method == null) {
            Assert
                .fail("The framework should provide either the testClass parameter or the method parameter in order to load the test data.");
        }
        // We give priority to Class Loading and then to method loading
        DataLoader testData = null;
        if (testClass != null) {
            testData = testClass.getAnnotation(DataLoader.class);
        } else {
            testData = method.getAnnotation(DataLoader.class);
        }
        if (testData != null) {
            TestInfo testInfo = DataLoaderUtil.determineLoader(testData, currentTestClass);
            Loader dataLoader = testInfo.getDataLoader();
            if (testInfo.getDataLoader() == null) {
                Assert.fail("The framework currently does not support the specified Loader type. "
                    + "You can provide the custom Loader by choosing LoaderType.CUSTOM in TestData "
                    + "annotation and providing your custom loader using DataLoader annotation.");
            } else {
                if (testInfo.getFilePaths() == null || testInfo.getFilePaths().length == 0) {
                    // implies that there exists a CUSTOM loader that loads the data using Java classes
                    Map<String, List<Map<String, Object>>> data = dataLoader.loadData(new EmptyResource());
                    // We also maintain the copy of the actual data for our write functionality.
                    fillWritableData(writableData , data , testData.appendData());
                    DataContext.setData(DataConverter.appendClassName(data, currentTestClass.getJavaClass()), testData.appendData());
                    DataContext.setConvertedData(DataConverter.convert(data, currentTestClass.getJavaClass()) , testData.appendData());
                } else {
                    ResourceLoader resourceLoader = new ResourceLoaderStrategy(currentTestClass.getJavaClass());
                    for (String filePath : testInfo.getFilePaths()) {
                        Resource resource = resourceLoader.getResource(filePath);
                        try {
                            if (resource.exists()) {
                                Map<String, List<Map<String, Object>>> data = dataLoader.loadData(resource);
                                // We also maintain the copy of the actual data for our write functionality.
                                fillWritableData(writableData , data , testData.appendData());
                                DataContext
                                    .setData(DataConverter.appendClassName(data, currentTestClass.getJavaClass()), testData.appendData());
                                DataContext.setConvertedData(DataConverter.convert(data,
                                    currentTestClass.getJavaClass()), testData.appendData());
                            } else {
                                LOG.warn(
                                    "Resource {} does not exists in the specified path. If it is a classpath resource, use 'classpath:' "
                                        + "before the path name, else check the path.", resource);
                            }
View Full Code Here

TOP

Related Classes of org.easetech.easytest.annotation.DataLoader

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.