OPEN - issue BATCH-654: Transactions when commit fails
Add copy constructor to ExecutionContext
This commit is contained in:
@@ -58,6 +58,20 @@ public class ExecutionContext implements Serializable {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param executionContext
|
||||
*/
|
||||
public ExecutionContext(ExecutionContext executionContext) {
|
||||
this();
|
||||
if (executionContext==null) {
|
||||
return;
|
||||
}
|
||||
for (Iterator iterator = executionContext.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry entry = (Entry) iterator.next();
|
||||
this.map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a String value to the context.
|
||||
*
|
||||
|
||||
@@ -128,6 +128,18 @@ public class ExecutionContextTests extends TestCase{
|
||||
assertEquals(7, ((TestSerializable)deserialized.get("5")).value);
|
||||
}
|
||||
|
||||
public void testCopyConstructor() throws Exception {
|
||||
ExecutionContext context = new ExecutionContext();
|
||||
context.put("foo", "bar");
|
||||
ExecutionContext copy = new ExecutionContext(context);
|
||||
assertEquals(copy, context);
|
||||
}
|
||||
|
||||
public void testCopyConstructorNullnNput() throws Exception {
|
||||
ExecutionContext context = new ExecutionContext((ExecutionContext)null);
|
||||
assertTrue(context.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Value object for testing serialization
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user