Skip to content

Commit

Permalink
Coverage updated. Log4j2 configuration added.
Browse files Browse the repository at this point in the history
  • Loading branch information
DjThunder committed Dec 31, 2023
1 parent 8768d47 commit 2d3d14f
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 2 deletions.
5 changes: 5 additions & 0 deletions sample-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<groupId>com.b3dgs.sample</groupId>
<artifactId>sample-game</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.b3dgs.sample</groupId>
<artifactId>sample-pc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.b3dgs.sample.editor</groupId>
Expand Down
1 change: 1 addition & 0 deletions sample-pc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/bin
/target
/META-INF/
/log
org.eclipse.core.resources.prefs
org.eclipse.m2e.core.prefs
org.sonar.ide.eclipse.core.prefs
Expand Down
26 changes: 24 additions & 2 deletions sample-pc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,33 @@
<packaging>jar</packaging>
<name>Sample PC</name>
<properties>
<jdk.version>17</jdk.version>
<jdk-release.version>${jdk.version}</jdk-release.version>
<checkstyle.skip>true</checkstyle.skip>
<log4j2.version>2.22.1</log4j2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>com.b3dgs.lionengine</groupId>
<artifactId>lionengine-core</artifactId>
<version>${lionengine.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.b3dgs.lionengine</groupId>
<artifactId>lionengine-core-awt</artifactId>
Expand Down
27 changes: 27 additions & 0 deletions sample-pc/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<!-- Logging Properties -->
<Properties>
<Property name="APP_LOG_NAME">sample</Property>
<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} %p %m%n</Property>
<Property name="APP_LOG_ROOT">log</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
<RollingFile name="File" fileName="${APP_LOG_ROOT}/${APP_LOG_NAME}.log" filePattern="${APP_LOG_ROOT}/${APP_LOG_NAME}-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<SizeBasedTriggeringPolicy size="2MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
50 changes: 50 additions & 0 deletions sample-pc/src/test/java/com/b3dgs/sample/pc/AppSampleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2013-2023 Byron 3D Games Studio (www.b3dgs.com) Pierre-Alexandre (contact@b3dgs.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.b3dgs.sample.pc;

import static com.b3dgs.lionengine.UtilAssert.assertPrivateConstructor;

import org.junit.jupiter.api.Test;

import com.b3dgs.lionengine.Engine;
import com.b3dgs.lionengine.UtilTests;

/**
* Test correct {@link AppSample} loading.
*/
final class AppSampleTest
{
/**
* Test the constructor.
*/
@Test
void testConstructorPrivate()
{
assertPrivateConstructor(AppSample.class);
}

/**
* Test app.
*/
@Test
void testApp()
{
AppSample.main(new String[] {});
UtilTests.pause(1000L);
Engine.terminate();
}
}

0 comments on commit 2d3d14f

Please # to comment.