OPEN - issue BATCH-654: Transactions when commit fails

Add copy constructor to ExecutionContext
This commit is contained in:
dsyer
2008-06-18 09:21:19 +00:00
parent dc7f0dc1d0
commit 26d14d2068
2 changed files with 26 additions and 0 deletions

View File

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

View File

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