use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryCheckDbConnectionsIT method testMillisecondWait.
/**
* Test whether a Millisecond-level timeout actually waits for N milliseconds, instead of N seconds
*/
@Test(timeout = 10000)
public void testMillisecondWait() {
int waitMilliseconds = 15;
Job mockedJob = Mockito.mock(Job.class);
Mockito.when(mockedJob.isStopped()).thenReturn(false);
JobEntryCheckDbConnections meta = new JobEntryCheckDbConnections();
meta.setParentJob(mockedJob);
meta.setLogLevel(LogLevel.BASIC);
DatabaseMeta db = new DatabaseMeta("InMemory H2", "H2", null, null, H2_DATABASE, "-1", null, null);
meta.setConnections(new DatabaseMeta[] { db });
meta.setWaittimes(new int[] { JobEntryCheckDbConnections.UNIT_TIME_MILLI_SECOND });
meta.setWaitfors(new String[] { String.valueOf(waitMilliseconds) });
Result result = meta.execute(new Result(), 0);
Assert.assertTrue(result.getResult());
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class JobEntryCheckDbConnectionsIT method testWaitingtime.
@Test(timeout = 5000)
public void testWaitingtime() {
int waitTimes = 3;
Job mockedJob = Mockito.mock(Job.class);
Mockito.when(mockedJob.isStopped()).thenReturn(false);
JobEntryCheckDbConnections meta = new JobEntryCheckDbConnections();
meta.setParentJob(mockedJob);
meta.setLogLevel(LogLevel.DETAILED);
DatabaseMeta db = new DatabaseMeta("InMemory H2", "H2", null, null, H2_DATABASE, "-1", null, null);
meta.setConnections(new DatabaseMeta[] { db });
meta.setWaittimes(new int[] { JobEntryCheckDbConnections.UNIT_TIME_SECOND });
meta.setWaitfors(new String[] { String.valueOf(waitTimes) });
Result result = meta.execute(new Result(), 0);
Assert.assertTrue(meta.getNow() - meta.getTimeStart() >= waitTimes * 1000);
Assert.assertTrue(result.getResult());
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class ScriptValueAddFunctions_SetVariableScopeTest method setGrandParentScopeVariable_ThreeLevelHierarchy.
@Test
public void setGrandParentScopeVariable_ThreeLevelHierarchy() {
Job grandParent = createJob();
Trans parent = createTrans(grandParent);
Trans child = createTrans(parent);
ScriptValuesAddedFunctions.setGrandParentScopeVariable(child, VARIABLE_NAME, VARIABLE_VALUE);
verify(child).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(parent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(grandParent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class ScriptValueAddFunctions_SetVariableScopeTest method setParentScopeVariable_ParentIsJob.
@Test
public void setParentScopeVariable_ParentIsJob() {
Job parent = createJob();
Trans child = createTrans(parent);
ScriptValuesAddedFunctions.setParentScopeVariable(child, VARIABLE_NAME, VARIABLE_VALUE);
verify(child).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(parent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
}
use of org.pentaho.di.job.Job in project pentaho-kettle by pentaho.
the class ScriptValueAddFunctions_SetVariableScopeTest method setSystemScopeVariable_FourLevelHierarchy.
@Test
public void setSystemScopeVariable_FourLevelHierarchy() {
Job grandGrandParent = createJob();
Trans grandParent = createTrans(grandGrandParent);
Trans parent = createTrans(grandParent);
Trans child = createTrans(parent);
Assert.assertNull(System.getProperty(VARIABLE_NAME));
try {
ScriptValuesAddedFunctions.setSystemScopeVariable(child, VARIABLE_NAME, VARIABLE_VALUE);
Assert.assertEquals(System.getProperty(VARIABLE_NAME), VARIABLE_VALUE);
verify(child).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(parent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(grandParent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(grandGrandParent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
} finally {
System.clearProperty(VARIABLE_NAME);
}
}
Aggregations