Search in sources :

Example 76 with Job

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());
}
Also used : Job(org.pentaho.di.job.Job) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 77 with Job

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());
}
Also used : Job(org.pentaho.di.job.Job) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 78 with Job

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));
}
Also used : Job(org.pentaho.di.job.Job) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Example 79 with Job

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));
}
Also used : Job(org.pentaho.di.job.Job) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Example 80 with Job

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);
    }
}
Also used : Job(org.pentaho.di.job.Job) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Aggregations

Job (org.pentaho.di.job.Job)95 JobMeta (org.pentaho.di.job.JobMeta)44 Test (org.junit.Test)35 Result (org.pentaho.di.core.Result)22 KettleException (org.pentaho.di.core.exception.KettleException)20 PrintWriter (java.io.PrintWriter)17 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)17 Trans (org.pentaho.di.trans.Trans)14 IOException (java.io.IOException)11 Before (org.junit.Before)11 Point (org.pentaho.di.core.gui.Point)11 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)11 JobExecutionConfiguration (org.pentaho.di.job.JobExecutionConfiguration)10 Repository (org.pentaho.di.repository.Repository)10 ArrayList (java.util.ArrayList)9 ServletException (javax.servlet.ServletException)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)9 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)9 JobConfiguration (org.pentaho.di.job.JobConfiguration)9