From c330ac064d7cf2f04f1c7674b84b835471fc6c18 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Mon, 23 Sep 2024 03:16:33 +0200 Subject: [PATCH] Improved Javadoc and added test for isPage method. --- .../httpaccess/HttpAccessLogAnalyzer.java | 16 +++++++++++++- .../HttpAccessLogsAnalyzerTest.java | 21 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogAnalyzer.java index 1cd1113..e334a59 100644 --- a/src/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogAnalyzer.java @@ -307,7 +307,21 @@ public class HttpAccessLogAnalyzer /** * Checks if is page. - * + * + *
+     * null             => false
+     * ""               => false
+     * "     "          => false
+     * "GET /foo"       => true
+     * "GET /foo42"     => true
+     * "GET /foo.cgi"   => true
+     * "GET /foo.htm"  => true
+     * "GET /foo.html"  => true
+     * "GET /foo.php"   => true
+     * "GET /foo.xhtml"  => true
+     * "GET /foo.jpg"   => false
+     * 
+ * * @param request * the request * @return true, if is page diff --git a/test/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogsAnalyzerTest.java b/test/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogsAnalyzerTest.java index 1978c51..3535da9 100644 --- a/test/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogsAnalyzerTest.java +++ b/test/fr/devinsy/statoolinfos/metrics/httpaccess/HttpAccessLogsAnalyzerTest.java @@ -38,6 +38,27 @@ import fr.devinsy.statoolinfos.util.FilesUtils; */ public class HttpAccessLogsAnalyzerTest { + /** + * Checks if is page test 01. + */ + @Test + public void isPageTest01() + { + Assert.assertFalse(HttpAccessLogAnalyzer.isPage(null)); + Assert.assertFalse(HttpAccessLogAnalyzer.isPage("")); + Assert.assertFalse(HttpAccessLogAnalyzer.isPage(" ")); + + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo")); + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo42")); + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo.html")); + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo.HTML")); + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo.HtMl")); + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo.HtMl")); + + Assert.assertTrue(HttpAccessLogAnalyzer.isPage("GET /foo/bar/foo.php")); + Assert.assertFalse(HttpAccessLogAnalyzer.isPage("GET /foo.jpg")); + } + /** * @throws Exception */