From a1d5d542cebeee49fda76f71af01285fb00ae5ee Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 17 May 2024 15:56:11 +0100 Subject: [PATCH] JAL-4420 Tests for new FileUtils methods --- test/jalview/util/FileUtilsTest.java | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) 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." }, + /* + */ + // + }; + } } -- 1.7.10.2