Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify logger & Enforce Logger by Architecture Test #1411

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions endtoend-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

import org.apache.commons.lang3.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.jplag.endtoend.model.DataSet;

public class UnzipManager {
private final Map<DataSet, File> unzippedFiles;
private static UnzipManager instance;
private final Logger logger = Logger.getLogger("Unzip Manager");
private final Logger logger = LoggerFactory.getLogger(UnzipManager.class);

private static synchronized UnzipManager getInstance() {
if (instance == null) {
Expand Down Expand Up @@ -46,7 +47,7 @@ private File unzipOrCacheInternal(DataSet dataSet, File zip) throws IOException
} else {
target = Files.createTempDirectory(zip.getName()).toFile();
if (!(target.setReadable(true, true) && target.setWritable(true, true) && target.setExecutable(true, true))) {
logger.warning("Could not set permissions for temp directory (" + target.getAbsolutePath() + ").");
logger.warn("Could not set permissions for temp directory ({}).", target.getAbsolutePath());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.jplag.endtoend.architecture;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;

import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;

@AnalyzeClasses(packages = "de.jplag")
public class JPlagArchitectureTest {
@ArchTest
public static final ArchRule enforceCorrectLogger = noClasses().should().accessClassesThat()
.haveNameMatching(java.util.logging.Logger.class.getName());

@ArchTest
public static final ArchRule enforceNameOfLogger = fields().that().haveRawType(org.slf4j.Logger.class).should().haveName("logger");
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.jplag.Language;
import de.jplag.ParsingException;
Expand All @@ -40,7 +40,7 @@
public abstract class LanguageModuleTest {
private static final Path DEFAULT_TEST_CODE_PATH_BASE = Path.of("src", "test", "resources", "de", "jplag");

private final Logger LOG = Logger.getLogger(this.getClass().getName());
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private final TestDataCollector collector;
private final Language language;
Expand Down Expand Up @@ -253,7 +253,7 @@ final void collectTestData() {

private List<Token> parseTokens(TestData source) throws ParsingException, IOException {
List<Token> tokens = source.parseTokens(this.language);
LOG.log(Level.INFO, TokenPrinter.printTokens(tokens));
logger.info(TokenPrinter.printTokens(tokens));
return tokens;
}

Expand Down
Loading