use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class GosuBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
GlueSource source = new GlueSource();
for (String gluePath : gluePaths) {
for (Resource glueScript : resourceLoader.resources(gluePath, ".gsp")) {
source.addGlueScript(glueScript);
}
}
Gosu gosu = new Gosu();
gosu.start(source.toArgInfo());
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method mockFileResource.
private void mockFileResource(ResourceLoader resourceLoader, String featurePath, String extension, String feature) throws IOException {
Resource resource = mock(Resource.class);
when(resource.getPath()).thenReturn(featurePath);
when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(feature.getBytes("UTF-8")));
when(resourceLoader.resources(featurePath, extension)).thenReturn(singletonList(resource));
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method mockFeatureFileResourceForAnyFeaturePath.
private ResourceLoader mockFeatureFileResourceForAnyFeaturePath(String feature) throws IOException {
ResourceLoader resourceLoader = mock(ResourceLoader.class);
Resource resource = mock(Resource.class);
when(resource.getPath()).thenReturn("");
when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(feature.getBytes("UTF-8")));
when(resourceLoader.resources(anyString(), anyString())).thenReturn(singletonList(resource));
return resourceLoader;
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class TestFeatureBuilder method feature.
static CucumberFeature feature(final String path, final String source) throws IOException {
ArrayList<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
FeatureBuilder featureBuilder = new FeatureBuilder(cucumberFeatures);
featureBuilder.parse(new Resource() {
@Override
public String getPath() {
return path;
}
@Override
public String getAbsolutePath() {
throw new UnsupportedOperationException();
}
@Override
public InputStream getInputStream() {
try {
return new ByteArrayInputStream(source.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
public String getClassName(String extension) {
throw new UnsupportedOperationException();
}
}, new ArrayList<Object>());
featureBuilder.close();
return cucumberFeatures.get(0);
}
use of cucumber.runtime.io.Resource in project tomee by apache.
the class ArchiveResourceIteratorFactory method findResources.
private Collection<Resource> findResources(final String path, final String suffix) {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final Collection<Resource> resources = new ArrayList<Resource>();
if (SWClassLoader.class.isInstance(loader)) {
final Collection<Archive<?>> archives = SWClassLoader.class.cast(loader).getArchives();
final ClassLoader parent = loader.getParent();
for (final Archive<?> archive : archives) {
final Map<ArchivePath, Node> content = archive.getContent(new Filter<ArchivePath>() {
@Override
public boolean include(final ArchivePath object) {
final String currentPath = classloaderPath(object);
return !(parent != null && parent.getResource(currentPath) != null) && currentPath.startsWith('/' + path) && currentPath.endsWith(suffix);
}
});
for (final Map.Entry<ArchivePath, Node> entry : content.entrySet()) {
resources.add(new SWResource(entry.getKey(), entry.getValue()));
}
}
}
return resources;
}
Aggregations