//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSupportProcedureDeprecation() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSupportProcedureDeprecation() { // Given Log log = mock(typeof(Log)); ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, ProcedureConfig.Default); // When IList <CallableProcedure> procs = procedureCompiler.CompileProcedure(typeof(ProcedureWithDeprecation), null, true); // Then verify(log).warn("Use of @Procedure(deprecatedBy) without @Deprecated in badProc"); verifyNoMoreInteractions(log); foreach (CallableProcedure proc in procs) { string name = proc.Signature().name().name(); proc.Apply(new BasicContext(), new object[0], _resourceTracker); switch (name) { case "newProc": assertFalse("Should not be deprecated", proc.Signature().deprecated().Present); break; case "oldProc": case "badProc": assertTrue("Should be deprecated", proc.Signature().deprecated().Present); assertThat(proc.Signature().deprecated().get(), equalTo("newProc")); break; default: fail("Unexpected procedure: " + name); break; } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSupportFunctionDeprecation() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSupportFunctionDeprecation() { // Given Log log = mock(typeof(Log)); ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), log, ProcedureConfig.Default); // When IList <CallableUserFunction> funcs = procedureCompiler.CompileFunction(typeof(FunctionWithDeprecation)); // Then verify(log).warn("Use of @UserFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc"); verifyNoMoreInteractions(log); foreach (CallableUserFunction func in funcs) { string name = func.Signature().name().name(); func.Apply(new BasicContext(), new AnyValue[0]); switch (name) { case "newFunc": assertFalse("Should not be deprecated", func.Signature().deprecated().Present); break; case "oldFunc": case "badFunc": assertTrue("Should be deprecated", func.Signature().deprecated().Present); assertThat(func.Signature().deprecated().get(), equalTo("newFunc")); break; default: fail("Unexpected function: " + name); break; } } }
public Procedures(EmbeddedProxySPI proxySPI, ThrowingConsumer <Procedures, ProcedureException> builtin, File pluginDir, Log log, ProcedureConfig config) { this._builtin = builtin; this._pluginDir = pluginDir; this._log = log; this._typeMappers = new TypeMappers(proxySPI); this._compiler = new ReflectiveProcedureCompiler(_typeMappers, _safeComponents, _allComponents, log, config); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { ComponentRegistry safeComponents = new ComponentRegistry(); ComponentRegistry allComponents = new ComponentRegistry(); safeComponents.Register(typeof(MyAwesomeAPI), ctx => new MyAwesomeAPI()); allComponents.Register(typeof(MyAwesomeAPI), ctx => new MyAwesomeAPI()); allComponents.Register(typeof(MyUnsafeAPI), ctx => new MyUnsafeAPI()); _compiler = new ReflectiveProcedureCompiler(new TypeMappers(), safeComponents, allComponents, _log, ProcedureConfig.Default); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotLoadAnyFunctionIfConfigIsEmpty() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotLoadAnyFunctionIfConfigIsEmpty() { // Given Log log = spy(typeof(Log)); _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), log, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_whitelist, ""))); IList <CallableUserFunction> method = Compile(typeof(SingleReadOnlyFunction)); verify(log).warn("The function 'org.neo4j.kernel.impl.proc.listCoolPeople' is not on the whitelist and won't be loaded."); assertThat(method.Count, equalTo(0)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLoadWhiteListedFunction() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLoadWhiteListedFunction() { // Given _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), NullLog.Instance, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_whitelist, "org.neo4j.kernel.impl.proc.listCoolPeople"))); CallableUserFunction method = Compile(typeof(SingleReadOnlyFunction))[0]; // Expect object @out = method.Apply(new BasicContext(), new AnyValue[0]); assertThat(@out, equalTo(ValueUtils.of(Arrays.asList("Bonnie", "Clyde")))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLoadWhiteListedFunction() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLoadWhiteListedFunction() { // Given _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), NullLog.Instance, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_whitelist, "org.neo4j.kernel.impl.proc.collectCool"))); CallableUserAggregationFunction method = Compile(typeof(SingleAggregationFunction))[0]; // Expect UserAggregator created = method.Create(new BasicContext()); created.Update(new object[] { "Bonnie" }); assertThat(created.Result(), equalTo(Collections.singletonList("Bonnie"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotLoadAnyProcedureIfConfigIsEmpty() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotLoadAnyProcedureIfConfigIsEmpty() { // Given ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_whitelist, "")); Log log = mock(typeof(Log)); ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config); // When IList <CallableProcedure> proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, 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.Count == 0, @is(true)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIgnoreWhiteListingIfFullAccess() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldIgnoreWhiteListingIfFullAccess() { // Given ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_whitelist, "empty")); Log log = mock(typeof(Log)); ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config); // When CallableProcedure proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, true)[0]; // Then RawIterator <object[], ProcedureException> result = proc.Apply(new BasicContext(), new object[0], _resourceTracker); assertEquals(result.Next()[0], "Bonnie"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLoadWhiteListedProcedure() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLoadWhiteListedProcedure() { // Given ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_whitelist, "org.neo4j.kernel.impl.proc.listCoolPeople")); Log log = mock(typeof(Log)); ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config); // When CallableProcedure proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, false)[0]; // When RawIterator <object[], ProcedureException> result = proc.Apply(new BasicContext(), new object[0], _resourceTracker); // Then assertEquals(result.Next()[0], "Bonnie"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _components = new ComponentRegistry(); _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, NullLog.Instance, ProcedureConfig.Default); }
internal ProcedureJarLoader(ReflectiveProcedureCompiler compiler, Log log) { this._compiler = compiler; this._log = log; }