use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveUserFunctionTest method shouldNotLoadAnyFunctionIfConfigIsEmpty.
@Test
public void shouldNotLoadAnyFunctionIfConfigIsEmpty() throws Throwable {
// Given
Log log = spy(Log.class);
procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, new ProcedureConfig(Config.defaults().with(MapUtil.stringMap(GraphDatabaseSettings.procedure_whitelist.name(), ""))));
List<CallableUserFunction> method = compile(SingleReadOnlyFunction.class);
verify(log).warn("The function 'org.neo4j.kernel.impl.proc.listCoolPeople' is not on the whitelist and won't be loaded.");
assertThat(method.size(), equalTo(0));
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ConfiguringPageCacheFactoryTest method mustUseAndLogConfiguredPageSwapper.
@Test
public void mustUseAndLogConfiguredPageSwapper() throws Exception {
// Given
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), "8m", pagecache_swapper.name(), TEST_PAGESWAPPER_NAME));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log log = logProvider.getLog(PageCache.class);
// When
new ConfiguringPageCacheFactory(fsRule.get(), config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, log);
// Then
assertThat(PageSwapperFactoryForTesting.countCreatedPageSwapperFactories(), is(1));
assertThat(PageSwapperFactoryForTesting.countConfiguredPageSwapperFactories(), is(1));
logProvider.assertContainsMessageContaining(TEST_PAGESWAPPER_NAME);
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldSupportProcedureDeprecation.
@Test
public void shouldSupportProcedureDeprecation() throws Throwable {
// Given
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, ProcedureConfig.DEFAULT);
// When
List<CallableProcedure> procs = procedureCompiler.compileProcedure(ProcedureWithDeprecation.class, Optional.empty(), true);
// Then
verify(log).warn("Use of @Procedure(deprecatedBy) without @Deprecated in badProc");
verifyNoMoreInteractions(log);
for (CallableProcedure proc : procs) {
String name = proc.signature().name().name();
proc.apply(new BasicContext(), new Object[0]);
switch(name) {
case "newProc":
assertFalse("Should not be deprecated", proc.signature().deprecated().isPresent());
break;
case "oldProc":
case "badProc":
assertTrue("Should be deprecated", proc.signature().deprecated().isPresent());
assertThat(proc.signature().deprecated().get(), equalTo("newProc"));
break;
default:
fail("Unexpected procedure: " + name);
}
}
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldNotLoadAnyProcedureIfConfigIsEmpty.
@Test
public void shouldNotLoadAnyProcedureIfConfigIsEmpty() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "")));
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
// When
List<CallableProcedure> proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), false);
// Then
verify(log).warn("The procedure 'org.neo4j.kernel.impl.proc.listCoolPeople' is not on the whitelist and won't be loaded.");
assertThat(proc.isEmpty(), is(true));
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldIgnoreWhiteListingIfFullAccess.
@Test
public void shouldIgnoreWhiteListingIfFullAccess() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "empty")));
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), true).get(0);
// Then
RawIterator<Object[], ProcedureException> result = proc.apply(new BasicContext(), new Object[0]);
assertEquals(result.next()[0], "Bonnie");
}
Aggregations