
com.tdder.junit.jupiter.extension.TeardownRegistryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-teardown-extension Show documentation
Show all versions of junit-teardown-extension Show documentation
JUnit Jupiter extension. Provides Automated Teardown mechanism.
The newest version!
package com.tdder.junit.jupiter.extension;
import java.util.Deque;
import java.util.LinkedList;
class TeardownRegistryImpl implements TeardownRegistry {
private final Deque tasks_ = new LinkedList<>();
@Override
public T add(final T closeable) {
tasks_.add(closeable);
return closeable;
}
int size() {
return tasks_.size();
}
public void teardown(final ExceptionHandler exceptionHandler) throws Exception {
while (!tasks_.isEmpty()) {
// teardown in reverse order
final AutoCloseable task = tasks_.removeLast();
try {
task.close();
} catch (final Exception e) {
exceptionHandler.add(e);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy