SPRNET-1340 MethodInvokingJobDetailFactoryObject does not set the result in JobContext
This commit is contained in:
@@ -66,7 +66,7 @@ namespace Spring.Scheduling.Quartz
|
||||
}
|
||||
try
|
||||
{
|
||||
methodInvoker.Invoke();
|
||||
context.Result = methodInvoker.Invoke();
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
|
||||
@@ -83,6 +83,24 @@ namespace Spring.Scheduling.Quartz
|
||||
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that invocation result is set to execution context (SPRNET-1340).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestMethodInvoker_ShouldSetResultToExecutionContext()
|
||||
{
|
||||
InvocationCountingJob job = new InvocationCountingJob();
|
||||
MethodInvoker mi = new MethodInvoker();
|
||||
mi.TargetObject = job;
|
||||
mi.TargetMethod = "InvokeWithReturnValue";
|
||||
mi.Prepare();
|
||||
methodInvokingJob.MethodInvoker = mi;
|
||||
JobExecutionContext context = CreateMinimalJobExecutionContext();
|
||||
methodInvokingJob.Execute(context);
|
||||
|
||||
Assert.AreEqual(InvocationCountingJob.DefaultReturnValue, context.Result, "result value was not set to context");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test method invoke via execute.
|
||||
/// </summary>
|
||||
@@ -147,6 +165,7 @@ namespace Spring.Scheduling.Quartz
|
||||
public class InvocationCountingJob
|
||||
{
|
||||
private int counter;
|
||||
internal const string DefaultReturnValue = "return value";
|
||||
|
||||
/// <summary>
|
||||
/// Increments method invoke counter.
|
||||
@@ -169,6 +188,14 @@ namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see cref="DefaultReturnValue" /> as return value.
|
||||
/// </summary>
|
||||
public string InvokeWithReturnValue()
|
||||
{
|
||||
return DefaultReturnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invocation count.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user