use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class GetTransStatusServletIT method testGetTransStatusServletEscapesHtmlWhenTransFound.
@Test
public void testGetTransStatusServletEscapesHtmlWhenTransFound() 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);
when(mockHttpServletRequest.getContextPath()).thenReturn(GetTransStatusServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING);
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));
getTransStatusServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(out.toString().contains(ServletTestUtils.BAD_STRING));
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class GetJobStatusServletIT method testGetJobStatusServletEscapesHtmlWhenTransFound.
@Test
public void testGetJobStatusServletEscapesHtmlWhenTransFound() 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);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getContextPath()).thenReturn(GetJobStatusServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockJobMap.getJob(any(CarteObjectEntry.class))).thenReturn(mockJob);
when(mockJob.getLogChannel()).thenReturn(mockLogChannelInterface);
when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
when(mockJobMeta.getMaximum()).thenReturn(new Point(10, 10));
getJobStatusServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(out.toString().contains(ServletTestUtils.BAD_STRING));
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SpoonTest method prepareSetSaveTests.
private static void prepareSetSaveTests(Spoon spoon, LogChannelInterface log, SpoonPerspective spoonPerspective, AbstractMeta metaData, boolean repIsNull, boolean basicLevel, String perspectiveID, boolean saveToRepository, boolean saveXMLFile, String fileType, String filename, boolean objectIdIsNull, boolean canSave) throws Exception {
TabMapEntry mockTabMapEntry = mock(TabMapEntry.class);
TabItem mockTabItem = mock(TabItem.class);
Repository mockRepository = mock(Repository.class);
DelegatingMetaStore mockMetaStore = mock(DelegatingMetaStore.class);
spoon.rep = repIsNull ? null : mockRepository;
spoon.metaStore = mockMetaStore;
spoon.delegates = mock(SpoonDelegates.class);
spoon.delegates.tabs = mock(SpoonTabsDelegate.class);
spoon.props = mock(PropsUI.class);
doReturn(mock(LogChannelInterface.class)).when(spoon).getLog();
doReturn(perspectiveID).when(spoonPerspective).getId();
doReturn(basicLevel).when(log).isBasic();
doReturn(basicLevel).when(log).isDetailed();
doReturn(mockTabMapEntry).when(spoon.delegates.tabs).findTabMapEntry(any());
doReturn(mockTabItem).when(mockTabMapEntry).getTabItem();
doReturn(saveToRepository).when(spoon).saveToRepository(metaData, true);
doReturn(saveXMLFile).when(spoon).saveXMLFile(metaData, false);
if (objectIdIsNull) {
doReturn(null).when(metaData).getObjectId();
} else {
doReturn(new ObjectId() {
@Override
public String getId() {
return "objectId";
}
}).when(metaData).getObjectId();
}
// saveFile
doReturn(filename).when(metaData).getFilename();
doReturn(canSave).when(metaData).canSave();
doReturn(false).when(spoon.props).useDBCache();
doReturn(saveToRepository).when(spoon).saveToRepository(metaData);
doReturn(saveXMLFile).when(spoon).save(metaData, filename, false);
doReturn(fileType).when(metaData).getFileType();
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testWidgetSelectedHelper.
@Test
public void testWidgetSelectedHelper() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
SelectionEvent event = mock(SelectionEvent.class);
String testPath = "/home/devuser/some/path";
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtility, extensionPointWrapper);
testInstance1.setText(testPath);
testInstance1.widgetSelected(event);
assertEquals(testInstance1.getText(), testPath);
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method createTestInstance.
protected SelectionAdapterFileDialog createTestInstance() {
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textWidget = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE, new String[] {}, "");
return createTestInstance(log, textWidget, meta, options, repositoryUtility, extensionPointWrapper);
}
Aggregations