Skip to content

Commit

Permalink
Fix #4262: Add startup test for SLF4J
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Dec 16, 2024
1 parent 66c8bd4 commit 5bd176d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions extended-it/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test {
dependencies {
apt project(':processor')
apt group: 'org.neo4j', name: 'neo4j', version: neo4jVersionEffective // mandatory to run @ServiceProvider based META-INF code generation
api group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.36'

def withoutJacksons = {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import apoc.util.TestContainerUtil.Neo4jVersion;
import apoc.util.TestUtil;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.neo4j.driver.Session;
Expand All @@ -23,7 +24,9 @@
import static apoc.util.TestContainerUtil.ApocPackage.CORE;
import static apoc.util.TestContainerUtil.ApocPackage.EXTENDED;
import static apoc.util.TestContainerUtil.createDB;
import static apoc.util.TestContainerUtil.dockerImageForNeo4j;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -105,6 +108,11 @@ private void startContainerSessionWithExtraDeps(Function<Neo4jVersion, Neo4jCont
neo4jContainer.start();
assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());

String startupLog = neo4jContainer.getLogs();

assertFalse(startupLog.contains("SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\""));
assertFalse(startupLog.contains("SLF4J: Class path contains multiple SLF4J providers"));

final Session session = neo4jContainer.getSession();

sessionConsumer.accept(session);
Expand All @@ -113,8 +121,10 @@ private void startContainerSessionWithExtraDeps(Function<Neo4jVersion, Neo4jCont
if (TestContainerUtil.isDockerImageAvailable(ex)) {
ex.printStackTrace();
fail("Should not have thrown exception when trying to start Neo4j: " + ex);
} else if (!TestUtil.isRunningInCI()) {
fail( "The docker image " + dockerImageForNeo4j(version) + " could not be loaded. Check whether it's available locally / in the CI. Exception:" + ex);
} else {
fail("The docker image could not be loaded. Check whether it's available locally / in the CI. Exception:" + ex);
fail( "The docker image " + dockerImageForNeo4j(version) + " could not be loaded. Check whether it's available locally / in the CI. Exception:" + ex);
}
}
}
Expand Down

0 comments on commit 5bd176d

Please sign in to comment.