Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#993 tests for Picocontainer lifecycle management
- Loading branch information
1 parent
ec76465
commit f2bb89b
Showing
3 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
picocontainer/src/test/java/cucumber/runtime/java/picocontainer/DisposableCucumberBelly.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
package cucumber.runtime.java.picocontainer; | |||
|
|||
import org.picocontainer.Disposable; | |||
|
|||
import java.util.List; | |||
|
|||
/** | |||
* A test helper class which simulates a class that holds system resources | |||
* which need disposing at the end of the test. | |||
* | |||
* In a real app, this could be a database connector or similar. | |||
*/ | |||
public class DisposableCucumberBelly | |||
implements Disposable { | |||
|
|||
private List<String> contents; | |||
private boolean isDisposed = false; | |||
|
|||
public void setContents(List<String> contents) { | |||
assert !isDisposed; | |||
this.contents = contents; | |||
} | |||
|
|||
public List<String> getContents() { | |||
assert !isDisposed; | |||
return contents; | |||
} | |||
|
|||
/** | |||
* "dispose()" is useful in addition to @After, as it is guaranteed to run | |||
* after all @After hooks, which is useful if this class is needed by the | |||
* After hooks themselves. | |||
*/ | |||
@Override | |||
public void dispose() { | |||
isDisposed = true; | |||
} | |||
|
|||
public boolean isDisposed() { | |||
return isDisposed; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters