use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class StartExecutionTransServletTest method testStartExecutionTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testStartExecutionTransServletEscapesHtmlWhenTransFound() 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);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(StartExecutionTransServlet.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.isReadyToStart()).thenReturn(true);
when(mockTrans.getLogChannelId()).thenReturn("test");
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
startExecutionTransServlet.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 StartTransServletTest method testStartTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testStartTransServletEscapesHtmlWhenTransFound() 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);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(StartTransServlet.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));
startTransServlet.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 StopTransServletTest method testStopTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testStopTransServletEscapesHtmlWhenTransFound() 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);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(StopTransServlet.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));
stopTransServlet.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 PauseTransServletTest method testPauseTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testPauseTransServletEscapesHtmlWhenTransFound() 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);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(PauseTransServlet.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.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
pauseTransServlet.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 GetSlavesServletTest method testUpdateActivityStatusInDoGet.
@Test
@SuppressWarnings("ResultOfMethodCallIgnored")
public void testUpdateActivityStatusInDoGet() throws Exception {
LogChannelInterface log = mock(LogChannelInterface.class);
ServletOutputStream outputStream = mock(ServletOutputStream.class);
SlaveServerDetection activeServerDetection = mock(SlaveServerDetection.class);
SlaveServerDetection inactiveServerDetection = mock(SlaveServerDetection.class);
SlaveServer activeSlaveServer = mock(SlaveServer.class);
SlaveServer inactiveSlaveServer = mock(SlaveServer.class);
servlet.log = log;
List<SlaveServerDetection> detections = new ArrayList<>();
detections.add(activeServerDetection);
detections.add(inactiveServerDetection);
doReturn(false).when(log).isDebug();
doReturn(outputStream).when(response).getOutputStream();
doReturn(detections).when(servlet).getDetections();
doReturn(activeSlaveServer).when(activeServerDetection).getSlaveServer();
doReturn(inactiveSlaveServer).when(inactiveServerDetection).getSlaveServer();
doThrow(new Exception()).when(inactiveSlaveServer).getStatus();
doCallRealMethod().when(servlet).doGet(request, response);
servlet.doGet(request, response);
verify(activeSlaveServer).getStatus();
verify(activeServerDetection, never()).setActive(false);
verify(activeServerDetection, never()).setLastInactiveDate(anyObject());
verify(activeServerDetection).getXML();
verify(inactiveSlaveServer).getStatus();
verify(inactiveServerDetection).setActive(false);
verify(inactiveServerDetection).setLastInactiveDate(anyObject());
verify(inactiveServerDetection).getXML();
}
Aggregations