Skip to content

Commit

Permalink
1586 Fix tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed Feb 20, 2024
1 parent a94ef4c commit f1c5253
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/io/AppendToTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void failsIfFileDoesNotExist() throws Exception {
* Ensures that AppendTo is appending to a given file.
* @param wdir TempDir to work in
* @throws Exception if fails
* @todo #1586:2h Tests failed on Windows due to not closed streams.
* @todo #1586:1h Tests failed on Windows due to not closed streams.
* It will be good to have feature to autoclose streams
*/
@Test
Expand Down
19 changes: 10 additions & 9 deletions src/test/java/org/cactoos/scalar/RetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
final class RetryTest {

@Test
void runsScalarMultipleTimes() throws Exception {
void runsScalarMultipleTimes() {
new Assertion<>(
"must retry in case of failure",
new Retry<>(
Expand All @@ -61,7 +61,7 @@ void runsScalarMultipleTimes() throws Exception {
}

@Test
void runsScalarTwiceWithDefaults() throws Exception {
void runsScalarTwiceWithDefaults() {
final AtomicInteger tries = new AtomicInteger(0);
new Assertion<>(
"Should run twice with defaults",
Expand All @@ -78,8 +78,7 @@ void runsScalarTwiceWithDefaults() throws Exception {
}

@Test
void runsScalarMultipleTimesIgnoringNegativeDuration()
throws Exception {
void runsScalarMultipleTimesIgnoringNegativeDuration() {
final int times = 2;
final AtomicInteger tries = new AtomicInteger(0);
new Assertion<>(
Expand Down Expand Up @@ -116,12 +115,14 @@ void runsScalarMultipleTimesWithWait() throws Exception {
Integer.MAX_VALUE,
Duration.ofMillis(wait)
).value();
for (int position = 0; position < executions.size() - 1; position += 1) {
final int actual = position;
for (int position = 0; position < times - 1; position += 1) {
new Assertion<>(
"Should wait the given time between attempts",
executions.get(actual).plusMillis(wait),
Matchers.lessThanOrEqualTo(executions.get(actual + 1))
String.format(
"Should wait the given time between attempts on attempt %d",
position
),
executions.get(position).plusMillis(wait),
Matchers.lessThanOrEqualTo(executions.get(position + 1))
).affirm();
}
}
Expand Down

0 comments on commit f1c5253

Please sign in to comment.