diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJob.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJob.cs
index 7a97176c..861d0dc3 100644
--- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJob.cs
+++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJob.cs
@@ -66,7 +66,7 @@ namespace Spring.Scheduling.Quartz
}
try
{
- methodInvoker.Invoke();
+ context.Result = methodInvoker.Invoke();
}
catch (TargetInvocationException ex)
{
diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs
index 94d3cfc2..ce0bb97e 100644
--- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs
+++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs
@@ -83,6 +83,24 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
}
+ ///
+ /// Test that invocation result is set to execution context (SPRNET-1340).
+ ///
+ [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");
+ }
+
///
/// Test method invoke via execute.
///
@@ -147,6 +165,7 @@ namespace Spring.Scheduling.Quartz
public class InvocationCountingJob
{
private int counter;
+ internal const string DefaultReturnValue = "return value";
///
/// Increments method invoke counter.
@@ -169,6 +188,14 @@ namespace Spring.Scheduling.Quartz
{
}
+ ///
+ /// Returns as return value.
+ ///
+ public string InvokeWithReturnValue()
+ {
+ return DefaultReturnValue;
+ }
+
///
/// Invocation count.
///