SPRNET-1340 MethodInvokingJobDetailFactoryObject does not set the result in JobContext
This commit is contained in:
@@ -66,7 +66,7 @@ namespace Spring.Scheduling.Quartz
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
methodInvoker.Invoke();
|
context.Result = methodInvoker.Invoke();
|
||||||
}
|
}
|
||||||
catch (TargetInvocationException ex)
|
catch (TargetInvocationException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,24 @@ namespace Spring.Scheduling.Quartz
|
|||||||
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
|
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>
|
/// <summary>
|
||||||
/// Test method invoke via execute.
|
/// Test method invoke via execute.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -147,6 +165,7 @@ namespace Spring.Scheduling.Quartz
|
|||||||
public class InvocationCountingJob
|
public class InvocationCountingJob
|
||||||
{
|
{
|
||||||
private int counter;
|
private int counter;
|
||||||
|
internal const string DefaultReturnValue = "return value";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Increments method invoke counter.
|
/// 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>
|
/// <summary>
|
||||||
/// Invocation count.
|
/// Invocation count.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user