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));
}
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();
}
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);
}
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());
}
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();
}
}
}
Aggregations