Skip to content

Commit

Permalink
[NOID] Add back mistakenly removed test (#3716)
Browse files Browse the repository at this point in the history
  • Loading branch information
gem-neo4j authored Aug 9, 2023
1 parent 241789e commit 42b3b81
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/src/test/java/apoc/ApocConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package apoc;

import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -32,8 +33,10 @@
import org.neo4j.logging.internal.SimpleLogService;
import org.neo4j.procedure.impl.GlobalProceduresRegistry;

import static apoc.ApocConfig.APOC_MAX_DECOMPRESSION_RATIO;
import static apoc.ApocConfig.SUN_JAVA_COMMAND;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -93,4 +96,24 @@ public void testDetermineNeo4jConfFolderWithWhitespaces() {
assertEquals("/home/stefan/neo4j enterprise-4.0.0-alpha09mr02/conf", apocConfig.determineNeo4jConfFolder());
}

@Test
public void testMaxDecompressionRatioValidation() {

LogProvider logProvider = new AssertableLogProvider();

Config neo4jConfig = mock(Config.class);
when(neo4jConfig.getDeclaredSettings()).thenReturn(Collections.emptyMap());
when(neo4jConfig.get(any())).thenReturn(null);
when(neo4jConfig.expandCommands()).thenReturn(false);

GlobalProceduresRegistry registry = mock(GlobalProceduresRegistry.class);
DatabaseManagementService databaseManagementService = mock(DatabaseManagementService.class);
System.setProperty(APOC_MAX_DECOMPRESSION_RATIO, "0");
ApocConfig apocConfig = new ApocConfig(neo4jConfig, new SimpleLogService(logProvider), registry, databaseManagementService);

RuntimeException e = assertThrows(RuntimeException.class, apocConfig::init);
String expectedMessage = String.format("value 0 is not allowed for the config option %s", APOC_MAX_DECOMPRESSION_RATIO);
Assertions.assertThat(e.getMessage()).contains(expectedMessage);
System.clearProperty(APOC_MAX_DECOMPRESSION_RATIO);
}
}

0 comments on commit 42b3b81

Please sign in to comment.