use of org.neo4j.logging.Log in project neo4j by neo4j.
the class PlatformModule method createPageCache.
protected PageCache createPageCache(FileSystemAbstraction fileSystem, Config config, LogService logging, Tracers tracers) {
Log pageCacheLog = logging.getInternalLog(PageCache.class);
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, tracers.pageCacheTracer, tracers.pageCursorTracerSupplier, pageCacheLog);
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
if (config.get(GraphDatabaseSettings.dump_configuration)) {
pageCacheFactory.dumpConfiguration();
}
return pageCache;
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveUserFunctionTest method shouldInjectLogging.
@Test
public void shouldInjectLogging() throws KernelException {
// Given
Log log = spy(Log.class);
components.register(Log.class, (ctx) -> log);
CallableUserFunction function = procedureCompiler.compileFunction(LoggingFunction.class).get(0);
// When
function.apply(new BasicContext(), new Object[0]);
// Then
verify(log).debug("1");
verify(log).info("2");
verify(log).warn("3");
verify(log).error("4");
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveUserFunctionTest method shouldSupportFunctionDeprecation.
@Test
public void shouldSupportFunctionDeprecation() throws Throwable {
// Given
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, ProcedureConfig.DEFAULT);
// When
List<CallableUserFunction> funcs = procedureCompiler.compileFunction(FunctionWithDeprecation.class);
// Then
verify(log).warn("Use of @UserFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc");
verifyNoMoreInteractions(log);
for (CallableUserFunction func : funcs) {
String name = func.signature().name().name();
func.apply(new BasicContext(), new Object[0]);
switch(name) {
case "newFunc":
assertFalse("Should not be deprecated", func.signature().deprecated().isPresent());
break;
case "oldFunc":
case "badFunc":
assertTrue("Should be deprecated", func.signature().deprecated().isPresent());
assertThat(func.signature().deprecated().get(), equalTo("newFunc"));
break;
default:
fail("Unexpected function: " + name);
}
}
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldLoadWhiteListedProcedure.
@Test
public void shouldLoadWhiteListedProcedure() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "org.neo4j.kernel.impl.proc.listCoolPeople")));
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), false).get(0);
// When
RawIterator<Object[], ProcedureException> result = proc.apply(new BasicContext(), new Object[0]);
// Then
assertEquals(result.next()[0], "Bonnie");
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ReflectiveUserAggregationFunctionTest method shouldSupportFunctionDeprecation.
@Test
public void shouldSupportFunctionDeprecation() throws Throwable {
// Given
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, ProcedureConfig.DEFAULT);
// When
List<CallableUserAggregationFunction> funcs = procedureCompiler.compileAggregationFunction(FunctionWithDeprecation.class);
// Then
verify(log).warn("Use of @UserAggregationFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc");
verifyNoMoreInteractions(log);
for (CallableUserAggregationFunction func : funcs) {
String name = func.signature().name().name();
func.create(new BasicContext());
switch(name) {
case "newFunc":
assertFalse("Should not be deprecated", func.signature().deprecated().isPresent());
break;
case "oldFunc":
case "badFunc":
assertTrue("Should be deprecated", func.signature().deprecated().isPresent());
assertThat(func.signature().deprecated().get(), equalTo("newFunc"));
break;
default:
fail("Unexpected function: " + name);
}
}
}
Aggregations