use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class RunConfigurationDelegateTest method testUpdateLoadedJobs_Exception.
@Test
public void testUpdateLoadedJobs_Exception() throws Exception {
JobEntryTrans trans = new JobEntryTrans();
trans.setRunConfiguration("key");
JobMeta meta = new JobMeta();
meta.addJobEntry(new JobEntryCopy(trans));
JobMeta[] jobs = new JobMeta[] { meta };
doReturn(jobs).when(spoon).getLoadedJobs();
DefaultRunConfiguration config = new DefaultRunConfiguration();
config.setName("Test");
config.setServer("localhost");
LogChannelInterface log = mock(LogChannelInterface.class);
doReturn(log).when(spoon).getLog();
PowerMockito.mockStatic(ExtensionPointHandler.class);
PowerMockito.when(ExtensionPointHandler.class, "callExtensionPoint", any(), any(), any()).thenThrow(KettleException.class);
delegate.updateLoadedJobs("key", config);
verify(log, times(1)).logBasic(any());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class OpenMappingExtensionTest method setKettleLogFactoryWithMock.
private void setKettleLogFactoryWithMock() {
LogChannelInterfaceFactory logChannelInterfaceFactory = mock(LogChannelInterfaceFactory.class);
logChannelInterface = mock(LogChannelInterface.class);
when(logChannelInterfaceFactory.create(any())).thenReturn(logChannelInterface);
KettleLogStore.setLogChannelInterfaceFactory(logChannelInterfaceFactory);
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class RemoveJobServletTest method testRemoveJobServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testRemoveJobServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
KettleLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Job mockJob = mock(Job.class);
JobMeta mockJobMeta = mock(JobMeta.class);
LogChannelInterface mockLogChannelInterface = mock(LogChannelInterface.class);
mockJob.setName(ServletTestUtils.BAD_STRING_TO_TEST);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(RemoveJobServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockJobMap.getJob(any(CarteObjectEntry.class))).thenReturn(mockJob);
when(mockJob.getLogChannelId()).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockJob.getLogChannel()).thenReturn(mockLogChannelInterface);
when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
when(mockJobMeta.getMaximum()).thenReturn(new Point(10, 10));
removeJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H3", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SniffStepServletTest method testSniffStepServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testSniffStepServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
KettleLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Trans mockTrans = mock(Trans.class);
TransMeta mockTransMeta = mock(TransMeta.class);
StepInterface mockStepInterface = mock(StepInterface.class);
List<StepInterface> stepInterfaces = new ArrayList<StepInterface>();
stepInterfaces.add(mockStepInterface);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(SniffStepServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockTransformationMap.getTransformation(any(CarteObjectEntry.class))).thenReturn(mockTrans);
when(mockTrans.getLogChannel()).thenReturn(mockChannelInterface);
when(mockTrans.getLogChannelId()).thenReturn("test");
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
when(mockTrans.findBaseSteps(ServletTestUtils.BAD_STRING_TO_TEST)).thenReturn(stepInterfaces);
sniffStepServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class BlackBoxIT method runTransOrJob.
// This is a generic JUnit 4 test that takes no parameters
@Test
public void runTransOrJob() throws Exception {
// Params are:
// File transFile
// List<File> expectedFiles
LogChannelInterface log = new LogChannel("BlackBoxTest [" + transFile.toString() + "]");
if (!transFile.exists()) {
log.logError("Transformation does not exist: " + getPath(transFile));
addFailure("Transformation does not exist: " + getPath(transFile));
fail("Transformation does not exist: " + getPath(transFile));
}
if (expectedFiles.isEmpty()) {
addFailure("No expected output files found: " + getPath(transFile));
fail("No expected output files found: " + getPath(transFile));
}
Result result = runTrans(transFile.getAbsolutePath(), log);
//
for (int i = 0; i < expectedFiles.size(); i++) {
File expected = expectedFiles.get(i);
if (expected.getAbsoluteFile().toString().contains(".expected")) {
// create a path to the expected output
String actualFile = expected.getAbsolutePath();
// multiple files case
actualFile = actualFile.replaceFirst(".expected_" + i + ".", ".actual_" + i + ".");
// single file case
actualFile = actualFile.replaceFirst(".expected.", ".actual.");
File actual = new File(actualFile);
if (result.getResult()) {
fileCompare(expected, actual);
}
}
}
//
if (!result.getResult()) {
String logStr = KettleLogStore.getAppender().getBuffer(result.getLogChannelId(), true).toString();
if (expectedFiles.size() == 0) {
// We haven't got a ".fail.txt" file, so this is a real failure
fail("Error running " + getPath(transFile) + ":" + logStr);
}
}
}
Aggregations