use of org.powermock.core.classloader.annotations.PrepareForTest in project pentaho-kettle by pentaho.
the class CleanupTransServletTest method testCleanupTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testCleanupTransServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Trans mockTrans = mock(Trans.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(CleanupTransServlet.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);
cleanupTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project pentaho-kettle by pentaho.
the class GetJobStatusServletTest method testGetJobStatusServletEscapesHtmlWhenTransNotFound.
@Test
@PrepareForTest({ Encode.class })
public void testGetJobStatusServletEscapesHtmlWhenTransNotFound() throws ServletException, IOException {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(GetJobStatusServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
getJobStatusServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project pentaho-kettle by pentaho.
the class GetTransStatusServletTest method testGetTransStatusServletEscapesHtmlWhenTransNotFound.
@Test
@PrepareForTest({ Encode.class })
public void testGetTransStatusServletEscapesHtmlWhenTransNotFound() throws ServletException, IOException {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(GetTransStatusServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
getTransStatusServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project pentaho-kettle by pentaho.
the class PrepareExecutionTransServletTest 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);
TransConfiguration mockTransConf = mock(TransConfiguration.class);
TransMeta mockTransMeta = mock(TransMeta.class);
TransExecutionConfiguration mockTransExecutionConf = mock(TransExecutionConfiguration.class);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(PrepareExecutionTransServlet.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(mockTransformationMap.getConfiguration(any(CarteObjectEntry.class))).thenReturn(mockTransConf);
when(mockTransConf.getTransExecutionConfiguration()).thenReturn(mockTransExecutionConf);
when(mockTrans.getLogChannel()).thenReturn(mockChannelInterface);
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
prepareExecutionTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project pentaho-kettle by pentaho.
the class RemoveTransServletTest method testRemoveTransServletEscapesHtmlWhenTransNotFound.
@Test
@PrepareForTest({ Encode.class })
public void testRemoveTransServletEscapesHtmlWhenTransNotFound() throws ServletException, IOException {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(RemoveTransServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
removeTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
Aggregations