Package cucumber.runtime.io

Examples of cucumber.runtime.io.ResourceLoader


        final Collection<ResourceLoader> customLoaders = new LinkedList<ResourceLoader>();
        if (additionalFeaturesAnn != null) {
            final Class<? extends ResourceLoader>[] userLoaders = additionalFeaturesAnn.loaders();
            for (final Class<? extends ResourceLoader> resourceLoader : userLoaders) {
                try {
                    final ResourceLoader instance = resourceLoader.newInstance();
                    customLoaders.add(instance);
                } catch (final Exception e) {
                    throw new IllegalArgumentException("can't create a " + resourceLoader.getName(), e);
                }
            }
        }

        for (final String raw : findFeatures(javaClass)) {
            final Collection<URL> list = new ArrayList<URL>();

            int lineIdx = raw.lastIndexOf(':');
            final String path;
            final String suffix;
            if (lineIdx > 0 && lineIdx + 1 != MultiLoader.CLASSPATH_SCHEME.length()) {
                path = raw.substring(0, lineIdx);
                suffix = raw.substring(lineIdx);
            } else {
                suffix = "";
                path = raw;
            }

            final boolean directResource = path.endsWith(EXTENSION);

            if (directResource) {
                { // from classpath
                    final URL url = loader.getResource(path);
                    if (url != null) {
                        list.add(url);
                        featureUrls.put(raw + suffix, list);
                        continue;
                    }
                }

                // from filesystem
                if (urlFromFileSystem(featureUrls, list, path, path, suffix)) {
                    continue;
                }

                // from filesystem with featureHome
                if (home != null && urlFromFileSystem(featureUrls, list, path, featureHome + path, suffix)) {
                    continue;
                }

                for (final ResourceLoader instance : customLoaders) {
                    for (final Resource r : instance.resources(path.substring(0, path.length() - EXTENSION.length()), EXTENSION)) {
                        try {
                            final String feature = new String(slurp(r.getInputStream()));
                            final String featurePath = r.getPath();
                            final File featureDump = dump(tempDir, javaClass.getName() + '/' + featurePath, feature);
                            featureDump.deleteOnExit();
                            featureUrls.put(featurePath, asList(featureDump.toURI().toURL()));
                        } catch (final IOException e) {
                            throw new IllegalStateException(e);
                        }
                    }
                }
            }

            findWithCucumberSearcher(loader, path, list);
            if (home != null) {
                findWithCucumberSearcher(loader, home + path, list);
            }

            if (!list.isEmpty()) {
                featureUrls.put(path + suffix, list);
            }
        }

        for (final ResourceLoader instance : customLoaders) {
            try {
                for (final Resource r : instance.resources(null, EXTENSION)) {
                    try {
                        final String feature = new String(slurp(r.getInputStream()));
                        final String featurePath = r.getPath();
                        final File featureDump = dump(tempDir, javaClass.getName() + '/' + featurePath, feature);
                        featureDump.deleteOnExit();
View Full Code Here

TOP

Related Classes of cucumber.runtime.io.ResourceLoader

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.