From: Ben Soares Date: Fri, 17 May 2024 14:56:11 +0000 (+0100) Subject: JAL-4420 Tests for new FileUtils methods X-Git-Tag: Release_2_11_4_0~28^2~17 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a1d5d542cebeee49fda76f71af01285fb00ae5ee;p=jalview.git JAL-4420 Tests for new FileUtils methods --- diff --git a/test/jalview/util/FileUtilsTest.java b/test/jalview/util/FileUtilsTest.java index 666b33b..3cc9ca6 100644 --- a/test/jalview/util/FileUtilsTest.java +++ b/test/jalview/util/FileUtilsTest.java @@ -157,4 +157,54 @@ public class FileUtilsTest }; } + @Test( + groups = "Functional", + dataProvider = "stringFilenamesBaseAndExtensionsData") + public void stringGetBaseAndExtensionTest(String filename, + String extension, String base) + { + String thisBase = FileUtils.getBase(filename); + Assert.assertEquals(thisBase, base, + "base part of path and filename not as expected"); + String thisExtension = FileUtils.getExtension(filename); + Assert.assertEquals(thisExtension, extension, + "extension part of filename not as expected"); + } + + @DataProvider(name = "stringFilenamesBaseAndExtensionsData") + public Object[][] stringFilenamesBaseAndExtensionsData() + { + return new Object[][] { + /* + * String full URL or path + * String base the above but without the extension if there is one + * String extension the filename extension if there is one + */ + /* + */ + { "/examples/uniref50.fa", "fa", "/examples/uniref50." }, + { "/examples/uniref50", null, "/examples/uniref50" }, + { "/examples/.uniref50", null, "/examples/.uniref50" }, + { "/exampl.es/uniref50", null, "/exampl.es/uniref50" }, + { "/examples/uniref50.", "", "/examples/uniref50." }, + { "examples/uniref50.fa", "fa", "examples/uniref50." }, + { "examples/uniref50", null, "examples/uniref50" }, + { "examples/.uniref50", null, "examples/.uniref50" }, + { "exampl.es/uniref50", null, "exampl.es/uniref50" }, + { "examples/uniref50.", "", "examples/uniref50." }, + { "https://www.jalview.org:443/examples/uniref50.fa", "fa", + "https://www.jalview.org:443/examples/uniref50." }, + { "https://www.jalview.org:443/examples/uniref50", null, + "https://www.jalview.org:443/examples/uniref50" }, + { "https://www.jalview.org:443/examples/.uniref50", null, + "https://www.jalview.org:443/examples/.uniref50" }, + { "https://www.jalview.org:443/exampl.es/uniref50", null, + "https://www.jalview.org:443/exampl.es/uniref50" }, + { "https://www.jalview.org:443/examples/uniref50.", "", + "https://www.jalview.org:443/examples/uniref50." }, + /* + */ + // + }; + } }