<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ 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.
  -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>${revision}</version>
    <relativePath>../log4j-parent</relativePath>
  </parent>

  <artifactId>log4j-core-test</artifactId>

  <name>Apache Log4j Core Tests</name>
  <description>The Apache Log4j Implementation Tests</description>

  <properties>
    <log4j.docgen.skip>true</log4j.docgen.skip>
    <!-- Ignore less important (high rank) bugs for test artifacts -->
    <spotbugs.maxRank>9</spotbugs.maxRank>

    <!--
      ~ OSGi and JPMS options
      -->
    <bnd-module-name>org.apache.logging.log4j.core.test</bnd-module-name>
    <bnd-extra-package-options>
      <!-- Both JUnit 4 and JUnit 5 are not required -->
      org.junit.*;resolution:=optional,
      org.hamcrest.*;resolution:=optional,
      org.junitpioneer.*;resolution:=optional,
      com.google.monitoring.*;resolution:=optional,
      javax.tools;resolution:=optional,
      org.assertj.*;resolution:=optional,
      org.awaitility.*;resolution:=optional,
      org.springframework.mock.*;resolution:=optional
    </bnd-extra-package-options>
    <bnd-extra-module-options>
      <!-- Non-transitive modules -->
      junit;transitive=false,
      org.hamcrest;transitive=false,
      org.junit.jupiter.api;transitive=false,
      <!-- Name changes -->
      java.allocation.instrumenter;substitute="java-allocation-instrumenter",
      spring.test;substitute="spring-test"
    </bnd-extra-module-options>

    <!-- Additional version of LMAX Disruptor to test -->
    <disruptor4.version>4.0.0</disruptor4.version>
    <json-unit.version>2.40.1</json-unit.version>
    <bouncycastle.version>1.83</bouncycastle.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk18on</artifactId>
        <version>${bouncycastle.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api-test</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
    </dependency>

    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
    </dependency>

    <!-- GC-free -->
    <dependency>
      <groupId>com.google.code.java-allocation-instrumenter</groupId>
      <artifactId>java-allocation-instrumenter</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-commons</artifactId>
    </dependency>

    <!-- Needed for JNDI mocks using `org.springframework.mock.jndi` -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
    </dependency>

    <!-- JNDI and JMS tests -->
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-broker</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-jms_1.1_spec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache-extras.beanshell</groupId>
      <artifactId>bsh</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcpkix-jdk18on</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Other -->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Used for compressing to formats other than zip and gz -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-csv</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Alternative implementation of BlockingQueue using Conversant Disruptor for AsyncAppender -->
    <dependency>
      <groupId>com.conversantmedia</groupId>
      <artifactId>disruptor</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Required for AsyncLoggers -->
    <dependency>
      <groupId>com.lmax</groupId>
      <artifactId>disruptor</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.zapodot</groupId>
      <artifactId>embedded-ldap-junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-dateutil</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Embedded JDBC drivers for database appender tests -->
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <classifier>jdk8</classifier>
      <scope>test</scope>
    </dependency>

    <!-- Required for JSON support -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Required for XML layout and receiver support -->
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-xml</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Required for YAML support (including JSON requirements) -->
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Used for JMS appenders (needs an implementation of course) -->
    <dependency>
      <groupId>javax.jms</groupId>
      <artifactId>javax.jms-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jspecify</groupId>
      <artifactId>jspecify</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>javax.mail</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>javax.mail-api</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Alternative implementation of BlockingQueue using JCTools for AsyncAppender -->
    <dependency>
      <groupId>org.jctools</groupId>
      <artifactId>jctools-core</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Used for ZeroMQ JeroMQ appender -->
    <dependency>
      <groupId>org.zeromq</groupId>
      <artifactId>jeromq</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Zeroconf advertiser tests -->
    <dependency>
      <groupId>org.jmdns</groupId>
      <artifactId>jmdns</artifactId>
      <scope>test</scope>
    </dependency>

    <!--  GELF and other tests that use JSON -->
    <dependency>
      <groupId>net.javacrumbs.json-unit</groupId>
      <artifactId>json-unit-assertj</artifactId>
      <version>${json-unit.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>net.javacrumbs.json-unit</groupId>
      <artifactId>json-unit</artifactId>
      <version>${json-unit.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit-pioneer</groupId>
      <artifactId>junit-pioneer</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- JUnit, naturally -->
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Used for Kafka appender -->
    <dependency>
      <groupId>org.apache.kafka</groupId>
      <artifactId>kafka-clients</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Mocking framework for use with JUnit -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Used for testing HttpAppender -->
    <dependency>
      <groupId>com.github.tomakehurst</groupId>
      <artifactId>wiremock-jre8</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.xmlunit</groupId>
      <artifactId>xmlunit-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.xmlunit</groupId>
      <artifactId>xmlunit-matchers</artifactId>
      <scope>test</scope>
    </dependency>

    <!--  Apache Commons Compress -->
    <dependency>
      <groupId>org.tukaani</groupId>
      <artifactId>xz</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.github.luben</groupId>
      <artifactId>zstd-jni</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>test-disruptor-4</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <additionalClasspathDependencies>
                <dependency>
                  <groupId>com.lmax</groupId>
                  <artifactId>disruptor</artifactId>
                  <version>${disruptor4.version}</version>
                </dependency>
              </additionalClasspathDependencies>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>com.lmax:disruptor</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <groups>org.apache.logging.log4j.core.test.categories.AsyncLoggers</groups>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <profiles>

    <!-- Fixes incompatible with Java 8 -->
    <profile>

      <id>java8-incompat-fixes</id>

      <!-- CI uses Java 8 for running tests.
           Hence, we assume CI=Java8 and apply our changes elsewhere.

           One might think why not activate using `<jdk>[16,)` instead?
           This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
           These two JDKs can differ due to Maven Toolchains.
           See `java8-tests` profile in `/pom.xml` for details. -->
      <activation>
        <property>
          <name>!env.CI</name>
        </property>
      </activation>

      <!-- JEP-335 has deprecated the built-in JavaScript engine (Nashorn) in Java 11, and JEP-372 removed it in Java 15.
           We are adding it back for tests that use JavaScript. -->
      <dependencies>
        <dependency>
          <groupId>org.openjdk.nashorn</groupId>
          <artifactId>nashorn-core</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <!-- Illegal access is disabled by default in Java 16 due to JEP-396.
           We are relaxing it for tests. -->
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <argLine>--add-opens java.base/java.lang=ALL-UNNAMED
                --add-opens java.base/java.net=ALL-UNNAMED
                --add-opens java.base/java.util=ALL-UNNAMED</argLine>
            </configuration>
          </plugin>
        </plugins>
      </build>

    </profile>

    <!--
      ~ Dummy profile to force Dependabot to upgrade `disruptor4.version`.
      ~ Using this profile causes a compilation error.
      -->
    <profile>
      <id>disruptor-4</id>
      <dependencies>
        <dependency>
          <groupId>com.lmax</groupId>
          <artifactId>disruptor</artifactId>
          <version>${disruptor4.version}</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

</project>
