SPRNET-1340 MethodInvokingJobDetailFactoryObject does not set the result in JobContext

This commit is contained in:
lahma
2010-07-13 09:24:36 +00:00
parent 5326ae1327
commit 54b2eb0b2e
2 changed files with 28 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ namespace Spring.Scheduling.Quartz
}
try
{
methodInvoker.Invoke();
context.Result = methodInvoker.Invoke();
}
catch (TargetInvocationException ex)
{

View File

@@ -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>