Skip to content

Commit

Permalink
Issue #1200 Improve PathWatcher
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 08b5acc
Merge: cea3366 daeb844
Author: Greg Wilkins <[email protected]>
Date:   Tue Sep 5 12:43:01 2017 +1000

    Merge branch 'jetty-9.4.x' into jetty-9.4.x-1200

commit cea3366
Author: Greg Wilkins <[email protected]>
Date:   Tue Sep 5 12:42:21 2017 +1000

    Issue #1200 ignore OSX failure

commit fd2493f
Author: Greg Wilkins <[email protected]>
Date:   Tue Sep 5 12:11:05 2017 +1000

    Issue #1789 PropertyUserStoreTest failures on windows

commit 89aa59c
Author: Greg Wilkins <[email protected]>
Date:   Tue Sep 5 11:56:52 2017 +1000

    Issue #1200 fixes for windows

commit 1904b45
Merge: 74d770e eec6453
Author: Greg Wilkins <[email protected]>
Date:   Tue Sep 5 11:45:19 2017 +1000

    Merge branch 'jetty-9.4.x' into jetty-9.4.x-1200

commit 74d770e
Author: Greg Wilkins <[email protected]>
Date:   Fri Sep 1 10:47:05 2017 +1000

    Issue #1200 fixes for windows

commit f4ee0e9
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 10:24:07 2017 +1000

    Issue #1200 improved tests for long duration quiet time

commit 17381cb
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 10:03:04 2017 +1000

    Issue #1200 fixed javadoc

commit b3a12c1
Merge: ed0db46 ce4adb5
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 09:41:50 2017 +1000

    Merge branch 'jetty-9.4.x-1200' of github.com:eclipse/jetty.project into jetty-9.4.x-1200

commit ed0db46
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 09:39:46 2017 +1000

    Issue #1200 Improved PathWatcher

commit ce4adb5
Merge: f993a7c 48aaecb
Author: Joakim Erdfelt <[email protected]>
Date:   Wed Aug 30 16:38:07 2017 -0700

    Merge branch 'jetty-9.4.x-1200' of github.com:eclipse/jetty.project into jetty-9.4.x-1200

commit f993a7c
Author: Joakim Erdfelt <[email protected]>
Date:   Wed Aug 30 16:37:45 2017 -0700

    Issue #1200 - adding some important OSX/HFS+ timing differences

    + We should really be testing the FileSystem (not the OS) to make the timing
       constants be more sane. (APFS for example should be much lower on newer
       OSX installations

commit 48aaecb
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 08:50:42 2017 +1000

    Issue #1200 Improved PathWatcher diff

commit 1917f8b
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 08:36:40 2017 +1000

    Issue #1200 Improved PathWatcher diff

commit ecf0023
Author: Greg Wilkins <[email protected]>
Date:   Thu Aug 31 08:22:41 2017 +1000

    Issue #1200 Test improved PathWatcher

commit 0d76544
Merge: 0fd7187 eb1320f
Author: Greg Wilkins <[email protected]>
Date:   Wed Aug 30 16:43:15 2017 +1000

    Merge branch 'jetty-9.4.x' into jetty-9.4.x-1200

commit 0fd7187
Author: Greg Wilkins <[email protected]>
Date:   Wed Aug 30 15:58:24 2017 +1000

    Issue #1200 Improve PathWatcher
  • Loading branch information
gregw committed Sep 5, 2017
1 parent daeb844 commit bc47942
Show file tree
Hide file tree
Showing 4 changed files with 1,038 additions and 682 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilePermission;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -139,7 +145,7 @@ private String initUsersPackedFileText()
}

}
return "jar:file:" + usersJar.getCanonicalPath() + "!/" + entryPath;
return "jar:" + usersJar.toURI().toASCIIString() + "!/" + entryPath;
}

private void writeUser(File usersFile)
Expand Down Expand Up @@ -205,30 +211,47 @@ public void testPropertyUserStoreLoadFromJarFile() throws Exception
userCount.awaitCount(3);
}


@Test
public void testPropertyUserStoreLoadUpdateUser() throws Exception
{
assumeThat("Skipping on OSX", OS.IS_OSX, is(false));
final UserCount userCount = new UserCount();
final File usersFile = initUsersText();

PropertyUserStore store = new PropertyUserStore();
final AtomicInteger loadCount = new AtomicInteger(0);
PropertyUserStore store = new PropertyUserStore()
{
@Override
protected void loadUsers() throws IOException
{
loadCount.incrementAndGet();
super.loadUsers();
}
};
store.setHotReload(true);
store.setConfigFile(usersFile);

store.registerUserListener(userCount);

store.start();

userCount.assertThatCount(is(3));

assertThat(loadCount.get(),is(1));

addAdditionalUser(usersFile,"skip: skip, roleA\n");

userCount.awaitCount(4);

assertThat("Failed to retrieve UserIdentity from PropertyUserStore directly", store.getUserIdentity("skip"), notNullValue());
assertThat(loadCount.get(),is(2));
assertThat(store.getUserIdentity("skip"), notNullValue());
userCount.assertThatCount(is(4));
userCount.assertThatUsers(hasItem("skip"));

if (OS.IS_LINUX)
Files.createFile(testdir.getPath().toRealPath().resolve("unrelated.txt"),
PosixFilePermissions.asFileAttribute(EnumSet.noneOf(PosixFilePermission.class)));
else
Files.createFile(testdir.getPath().toRealPath().resolve("unrelated.txt"));

Thread.sleep(1100);
assertThat(loadCount.get(),is(2));

userCount.assertThatCount(is(4));
userCount.assertThatUsers(hasItem("skip"));
}
Expand Down
Loading

0 comments on commit bc47942

Please sign in to comment.