use of liquibase.exception.SetupException in project liquibase by liquibase.
the class DatabaseChangeLog method includeAll.
public void includeAll(String pathName, boolean isRelativeToChangelogFile, IncludeAllFilter resourceFilter, boolean errorIfMissingOrEmpty, Comparator<String> resourceComparator, ResourceAccessor resourceAccessor, ContextExpression includeContexts) throws SetupException {
try {
if (pathName == null) {
throw new SetupException("No path attribute for includeAll");
}
pathName = pathName.replace('\\', '/');
if (!(pathName.endsWith("/"))) {
pathName = pathName + '/';
}
Logger log = LogFactory.getInstance().getLog();
log.debug("includeAll for " + pathName);
log.debug("Using file opener for includeAll: " + resourceAccessor.toString());
String relativeTo = null;
if (isRelativeToChangelogFile) {
relativeTo = this.getPhysicalFilePath();
}
Set<String> unsortedResources = null;
try {
unsortedResources = resourceAccessor.list(relativeTo, pathName, true, false, true);
} catch (FileNotFoundException e) {
if (errorIfMissingOrEmpty) {
throw e;
}
}
SortedSet<String> resources = new TreeSet<String>(resourceComparator);
if (unsortedResources != null) {
for (String resourcePath : unsortedResources) {
if (resourceFilter == null || resourceFilter.include(resourcePath)) {
resources.add(resourcePath);
}
}
}
if (resources.size() == 0 && errorIfMissingOrEmpty) {
throw new SetupException("Could not find directory or directory was empty for includeAll '" + pathName + "'");
}
for (String path : resources) {
include(path, false, resourceAccessor, includeContexts);
}
} catch (Exception e) {
throw new SetupException(e);
}
}
use of liquibase.exception.SetupException in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_setupException.
@Test
public void visit_setupException() throws Exception {
changeSet1.addChange(new CreateTableChange() {
@Override
public void finishInitialization() throws SetupException {
throw new SetupException("Test message");
}
});
ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
assertEquals(1, handler.getSetupExceptions().size());
assertEquals("Test message", handler.getSetupExceptions().get(0).getMessage());
assertFalse(handler.validationPassed());
}
Aggregations