diff options
Diffstat (limited to 'utils-test')
2 files changed, 18 insertions, 9 deletions
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/test/log/logback/ExtractAppender.java b/utils-test/src/main/java/org/onap/policy/common/utils/test/log/logback/ExtractAppender.java index 5ccb13ee..19c50968 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/test/log/logback/ExtractAppender.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/test/log/logback/ExtractAppender.java @@ -2,7 +2,7 @@ * ============LICENSE_START==================================================== * Common Utils-Test * ============================================================================= - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public class ExtractAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(final ILoggingEvent event) { - String msg = event.getMessage(); + String msg = event.getFormattedMessage(); synchronized (patterns) { if (patterns.isEmpty()) { diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/test/log/logback/ExtractAppenderTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/test/log/logback/ExtractAppenderTest.java index eee60c38..e01ed417 100644 --- a/utils-test/src/test/java/org/onap/policy/common/utils/test/log/logback/ExtractAppenderTest.java +++ b/utils-test/src/test/java/org/onap/policy/common/utils/test/log/logback/ExtractAppenderTest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * Common Utils-Test * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -206,6 +206,15 @@ public class ExtractAppenderTest { } @Test + public void testAppendILoggingEvent_Formatted() { + ExtractAppender appender = makeAppender(); + + logger.info("hello {} world{}", "there", "!"); + + assertEquals(strList("hello there world!"), appender.getExtracted()); + } + + @Test public void testAppendILoggingEvent_MatchFirstPattern() { ExtractAppender appender = makeAppender("abc[0-9]", "def[0-9]"); @@ -402,7 +411,7 @@ public class ExtractAppenderTest { /** * Adds multiple threads to perform some function repeatedly until the given time is reached. - * + * * @param tend time, in milliseconds, when the test should terminate * @param haderr this will be set to {@code true} if the function throws an exception other than * an InterruptedException @@ -437,7 +446,7 @@ public class ExtractAppenderTest { /** * Makes an appender that recognizes the given set of strings. - * + * * @param strings regular expressions to be matched * @return a new appender */ @@ -451,7 +460,7 @@ public class ExtractAppenderTest { /** * Adds an appender to the logger. - * + * * @param app appender to be added */ private void addAppender(ExtractAppender app) { @@ -463,7 +472,7 @@ public class ExtractAppenderTest { /** * Converts an array of strings into a list of strings. - * + * * @param strings array of strings * @return a list of the strings */ |