From 889c5cc75ef8a5b9313cf9300e35b5d68925f0bf Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Mon, 10 Jun 2019 21:32:02 +0200 Subject: Create unit tests for special characters in path names Create a regression test for issue #999. Add directories with '[]' ans '()' in the name to the hello-world repository, so that they can be used in unit tests for repository paths with special characters. --- src/test/data/hello-world.git.zip | Bin 55129 -> 76158 bytes src/test/data/hello-world.properties | 8 ++++++-- src/test/java/com/gitblit/tests/JGitUtilsTest.java | 14 +++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/data/hello-world.git.zip b/src/test/data/hello-world.git.zip index e1057a6b..ef378f23 100644 Binary files a/src/test/data/hello-world.git.zip and b/src/test/data/hello-world.git.zip differ diff --git a/src/test/data/hello-world.properties b/src/test/data/hello-world.properties index 99ed126b..7828a8ce 100644 --- a/src/test/data/hello-world.properties +++ b/src/test/data/hello-world.properties @@ -5,5 +5,9 @@ commit.fifteen=5ebfaca commit.added=192cded commit.changed=b2c50ce commit.deleted=8613bee10bde27a0fbaca66447cdc3f0f9483365 -users.byEmail=9 -users.byName=8 +users.byEmail=11 +users.byName=10 +files.top=14 +files.C.top=2 +files.C.KnR=1 +files.Cpp=1 \ No newline at end of file diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java index 5f083555..a493884a 100644 --- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java +++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java @@ -596,10 +596,22 @@ public class JGitUtilsTest extends GitblitUnitTest { @Test public void testFilesInPath2() throws Exception { assertEquals(0, JGitUtils.getFilesInPath2(null, null, null).size()); + Repository repository = GitBlitSuite.getHelloworldRepository(); + List files = JGitUtils.getFilesInPath2(repository, null, null); + assertEquals(GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.files.top, 15), files.size()); + + files = JGitUtils.getFilesInPath2(repository, "C", null); + assertEquals(GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.files.C.top, 1), files.size()); + + files = JGitUtils.getFilesInPath2(repository, "[C++]", null); + assertEquals(GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.files.Cpp, 1), files.size()); + + files = JGitUtils.getFilesInPath2(repository, "C/C (K&R)", null); + assertEquals(GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.files.C.KnR, 1), files.size()); + repository.close(); - assertTrue(files.size() > 10); } @Test -- cgit v1.2.3