Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit a4b41ef

Browse files
committed
Added final missing test
1 parent 3a9004f commit a4b41ef

File tree

3 files changed

+54
-209
lines changed

3 files changed

+54
-209
lines changed

src/main/java/com/morgan/design/properties/internal/CopyOfPropertiesWatcher.java

Lines changed: 0 additions & 192 deletions
This file was deleted.

src/test/java/com/morgan/design/properties/internal/PropertiesWatcherUnitTest.java

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@
2121

2222
public class PropertiesWatcherUnitTest {
2323

24-
private static final String PROPERTIES = "target/test-classes/test-files/fileWatcher.properties";
25-
private static final String PROPERTIES2 = "target/test-classes/test-files2/fileWatcher2.properties";
24+
private static final int _1_SEC = 1000;
25+
private static final int _2_SEC = 2000;
2626

2727
private Resource actual;
2828
private CountDownLatch lock = new CountDownLatch(0);
2929

30-
final File propertiesFile1 = new File(PROPERTIES);
31-
final Resource[] singleResource = new Resource[] { new FileSystemResource(this.propertiesFile1) };
30+
final File propertiesFile1 = new File("target/test-classes/test-files/fileWatcher.properties");
31+
final File propertiesFile2 = new File("target/test-classes/test-files/different_fileWatcher.properties");
32+
final File propertiesFile3 = new File("target/test-classes/test-files2/fileWatcher2.properties");
3233

33-
final File propertiesFile2 = new File(PROPERTIES2);
34-
final Resource[] multipleResources = new Resource[] { new FileSystemResource(this.propertiesFile1), new FileSystemResource(this.propertiesFile2) };
34+
final Resource[] singleResource = new Resource[] { new FileSystemResource(this.propertiesFile1) };
35+
final Resource[] multiResourceSameDir = new Resource[] { new FileSystemResource(this.propertiesFile1), new FileSystemResource(this.propertiesFile2) };
36+
final Resource[] multiResourceDifferentDir = new Resource[] { new FileSystemResource(this.propertiesFile1), new FileSystemResource(this.propertiesFile3) };
3537

3638
@Test
3739
public final void testWatchingASingle() throws IOException, InterruptedException {
@@ -41,44 +43,64 @@ public final void testWatchingASingle() throws IOException, InterruptedException
4143
confirmTestDataNotSet();
4244

4345
startPropertiesWatcher(propertiesWatcher);
44-
wait(1000);
46+
wait(_1_SEC);
4547

4648
modifyPropertiesFile(this.propertiesFile1);
47-
wait(2000);
49+
wait(_2_SEC);
4850
confirmPropertiesFileModified(this.propertiesFile1);
4951

5052
propertiesWatcher.stop();
51-
wait(1000);
53+
wait(_2_SEC);
5254
}
5355

5456
@Test
5557
public final void testWatchingMulitipleResourcesInDifferingDirectories() throws IOException, InterruptedException {
56-
resetCountDownLatch(this.multipleResources.length);
58+
resetCountDownLatch(this.multiResourceDifferentDir.length);
5759

58-
final PropertiesWatcher propertiesWatcher = createPropertiesWatcher(this.multipleResources);
60+
final PropertiesWatcher propertiesWatcher = createPropertiesWatcher(this.multiResourceDifferentDir);
5961
confirmTestDataNotSet();
6062

6163
startPropertiesWatcher(propertiesWatcher);
62-
wait(1000);
64+
wait(_1_SEC);
6365

64-
modifyPropertiesFile(this.propertiesFile2);
65-
wait(2000);
66-
confirmPropertiesFileModified(this.propertiesFile2);
66+
modifyPropertiesFile(this.propertiesFile3);
67+
wait(_2_SEC);
68+
confirmPropertiesFileModified(this.propertiesFile3);
6769

6870
resetTestData();
6971
confirmTestDataNotSet();
7072

7173
modifyPropertiesFile(this.propertiesFile1);
72-
wait(2000);
74+
wait(_2_SEC);
7375
confirmPropertiesFileModified(this.propertiesFile1);
7476

7577
propertiesWatcher.stop();
76-
wait(1000);
78+
wait(_1_SEC);
7779
}
7880

7981
@Test
8082
public final void testModifyingADifferentResoruceInSameDirectory() throws IOException, InterruptedException {
83+
resetCountDownLatch(this.multiResourceSameDir.length);
84+
85+
final PropertiesWatcher propertiesWatcher = createPropertiesWatcher(this.multiResourceSameDir);
86+
confirmTestDataNotSet();
87+
88+
startPropertiesWatcher(propertiesWatcher);
89+
wait(_1_SEC);
90+
91+
modifyPropertiesFile(this.propertiesFile1);
92+
wait(_2_SEC);
93+
confirmPropertiesFileModified(this.propertiesFile1);
94+
95+
resetTestData();
96+
confirmTestDataNotSet();
8197

98+
modifyPropertiesFile(this.propertiesFile2);
99+
wait(_2_SEC);
100+
confirmPropertiesFileModified(this.propertiesFile2);
101+
102+
propertiesWatcher.stop();
103+
wait(_1_SEC);
82104
}
83105

84106
private void resetCountDownLatch(final int count) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Sun Jul 15 12:18:45 BST 2012
2+
dynamicProperty.longValue=12345
3+
dynamicProperty.substitutionProperty=${dynamicProperty.substitutionValue}
4+
dynamicProperty.doubleValue=12345.67
5+
dynamicProperty.localTimeValue=12:22:45
6+
dynamicProperty.stringValue=Injected String Value
7+
dynamicProperty.substitutionValue=elephant
8+
dynamicProperty.bigDecimalValue=20012.56
9+
dynamicProperty.intValue=42
10+
dynamicProperty.localDateValue=2009-06-12
11+
dynamicProperty.periodValue=00:12:22
12+
dynamicProperty.booleanValue=true
13+
dynamicProperty.localDateTimeValue=2009-07-05 12:56:02
14+
invalid.period=12:22:
15+
dynamicProperty.bigIntegerValue=224411

0 commit comments

Comments
 (0)