Package com.github.timurstrekalov.saga.core.instrumentation

Examples of com.github.timurstrekalov.saga.core.instrumentation.ScriptInstrumenter


    private static final Logger logger = LoggerFactory.getLogger(FileSystemSourcePreloader.class);

    @Override
    public void preloadSources(final Config config, final TestRunCoverageStatistics totalStats) throws IOException {
        final ScriptInstrumenter instrumenter = new HtmlUnitBasedScriptInstrumenter(config);
        final String sourcesToPreload = config.getSourcesToPreload();
        final URI baseUri = config.getBaseUri();

        if (sourcesToPreload == null || !config.getOutputStrategy().contains(OutputStrategy.TOTAL) || !UriUtil.isFileUri(baseUri)) {
            return;
        }

        final String sourcesToPreloadEncoding = config.getSourcesToPreloadEncoding();
        logger.info("Using {} to preload sources", sourcesToPreloadEncoding);

        final List<File> filesToPreload = FileUtils.getFiles(new File(baseUri), sourcesToPreload, null);

        logger.info("Preloading {} files", filesToPreload.size());

        for (final File file : filesToPreload) {
            logger.debug("Preloading {}", file);

            final String source = CharStreams.toString(Files.newReaderSupplier(file, Charset.forName(sourcesToPreloadEncoding)));
            instrumenter.instrument(source, file.toURI().toString(), 0);
        }

        for (final ScriptData data : instrumenter.getScriptDataList()) {
            final Map<String, Long> coverageData = Maps.newHashMap();

            for (final Integer lineNumber : data.getLineNumbersOfAllStatements()) {
                coverageData.put(String.valueOf(lineNumber), 0L);
            }
View Full Code Here

TOP

Related Classes of com.github.timurstrekalov.saga.core.instrumentation.ScriptInstrumenter

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.