Search in sources :

Example 6 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class MissingTransStepTest method testInit.

@Test
public void testInit() {
    StepMetaInterface stepMetaInterface = new AbstractStepMeta() {

        @Override
        public void setDefault() {
        }

        @Override
        public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans) {
            return null;
        }
    };
    StepMeta stepMeta = new StepMeta();
    stepMeta.setName("TestMetaStep");
    StepDataInterface stepDataInterface = mock(StepDataInterface.class);
    Trans trans = new Trans();
    LogChannel log = mock(LogChannel.class);
    doAnswer(new Answer<Void>() {

        public Void answer(InvocationOnMock invocation) {
            return null;
        }
    }).when(log).logError(anyString());
    trans.setLog(log);
    TransMeta transMeta = new TransMeta();
    transMeta.addStep(stepMeta);
    MissingTransStep step = createAndInitStep(stepMetaInterface, stepDataInterface);
    assertFalse(step.init(stepMetaInterface, stepDataInterface));
}
Also used : AbstractStepMeta(org.pentaho.di.core.util.AbstractStepMeta) InvocationOnMock(org.mockito.invocation.InvocationOnMock) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) TransMeta(org.pentaho.di.trans.TransMeta) LogChannel(org.pentaho.di.core.logging.LogChannel) StepMeta(org.pentaho.di.trans.step.StepMeta) AbstractStepMeta(org.pentaho.di.core.util.AbstractStepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Example 7 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class FileUtilsTest method testCreateParentFolder.

@Test
public void testCreateParentFolder() {
    String tempDir = TestUtils.createTempDir();
    String suff = tempDir.substring(tempDir.lastIndexOf(File.separator) + 1);
    tempDir += File.separator + suff + File.separator + suff;
    assertTrue("Dir should be created", FileUtil.createParentFolder(getClass(), tempDir, true, new LogChannel(this), null));
    File fl = new File(tempDir.substring(0, tempDir.lastIndexOf(File.separator)));
    assertTrue("Dir should exist", fl.exists());
    fl.delete();
    new File(tempDir).delete();
}
Also used : LogChannel(org.pentaho.di.core.logging.LogChannel) File(java.io.File) Test(org.junit.Test)

Example 8 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class MailConnectionTest method beforeExec.

@Before
public void beforeExec() throws KettleException, MessagingException {
    Object subj = new Object();
    LogChannelInterface log = new LogChannel(subj);
    conn = new Mconn(log);
}
Also used : LogChannel(org.pentaho.di.core.logging.LogChannel) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Before(org.junit.Before)

Example 9 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class RepositoriesMetaTest method testReadData.

@Test
public void testReadData() throws Exception {
    LogChannel log = mock(LogChannel.class);
    doReturn(getClass().getResource("repositories.xml").getPath()).when(repoMeta).getKettleUserRepositoriesFile();
    doReturn(log).when(repoMeta).newLogChannel();
    repoMeta.readData();
    String repositoriesXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Const.CR + "<repositories>" + Const.CR + "  <connection>" + Const.CR + "    <name>local postgres</name>" + Const.CR + "    <server>localhost</server>" + Const.CR + "    <type>POSTGRESQL</type>" + Const.CR + "    <access>Native</access>" + Const.CR + "    <database>hibernate</database>" + Const.CR + "    <port>5432</port>" + Const.CR + "    <username>auser</username>" + Const.CR + "    <password>Encrypted 2be98afc86aa7f285bb18bd63c99dbdde</password>" + Const.CR + "    <servername/>" + Const.CR + "    <data_tablespace/>" + Const.CR + "    <index_tablespace/>" + Const.CR + "    <attributes>" + Const.CR + "      <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>" + Const.CR + "      <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>" + Const.CR + "      <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>" + Const.CR + "      <attribute><code>PORT_NUMBER</code><attribute>5432</attribute></attribute>" + Const.CR + "      <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>" + Const.CR + "      <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>" + Const.CR + "      <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>" + Const.CR + "      <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>" + Const.CR + "      <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>" + Const.CR + "    </attributes>" + Const.CR + "  </connection>" + Const.CR + "  <repository>    <id>KettleFileRepository</id>" + Const.CR + "    <name>Test Repository</name>" + Const.CR + "    <description>Test Repository Description</description>" + Const.CR + "    <is_default>false</is_default>" + Const.CR + "    <base_directory>test-repository</base_directory>" + Const.CR + "    <read_only>N</read_only>" + Const.CR + "    <hides_hidden_files>N</hides_hidden_files>" + Const.CR + "  </repository>  </repositories>" + Const.CR;
    assertEquals(repositoriesXml, repoMeta.getXML());
    RepositoriesMeta clone = repoMeta.clone();
    assertEquals(repositoriesXml, repoMeta.getXML());
    assertNotSame(clone, repoMeta);
    assertEquals(1, repoMeta.nrRepositories());
    RepositoryMeta repository = repoMeta.getRepository(0);
    assertEquals("Test Repository", repository.getName());
    assertEquals("Test Repository Description", repository.getDescription());
    assertEquals("  <repository>    <id>KettleFileRepository</id>" + Const.CR + "    <name>Test Repository</name>" + Const.CR + "    <description>Test Repository Description</description>" + Const.CR + "    <is_default>false</is_default>" + Const.CR + "    <base_directory>test-repository</base_directory>" + Const.CR + "    <read_only>N</read_only>" + Const.CR + "    <hides_hidden_files>N</hides_hidden_files>" + Const.CR + "  </repository>", repository.getXML());
    assertSame(repository, repoMeta.searchRepository("Test Repository"));
    assertSame(repository, repoMeta.findRepositoryById("KettleFileRepository"));
    assertSame(repository, repoMeta.findRepository("Test Repository"));
    assertNull(repoMeta.findRepository("not found"));
    assertNull(repoMeta.findRepositoryById("not found"));
    assertEquals(0, repoMeta.indexOfRepository(repository));
    repoMeta.removeRepository(0);
    assertEquals(0, repoMeta.nrRepositories());
    assertNull(repoMeta.searchRepository("Test Repository"));
    repoMeta.addRepository(0, repository);
    assertEquals(1, repoMeta.nrRepositories());
    repoMeta.removeRepository(1);
    assertEquals(1, repoMeta.nrRepositories());
    assertEquals(1, repoMeta.nrDatabases());
    assertEquals("local postgres", repoMeta.getDatabase(0).getName());
    DatabaseMeta searchDatabase = repoMeta.searchDatabase("local postgres");
    assertSame(searchDatabase, repoMeta.getDatabase(0));
    assertEquals(0, repoMeta.indexOfDatabase(searchDatabase));
    repoMeta.removeDatabase(0);
    assertEquals(0, repoMeta.nrDatabases());
    assertNull(repoMeta.searchDatabase("local postgres"));
    repoMeta.addDatabase(0, searchDatabase);
    assertEquals(1, repoMeta.nrDatabases());
    repoMeta.removeDatabase(1);
    assertEquals(1, repoMeta.nrDatabases());
    assertEquals("Unable to read repository with id [junk]. RepositoryMeta is not available.", repoMeta.getErrorMessage());
}
Also used : LogChannel(org.pentaho.di.core.logging.LogChannel) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 10 with LogChannel

use of org.pentaho.di.core.logging.LogChannel in project pentaho-kettle by pentaho.

the class RepositoriesMetaTest method testReadData_closeInput.

@Test
public void testReadData_closeInput() throws Exception {
    String repositoriesFile = getClass().getResource("repositories.xml").getPath();
    LogChannel log = mock(LogChannel.class);
    when(repoMeta.getKettleUserRepositoriesFile()).thenReturn(repositoriesFile);
    when(repoMeta.newLogChannel()).thenReturn(log);
    repoMeta.readData();
    RandomAccessFile fos = null;
    try {
        File file = new File(repositoriesFile);
        if (file.exists()) {
            fos = new RandomAccessFile(file, "rw");
        }
    } catch (FileNotFoundException | SecurityException e) {
        fail("the file with properties should be unallocated");
    } finally {
        if (fos != null) {
            fos.close();
        }
    }
}
Also used : RandomAccessFile(java.io.RandomAccessFile) FileNotFoundException(java.io.FileNotFoundException) LogChannel(org.pentaho.di.core.logging.LogChannel) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Aggregations

LogChannel (org.pentaho.di.core.logging.LogChannel)44 TransMeta (org.pentaho.di.trans.TransMeta)17 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)13 TransSplitter (org.pentaho.di.trans.cluster.TransSplitter)13 Test (org.junit.Test)8 File (java.io.File)6 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)6 Before (org.junit.Before)4 Repository (org.pentaho.di.repository.Repository)4 Node (org.w3c.dom.Node)4 IOException (java.io.IOException)3 FileObject (org.apache.commons.vfs2.FileObject)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 SlaveServer (org.pentaho.di.cluster.SlaveServer)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Display (org.eclipse.swt.widgets.Display)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 KettleException (org.pentaho.di.core.exception.KettleException)2