use of spock.config.ConfigurationException in project spock by spockframework.
the class ConfigurationScriptLoader method loadScriptFromClassPathLocation.
@Nullable
private DelegatingScript loadScriptFromClassPathLocation(String location) {
URL url = this.getClass().getClassLoader().getResource(location);
if (url == null)
return null;
GroovyShell shell = createShell();
try {
return (DelegatingScript) shell.parse(new GroovyCodeSource(url));
} catch (IOException e) {
throw new ConfigurationException("Error reading configuration script '%s'", location);
} catch (CompilationFailedException e) {
throw new ConfigurationException("Error compiling configuration script '%s'", location);
}
}
use of spock.config.ConfigurationException in project spock by spockframework.
the class ConfigurationScriptLoader method loadScriptFromSystemPropertyInducedLocation.
@Nullable
private DelegatingScript loadScriptFromSystemPropertyInducedLocation(String propertyKey) {
String location = System.getProperty(propertyKey);
if (location == null || location.length() == 0)
return null;
DelegatingScript script = loadScriptFromClassPathLocation(location);
if (script != null)
return script;
script = loadScriptFromFileSystemLocation(location);
if (script != null)
return script;
throw new ConfigurationException("Cannot find configuration script '%s'", location);
}
use of spock.config.ConfigurationException in project spock by spockframework.
the class ConfigurationScriptLoader method loadScriptFromFileSystemLocation.
@Nullable
private DelegatingScript loadScriptFromFileSystemLocation(String location) {
File file = new File(location);
try {
if (!file.exists())
return null;
} catch (AccessControlException e) {
// so let's just assume it's not there and continue
return null;
}
GroovyShell shell = createShell();
try {
return (DelegatingScript) shell.parse(file);
} catch (IOException e) {
throw new ConfigurationException("Error reading configuration script '%s'", location);
} catch (CompilationFailedException e) {
throw new ConfigurationException("Error compiling configuration script '%s'", location);
}
}
Aggregations