This is an automated email from the ASF dual-hosted git repository. vy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/logging-log4j-scala.git
commit 468ab8cb1f4380043339fa1e0f0f5e43dfd154b2 Author: PJ Fanning <[email protected]> AuthorDate: Fri Sep 29 14:29:06 2023 +0100 add extra tests --- .editorconfig | 4 +- .../log4j/scala/LoggerFunctionCallTest.scala | 53 ++++++++++++++++++++++ .../log4j/scala/LoggerFunctionCallTest.scala | 1 + .../log4j/scala/LoggerFunctionCallTest.scala | 1 + .../log4j/scala/LoggerFunctionCallTest.scala | 1 + .../log4j/scala/LoggerFunctionCallTest.scala | 1 + 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6c3d154..624bf2c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,8 +18,8 @@ root = true [*] -indent_size = 4 -ij_continuation_indent_size = 8 +indent_size = 2 +ij_continuation_indent_size = 4 indent_style = space trim_trailing_whitespace = true diff --git a/log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala b/log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala new file mode 100644 index 0000000..1ddf0aa --- /dev/null +++ b/log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.scala + +import org.junit.runner.RunWith +import org.scalatest.matchers.should.Matchers +import org.scalatest.funsuite.AnyFunSuite +import org.scalatestplus.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +class LoggerFunctionCallTest extends AnyFunSuite with Matchers { + + val logger = Logger(classOf[LoggerFunctionCallTest]) + + test("interpolated call is not made if log level is not enabled") { + var logCount: Int = 0 + + def incrementAndGetLogCount(): Int = { + logCount += 1 + logCount + } + + logger.debug(s"logCount = ${incrementAndGetLogCount()}") + logCount shouldEqual 0 + } + + test("interpolated call is made if log level is enabled") { + var logCount: Int = 0 + + def incrementAndGetLogCount(): Int = { + logCount += 1 + logCount + } + + logger.error(s"logCount = ${incrementAndGetLogCount()}") + logCount shouldEqual 1 + } + +} diff --git a/log4j-api-scala_2.11/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala b/log4j-api-scala_2.11/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala new file mode 120000 index 0000000..68c302b --- /dev/null +++ b/log4j-api-scala_2.11/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala @@ -0,0 +1 @@ +../../../../../../../../../log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala \ No newline at end of file diff --git a/log4j-api-scala_2.12/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala b/log4j-api-scala_2.12/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala new file mode 120000 index 0000000..68c302b --- /dev/null +++ b/log4j-api-scala_2.12/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala @@ -0,0 +1 @@ +../../../../../../../../../log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala \ No newline at end of file diff --git a/log4j-api-scala_2.13/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala b/log4j-api-scala_2.13/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala new file mode 120000 index 0000000..68c302b --- /dev/null +++ b/log4j-api-scala_2.13/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala @@ -0,0 +1 @@ +../../../../../../../../../log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala \ No newline at end of file diff --git a/log4j-api-scala_3/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala b/log4j-api-scala_3/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala new file mode 120000 index 0000000..68c302b --- /dev/null +++ b/log4j-api-scala_3/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala @@ -0,0 +1 @@ +../../../../../../../../../log4j-api-scala_2.10/src/test/scala/org/apache/logging/log4j/scala/LoggerFunctionCallTest.scala \ No newline at end of file
