@Test
  public void testReleaseClassLoader() throws Exception {
    PipelineBean pipelineBean = Mockito.mock(PipelineBean.class);
    StageBean stageBean = Mockito.mock(StageBean.class);
    Mockito.when(stageBean.getStage()).thenReturn(Mockito.mock(Stage.class));
    StageDefinition def = Mockito.mock(StageDefinition.class);
    Mockito.when(stageBean.getDefinition()).thenReturn(def);

    StageRuntime runtime = new StageRuntime(pipelineBean, stageBean);

    Mockito.verify(stageBean, Mockito.never()).releaseClassLoader();
    runtime.destroy();
    Mockito.verify(stageBean, Mockito.times(1)).releaseClassLoader();
  }
  @Test
  public void testCreateByRef() throws Exception {
    PipelineBean pipelineBean = Mockito.mock(PipelineBean.class);
    StageBean stageBean = Mockito.mock(StageBean.class);
    Mockito.when(stageBean.getSystemConfigs()).thenReturn(new StageConfigBean());
    StageDefinition def = Mockito.mock(StageDefinition.class);
    Mockito.when(stageBean.getDefinition()).thenReturn(def);
    StageContext context = Mockito.mock(StageContext.class);
    StageRuntime runtime = new StageRuntime(pipelineBean, stageBean);
    runtime.setContext(context);

    // by value, no preview
    Mockito.when(def.getRecordsByRef()).thenReturn(false);
    Mockito.when(context.isPreview()).thenReturn(false);
    runtime.execute(
        new Callable<String>() {
          @Override
          public String call() throws Exception {
            Assert.assertFalse(CreateByRef.isByRef());
            return null;
          }
        });

    // by value, preview
    Mockito.when(def.getRecordsByRef()).thenReturn(false);
    Mockito.when(context.isPreview()).thenReturn(true);
    runtime.execute(
        new Callable<String>() {
          @Override
          public String call() throws Exception {
            Assert.assertFalse(CreateByRef.isByRef());
            return null;
          }
        });

    // by ref, no preview
    Mockito.when(def.getRecordsByRef()).thenReturn(true);
    Mockito.when(context.isPreview()).thenReturn(false);
    runtime.execute(
        new Callable<String>() {
          @Override
          public String call() throws Exception {
            Assert.assertTrue(CreateByRef.isByRef());
            return null;
          }
        });

    // by ref, preview
    Mockito.when(def.getRecordsByRef()).thenReturn(true);
    Mockito.when(context.isPreview()).thenReturn(true);
    runtime.execute(
        new Callable<String>() {
          @Override
          public String call() throws Exception {
            Assert.assertFalse(CreateByRef.isByRef());
            return null;
          }
        });
  }