Search in sources :

Example 1 with LogChannel

use of org.apache.hop.core.logging.LogChannel in project hop by apache.

the class FieldHelperTest method getGetSignature_Serializable.

@Test
public void getGetSignature_Serializable() throws Exception {
    LogChannel log = mock(LogChannel.class);
    whenNew(LogChannel.class).withAnyArguments().thenReturn(log);
    ValueMetaSerializable v = new ValueMetaSerializable("Data");
    String accessor = FieldHelper.getAccessor(true, "Data");
    assertEquals("Object Data = get(Fields.In, \"Data\").getObject(r);", FieldHelper.getGetSignature(accessor, v));
    assertNotNull(getMethod(FieldHelper.class, "getObject", Object[].class));
}
Also used : LogChannel(org.apache.hop.core.logging.LogChannel) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with LogChannel

use of org.apache.hop.core.logging.LogChannel in project hop by apache.

the class FieldHelperTest method getNativeDataTypeSimpleName_Unknown.

@Test
public void getNativeDataTypeSimpleName_Unknown() throws Exception {
    HopValueException e = new HopValueException();
    IValueMeta v = mock(IValueMeta.class);
    doThrow(e).when(v).getNativeDataTypeClass();
    LogChannel log = mock(LogChannel.class);
    whenNew(LogChannel.class).withAnyArguments().thenReturn(log);
    assertEquals("Object", FieldHelper.getNativeDataTypeSimpleName(v));
    verify(log, times(1)).logDebug("Unable to get name from data type");
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) HopValueException(org.apache.hop.core.exception.HopValueException) LogChannel(org.apache.hop.core.logging.LogChannel) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with LogChannel

use of org.apache.hop.core.logging.LogChannel in project hop by apache.

the class HopImport method run.

@Override
public void run() {
    try {
        log = new LogChannel("HopImport");
        if (listPluginTypes != null && listPluginTypes) {
            printPluginTypes();
            return;
        }
        if (!validateOptions()) {
            cmd.usage(System.err);
            return;
        }
        hopImport = loadImportPlugin();
        if (hopImport == null) {
            return;
        }
        log.logDetailed("Start of Hop Import");
        // Set the options...
        // 
        hopImport.setValidateInputFolder(inputFolderName);
        hopImport.setValidateOutputFolder(outputFolderName);
        hopImport.setKettlePropertiesFilename(kettlePropertiesFilename);
        hopImport.setJdbcPropertiesFilename(jdbcPropertiesFilename);
        hopImport.setSharedXmlFilename(sharedXmlFilename);
        if (skippingExistingTargetFiles != null) {
            log.logBasic("Import is " + (skippingExistingTargetFiles ? "" : "not ") + "skipping existing target files");
            hopImport.setSkippingExistingTargetFiles(skippingExistingTargetFiles);
        }
        if (skippingHiddenFilesAndFolders != null) {
            log.logBasic("Import is " + (skippingHiddenFilesAndFolders ? "" : "not ") + "skipping hidden files and folders");
            hopImport.setSkippingHiddenFilesAndFolders(skippingHiddenFilesAndFolders);
        }
        if (skippingFolders != null) {
            log.logBasic("Import is " + (skippingFolders ? "" : "not ") + "skipping sub-folders");
            hopImport.setSkippingFolders(skippingFolders);
        }
        hopImport.setTargetConfigFilename(targetConfigFilename);
        // Allow plugins to modify the elements loaded so far, before a pipeline or workflow is even
        // loaded
        // 
        ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportStart.id, this);
        // Handle the options of the configuration plugins
        // 
        Map<String, Object> mixins = cmd.getMixins();
        for (String key : mixins.keySet()) {
            Object mixin = mixins.get(key);
            if (mixin instanceof IConfigOptions) {
                IConfigOptions configOptions = (IConfigOptions) mixin;
                configOptions.handleOption(log, this, variables);
            }
        }
        // Text version of a progress monitor...
        // 
        IProgressMonitor monitor = new LogProgressMonitor(log);
        // Run the import...
        // 
        hopImport.runImport(monitor);
        // Print the report...
        // 
        log.logBasic(Const.CR);
        log.logBasic(hopImport.getImportReport());
        ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportEnd.id, this);
    } catch (Exception e) {
        throw new ExecutionException(cmd, "There was an error during import", e);
    }
}
Also used : IConfigOptions(org.apache.hop.core.config.plugin.IConfigOptions) IProgressMonitor(org.apache.hop.core.IProgressMonitor) ILogChannel(org.apache.hop.core.logging.ILogChannel) LogChannel(org.apache.hop.core.logging.LogChannel) ExecutionException(picocli.CommandLine.ExecutionException) LogProgressMonitor(org.apache.hop.core.LogProgressMonitor) HopException(org.apache.hop.core.exception.HopException) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) IOException(java.io.IOException)

Example 4 with LogChannel

use of org.apache.hop.core.logging.LogChannel in project hop by apache.

the class MailConnectionTest method beforeExec.

@Before
public void beforeExec() throws HopException, MessagingException {
    Object subj = new Object();
    ILogChannel log = new LogChannel(subj);
    conn = new Mconn(log);
}
Also used : ILogChannel(org.apache.hop.core.logging.ILogChannel) ILogChannel(org.apache.hop.core.logging.ILogChannel) LogChannel(org.apache.hop.core.logging.LogChannel) Before(org.junit.Before)

Example 5 with LogChannel

use of org.apache.hop.core.logging.LogChannel in project hop by apache.

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)));
    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.apache.hop.core.logging.LogChannel) File(java.io.File) Test(org.junit.Test)

Aggregations

LogChannel (org.apache.hop.core.logging.LogChannel)10 ILogChannel (org.apache.hop.core.logging.ILogChannel)7 IConfigOptions (org.apache.hop.core.config.plugin.IConfigOptions)5 HopException (org.apache.hop.core.exception.HopException)5 ExecutionException (picocli.CommandLine.ExecutionException)4 ParameterException (picocli.CommandLine.ParameterException)4 Test (org.junit.Test)3 IOException (java.io.IOException)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 File (java.io.File)1 FileObject (org.apache.commons.vfs2.FileObject)1 IProgressMonitor (org.apache.hop.core.IProgressMonitor)1 LogProgressMonitor (org.apache.hop.core.LogProgressMonitor)1 HopPluginException (org.apache.hop.core.exception.HopPluginException)1 HopValueException (org.apache.hop.core.exception.HopValueException)1 UnknownParamException (org.apache.hop.core.parameters.UnknownParamException)1 IPlugin (org.apache.hop.core.plugins.IPlugin)1 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)1 IValueMeta (org.apache.hop.core.row.IValueMeta)1 Before (org.junit.Before)1