use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class ClasspathResourceIterable method iterator.
@Override
public Iterator<Resource> iterator() {
try {
FlatteningIterator<Resource> iterator = new FlatteningIterator<Resource>();
Enumeration<URL> resources = classLoader.getResources(path);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
Iterator<Resource> resourceIterator = resourceIteratorFactory.createIterator(url, path, suffix);
iterator.push(resourceIterator);
}
return iterator;
} catch (IOException e) {
throw new CucumberException(e);
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class OpenEJBObjectFactory method getInstance.
@Override
public <T> T getInstance(Class<T> type) {
if (instances.containsKey(type)) {
return type.cast(instances.get(type));
}
T object;
try {
object = type.newInstance();
container.getContext().bind("inject", object);
} catch (Exception e) {
throw new CucumberException("can't create " + type.getName(), e);
}
instances.put(type, object);
return object;
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class JUnitReporter method fetchAndCheckRunnerStep.
private Step fetchAndCheckRunnerStep() {
Step scenarioStep = steps.remove(0);
Step runnerStep = executionUnitRunner.getRunnerSteps().remove(0);
if (!scenarioStep.getName().equals(runnerStep.getName())) {
throw new CucumberException("Expected step: \"" + scenarioStep.getName() + "\" got step: \"" + runnerStep.getName() + "\"");
}
return runnerStep;
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class DefaultJavaObjectFactory method cacheNewInstance.
private <T> T cacheNewInstance(Class<T> type) {
try {
Constructor<T> constructor = type.getConstructor();
T instance = constructor.newInstance();
instances.put(type, instance);
return instance;
} catch (NoSuchMethodException e) {
throw new CucumberException(String.format("%s doesn't have an empty constructor. If you need DI, put cucumber-picocontainer on the classpath", type), e);
} catch (Exception e) {
throw new CucumberException(String.format("Failed to instantiate %s", type), e);
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class GroovyBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
final Binding context = shell.getContext();
for (String gluePath : gluePaths) {
// Load sources
for (Resource resource : resourceLoader.resources(gluePath, ".groovy")) {
Script script = parse(resource);
runIfScript(context, script);
}
// Load compiled scripts
for (Class<? extends Script> glueClass : classFinder.getDescendants(Script.class, packageName(gluePath))) {
try {
Script script = glueClass.getConstructor(Binding.class).newInstance(context);
runIfScript(context, script);
} catch (Exception e) {
throw new CucumberException(e);
}
}
}
}
Aggregations