### Question:
ContextFactory { @SuppressWarnings("unchecked") public static JobContext cloneContext(JobContext original, Configuration conf ) throws IOException, InterruptedException { try { if (original instanceof MapContext<?,?,?,?>) { return cloneMapContext((Mapper.Context) original, conf, null, null); } else if (original instanceof ReduceContext<?,?,?,?>) { throw new IllegalArgumentException("can't clone ReduceContext"); } else if (original instanceof TaskAttemptContext) { TaskAttemptContext spec = (TaskAttemptContext) original; return (JobContext) TASK_CONTEXT_CONSTRUCTOR.newInstance(conf, spec.getTaskAttemptID()); } else { return (JobContext) JOB_CONTEXT_CONSTRUCTOR.newInstance(conf, original.getJobID()); } } catch (InstantiationException e) { throw new IllegalArgumentException("Can't clone object", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Can't clone object", e); } catch (InvocationTargetException e) { throw new IllegalArgumentException("Can't clone object", e); } }  @SuppressWarnings("unchecked") static JobContext cloneContext(JobContext original,
                                        Configuration conf
                                        ); @SuppressWarnings("unchecked") static Mapper<K1,V1,K2,V2>.Context cloneMapContext(MapContext<K1,V1,K2,V2> context,
                       Configuration conf,
                       RecordReader<K1,V1> reader,
                       RecordWriter<K2,V2> writer
                      );  }### Answer:
@Test public void testCloneContext() throws Exception { ContextFactory.cloneContext(jobContext, conf); }