Skip to content

Commit 23990d9

Browse files
committed
Fix warnings in tests
1 parent d1385a4 commit 23990d9

File tree

8 files changed

+20
-36
lines changed

8 files changed

+20
-36
lines changed

src/test/java/engineering/swat/watch/APIErrorsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.junit.jupiter.api.BeforeEach;
3838
import org.junit.jupiter.api.Test;
3939

40-
public class APIErrorsTests {
40+
class APIErrorsTests {
4141

4242
private TestDirectory testDir;
4343

src/test/java/engineering/swat/watch/DeleteLockTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void setup() throws IOException {
5151
}
5252

5353
@AfterEach
54-
void cleanup() throws IOException {
54+
void cleanup() {
5555
if (testDir != null) {
5656
testDir.close();
5757
}
@@ -62,7 +62,6 @@ static void setupEverything() {
6262
Awaitility.setDefaultTimeout(TestHelper.NORMAL_WAIT);
6363
}
6464

65-
6665
@FunctionalInterface
6766
private interface Deleter {
6867
void run(Path target) throws IOException;

src/test/java/engineering/swat/watch/RecursiveWatchTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.io.IOException;
3232
import java.nio.file.Files;
3333
import java.nio.file.Path;
34-
import java.util.concurrent.TimeUnit;
3534
import java.util.concurrent.atomic.AtomicBoolean;
3635
import java.util.concurrent.atomic.AtomicReference;
3736

@@ -56,18 +55,17 @@ void setup() throws IOException {
5655
}
5756

5857
@AfterEach
59-
void cleanup() throws IOException {
58+
void cleanup() {
6059
if (testDir != null) {
6160
testDir.close();
6261
}
6362
}
6463

6564
@BeforeAll
66-
static void setupEverything() throws IOException {
65+
static void setupEverything() {
6766
Awaitility.setDefaultTimeout(TestHelper.NORMAL_WAIT);
6867
}
6968

70-
7169
@Test
7270
void newDirectoryWithFilesChangesDetected() throws IOException {
7371
var target = new AtomicReference<Path>();
@@ -123,7 +121,7 @@ void correctRelativePathIsReported() throws IOException {
123121
}
124122

125123
@Test
126-
void deleteOfFileInDirectoryShouldBeVisible() throws IOException, InterruptedException {
124+
void deleteOfFileInDirectoryShouldBeVisible() throws IOException {
127125
var target = testDir.getTestFiles()
128126
.stream()
129127
.filter(p -> !p.getParent().equals(testDir.getTestDirectory()))

src/test/java/engineering/swat/watch/SingleDirectoryTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
import java.io.IOException;
3232
import java.nio.file.Files;
33-
import java.time.Duration;
34-
import java.util.concurrent.TimeUnit;
3533
import java.util.concurrent.atomic.AtomicBoolean;
3634

3735
import org.awaitility.Awaitility;
@@ -42,7 +40,7 @@
4240

4341
import engineering.swat.watch.WatchEvent.Kind;
4442

45-
public class SingleDirectoryTests {
43+
class SingleDirectoryTests {
4644
private TestDirectory testDir;
4745

4846
@BeforeEach
@@ -51,7 +49,7 @@ void setup() throws IOException {
5149
}
5250

5351
@AfterEach
54-
void cleanup() throws IOException {
52+
void cleanup() {
5553
if (testDir != null) {
5654
testDir.close();
5755
}
@@ -63,7 +61,7 @@ static void setupEverything() {
6361
}
6462

6563
@Test
66-
void deleteOfFileInDirectoryShouldBeVisible() throws IOException, InterruptedException {
64+
void deleteOfFileInDirectoryShouldBeVisible() throws IOException {
6765
var target = testDir.getTestFiles().get(0);
6866
var seenDelete = new AtomicBoolean(false);
6967
var seenCreate = new AtomicBoolean(false);
@@ -91,7 +89,7 @@ void deleteOfFileInDirectoryShouldBeVisible() throws IOException, InterruptedExc
9189
}
9290

9391
@Test
94-
void alternativeAPITest() throws IOException, InterruptedException {
92+
void alternativeAPITest() throws IOException {
9593
var target = testDir.getTestFiles().get(0);
9694
var seenDelete = new AtomicBoolean(false);
9795
var seenCreate = new AtomicBoolean(false);

src/test/java/engineering/swat/watch/SingleFileTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.junit.jupiter.api.BeforeEach;
4141
import org.junit.jupiter.api.Test;
4242

43-
public class SingleFileTests {
43+
class SingleFileTests {
4444
private TestDirectory testDir;
4545

4646
@BeforeEach
@@ -49,7 +49,7 @@ void setup() throws IOException {
4949
}
5050

5151
@AfterEach
52-
void cleanup() throws IOException {
52+
void cleanup() {
5353
if (testDir != null) {
5454
testDir.close();
5555
}

src/test/java/engineering/swat/watch/SmokeTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import java.io.IOException;
3434
import java.nio.file.Files;
35-
import java.util.concurrent.TimeUnit;
3635
import java.util.concurrent.atomic.AtomicBoolean;
3736

3837
import org.awaitility.Awaitility;
@@ -51,7 +50,7 @@ void setup() throws IOException {
5150
}
5251

5352
@AfterEach
54-
void cleanup() throws IOException {
53+
void cleanup() {
5554
if (testDir != null) {
5655
testDir.close();
5756
}
@@ -63,7 +62,7 @@ static void setupEverything() {
6362
}
6463

6564
@Test
66-
void watchDirectory() throws IOException, InterruptedException {
65+
void watchDirectory() throws IOException {
6766
var changed = new AtomicBoolean(false);
6867
var target = testDir.getTestFiles().get(0);
6968
var watchConfig = Watcher.watch(testDir.getTestDirectory(), WatchScope.PATH_AND_CHILDREN)
@@ -77,7 +76,7 @@ void watchDirectory() throws IOException, InterruptedException {
7776
}
7877

7978
@Test
80-
void watchRecursiveDirectory() throws IOException, InterruptedException {
79+
void watchRecursiveDirectory() throws IOException {
8180
var changed = new AtomicBoolean(false);
8281
var target = testDir.getTestFiles().stream()
8382
.filter(p -> !p.getParent().equals(testDir.getTestDirectory()))
@@ -113,6 +112,4 @@ void watchSingleFile() throws IOException {
113112
await("Single file change").untilTrue(changed);
114113
}
115114
}
116-
117-
118115
}

src/test/java/engineering/swat/watch/TortureTests.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.util.Collections;
4040
import java.util.Set;
4141
import java.util.concurrent.ConcurrentHashMap;
42-
import java.util.concurrent.ConcurrentLinkedDeque;
4342
import java.util.concurrent.Executor;
4443
import java.util.concurrent.Executors;
4544
import java.util.concurrent.LinkedBlockingDeque;
@@ -58,8 +57,6 @@
5857
import org.junit.jupiter.api.Test;
5958
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
6059

61-
import engineering.swat.watch.WatchEvent.Kind;
62-
6360
class TortureTests {
6461

6562
private final Logger logger = LogManager.getLogger();
@@ -77,7 +74,7 @@ void setup() throws IOException {
7774
}
7875

7976
@AfterEach
80-
void cleanup() throws IOException {
77+
void cleanup() {
8178
if (testDir != null) {
8279
testDir.close();
8380
}
@@ -97,7 +94,7 @@ private final class IOGenerator {
9794
}
9895
}
9996

100-
private final static int BURST_SIZE = 1000;
97+
private static final int BURST_SIZE = 1000;
10198

10299
private void startJob(final Path root, Random r, Executor exec) {
103100
exec.execute(() -> {
@@ -246,7 +243,6 @@ void manyRegistrationsForSamePath() throws InterruptedException, IOException {
246243
done.acquire(TORTURE_REGISTRATION_THREADS - 1);
247244
assertTrue(seen.isEmpty(), "No events should have been sent");
248245
var target = testDir.getTestDirectory().resolve("test124.txt");
249-
//logger.info("Writing: {}", target);
250246
Files.writeString(target, "Hello World");
251247
var expected = Collections.singleton(target);
252248
await("We should see only one event")
@@ -331,8 +327,6 @@ void manyRegisterAndUnregisterSameTime() throws InterruptedException, IOExceptio
331327

332328
}
333329

334-
335-
336330
@Test
337331
//Deletes can race the filesystem, so you might miss a few files in a dir, if that dir is already deleted
338332
@EnabledIfEnvironmentVariable(named="TORTURE_DELETE", matches="true")
@@ -370,7 +364,7 @@ void pressureOnFSShouldNotMissDeletes() throws InterruptedException, IOException
370364
});
371365

372366
try (var activeWatch = watchConfig.start() ) {
373-
logger.info("Deleting files now", THREADS);
367+
logger.info("Deleting files now ({} threads)", THREADS);
374368
testDir.deleteAllFiles();
375369
logger.info("Waiting for the events processing to stabilize");
376370
waitForStable(events, happened);

src/test/java/engineering/swat/watch/impl/BundlingTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import engineering.swat.watch.impl.util.BundledSubscription;
5555
import engineering.swat.watch.impl.util.ISubscribable;
5656

57-
public class BundlingTests {
57+
class BundlingTests {
5858

5959
private final Logger logger = LogManager.getLogger();
6060
private BundledSubscription<Long, Boolean> target;
@@ -77,8 +77,7 @@ void publish(Long x) {
7777
s.accept(true);
7878
}
7979
}
80-
};
81-
80+
}
8281

8382
@BeforeEach
8483
void setup() {
@@ -134,7 +133,7 @@ void manySubscriptions() throws IOException {
134133
}
135134

136135
@RepeatedTest(failureThreshold = 1, value=50)
137-
void parallelSubscriptions() throws IOException, InterruptedException {
136+
void parallelSubscriptions() throws InterruptedException {
138137
var hits = new AtomicInteger();
139138
var endPointReached = new Semaphore(0);
140139
var waitingForClose = new Semaphore(0);
@@ -171,5 +170,4 @@ void parallelSubscriptions() throws IOException, InterruptedException {
171170
.untilAtomic(hits, IsEqual.equalTo(active));
172171
waitingForClose.release(active);
173172
}
174-
175173
}

0 commit comments

Comments
 (0)