This is an automated email from the ASF dual-hosted git repository.
lewismc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-mudrod.git
The following commit(s) were added to refs/heads/master by this push:
new bbc4c89 SDAP-180 fixes failed test for Apache access logs. (#40)
bbc4c89 is described below
commit bbc4c89e1d4f47fc744d7b945ca363f3d3273059
Author: Furkan KAMACI <[email protected]>
AuthorDate: Wed Feb 13 22:32:12 2019 +0300
SDAP-180 fixes failed test for Apache access logs. (#40)
---
.../sdap/mudrod/weblog/structure/log/ApacheAccessLog.java | 4 ++--
.../sdap/mudrod/weblog/structure/TestApacheAccessLog.java | 11 +++--------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git
a/core/src/main/java/org/apache/sdap/mudrod/weblog/structure/log/ApacheAccessLog.java
b/core/src/main/java/org/apache/sdap/mudrod/weblog/structure/log/ApacheAccessLog.java
index 8224b33..6ffd3be 100644
---
a/core/src/main/java/org/apache/sdap/mudrod/weblog/structure/log/ApacheAccessLog.java
+++
b/core/src/main/java/org/apache/sdap/mudrod/weblog/structure/log/ApacheAccessLog.java
@@ -57,9 +57,9 @@ public class ApacheAccessLog extends WebLog implements
Serializable {
super();
}
- public static String parseFromLogLine(String log, Properties props) throws
IOException, ParseException {
+ public static String parseFromLogLine(String log, Properties props) throws
ParseException {
- String logEntryPattern = "^([\\d.]+) (\\S+) (\\S+)
\\[([\\w:/]+\\s[+\\-]\\d{4})\\] \"(.+?)\" (\\d{3}) (\\d+|-) \"((?:[^\"]|\")+)\"
\"([^\"]+)\"";
+ String logEntryPattern = "^([\\d.]+) (\\S+) (\\S+)
\\[([\\w:/]+\\s[+\\-]\\d{4})] \"(.+?)\" (\\d{3}) (\\d+|-) \"((?:[^\"]|\")+)\"
\"([^\"]+)\"";
final int numFields = 9;
Pattern p = Pattern.compile(logEntryPattern);
Matcher matcher;
diff --git
a/core/src/test/java/org/apache/sdap/mudrod/weblog/structure/TestApacheAccessLog.java
b/core/src/test/java/org/apache/sdap/mudrod/weblog/structure/TestApacheAccessLog.java
index b4aebed..a0e51d8 100644
---
a/core/src/test/java/org/apache/sdap/mudrod/weblog/structure/TestApacheAccessLog.java
+++
b/core/src/test/java/org/apache/sdap/mudrod/weblog/structure/TestApacheAccessLog.java
@@ -34,23 +34,18 @@ public class TestApacheAccessLog {
@BeforeClass
public static void loadProperties() throws IOException {
-
URL configURL =
ClassLoader.getSystemClassLoader().getResource("config.properties");
-
assert configURL != null : "Could not load config.properties";
+
try (InputStream instream = new FileInputStream(configURL.getFile())) {
testProperties.load(instream);
}
}
@Test
- public void testLogMatch() throws IOException, ParseException {
-
-
- String testLogLine = "198.118.243.84 - - [31/Dec/2017:23:59:20 +0000]
\"GET
/events?page=12&%25252525252525252525252525252525252525253Bsort=asc&order=field_location&sort=desc
HTTP/1.1\" 200 86173";
-
+ public void testLogMatch() throws ParseException {
+ String testLogLine = "198.118.243.84 - - [31/Dec/2017:23:59:20 +0000]
\"GET
/events?page=12&%25252525252525252525252525252525252525253Bsort=asc&order=field_location&sort=desc
HTTP/1.1\" 200 86173 \"http://www.example.com/start.html\" \"Mozilla/4.08 [en]
(Win98; I ;Nav)\"";
String result = ApacheAccessLog.parseFromLogLine(testLogLine,
testProperties);
-
assertNotEquals("Log line does not match", "{}", result);
}
}