use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SalesforceConnectionIT method testConnect.
private void testConnect(String password) throws Exception {
LogChannelInterface logInterface = mock(LogChannelInterface.class);
String url = "http://localhost/services/Soap/u/37.0";
String username = "MySampleUsername";
SalesforceConnection connection;
connection = spy(new SalesforceConnection(logInterface, url, username, password));
ArgumentCaptor<ConnectorConfig> captorConfig = ArgumentCaptor.forClass(ConnectorConfig.class);
ConnectorConfig mockConfig = mock(ConnectorConfig.class);
doReturn(UUID.randomUUID().toString()).when(mockConfig).getUsername();
doReturn(UUID.randomUUID().toString()).when(mockConfig).getPassword();
doReturn(mockConfig).when(bindingStub).getConfig();
doReturn(mock(LoginResult.class)).when(bindingStub).login(anyString(), anyString());
try {
connection.connect();
} catch (KettleException e) {
// The connection should fail
// We just want to see the generated ConnectorConfig
}
verify(connection).createBinding(captorConfig.capture());
assertEquals(username, captorConfig.getValue().getUsername());
// Password is unchanged (not decrypted) when setting in ConnectorConfig
assertEquals(password, captorConfig.getValue().getPassword());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class BaseStepTest method testBaseStepPutRowLocalSpecialPartitioning.
/**
* This test checks that data from one non-partitioned step copies to 2 partitioned steps right.
*
* @throws KettleException
* @see {@link <a href="http://jira.pentaho.com/browse/PDI-12211">http://jira.pentaho.com/browse/PDI-12211<a>}
*/
@Test
public void testBaseStepPutRowLocalSpecialPartitioning() throws KettleException {
List<StepMeta> stepMetas = new ArrayList<StepMeta>();
stepMetas.add(mockHelper.stepMeta);
stepMetas.add(mockHelper.stepMeta);
StepPartitioningMeta stepPartitioningMeta = spy(new StepPartitioningMeta());
BasePartitioner partitioner = mock(BasePartitioner.class);
when(mockHelper.logChannelInterfaceFactory.create(any(), any(LoggingObjectInterface.class))).thenAnswer(new Answer<LogChannelInterface>() {
@Override
public LogChannelInterface answer(InvocationOnMock invocation) throws Throwable {
((BaseStep) invocation.getArguments()[0]).getLogLevel();
return mockHelper.logChannelInterface;
}
});
when(mockHelper.trans.isRunning()).thenReturn(true);
when(mockHelper.transMeta.findNextSteps(any(StepMeta.class))).thenReturn(stepMetas);
when(mockHelper.stepMeta.getStepPartitioningMeta()).thenReturn(stepPartitioningMeta);
when(stepPartitioningMeta.getPartitioner()).thenReturn(partitioner);
when(partitioner.getNrPartitions()).thenReturn(2);
Object object0 = "name0";
ValueMetaInterface meta0 = new ValueMetaString(object0.toString());
Object object1 = "name1";
ValueMetaInterface meta2 = new ValueMetaString(object1.toString());
RowMetaInterface rowMeta0 = new RowMeta();
rowMeta0.addValueMeta(meta0);
Object[] objects0 = { object0 };
RowMetaInterface rowMeta1 = new RowMeta();
rowMeta1.addValueMeta(meta2);
Object[] objects1 = { object1 };
when(stepPartitioningMeta.getPartition(rowMeta0, objects0)).thenReturn(0);
when(stepPartitioningMeta.getPartition(rowMeta1, objects1)).thenReturn(1);
BlockingRowSet[] rowSet = { new BlockingRowSet(2), new BlockingRowSet(2), new BlockingRowSet(2), new BlockingRowSet(2) };
List<RowSet> outputRowSets = new ArrayList<RowSet>();
outputRowSets.addAll(Arrays.asList(rowSet));
BaseStep baseStep = new BaseStep(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
baseStep.setStopped(false);
baseStep.setRepartitioning(StepPartitioningMeta.PARTITIONING_METHOD_SPECIAL);
baseStep.setOutputRowSets(outputRowSets);
baseStep.putRow(rowMeta0, objects0);
baseStep.putRow(rowMeta1, objects1);
assertEquals(object0, baseStep.getOutputRowSets().get(0).getRow()[0]);
assertEquals(object1, baseStep.getOutputRowSets().get(1).getRow()[0]);
assertEquals(object0, baseStep.getOutputRowSets().get(2).getRow()[0]);
assertEquals(object1, baseStep.getOutputRowSets().get(3).getRow()[0]);
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class SniffStepServletIT method testSniffStepServletEscapesHtmlWhenTransFound.
@Test
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);
when(mockHttpServletRequest.getContextPath()).thenReturn(SniffStepServlet.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.getLogChannelId()).thenReturn("test");
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
when(mockTrans.findBaseSteps(ServletTestUtils.BAD_STRING)).thenReturn(stepInterfaces);
sniffStepServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class StopJobServletIT method testStopJobServletEscapesHtmlWhenTransFound.
@Test
public void testStopJobServletEscapesHtmlWhenTransFound() 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(StopJobServlet.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.getLogChannelId()).thenReturn(ServletTestUtils.BAD_STRING);
when(mockJob.getLogChannel()).thenReturn(mockLogChannelInterface);
when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
when(mockJobMeta.getMaximum()).thenReturn(new Point(10, 10));
stopJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class JobEntryWriteToLogTest method verifyErrorMessageForParentJobLogLevel.
private void verifyErrorMessageForParentJobLogLevel(LogLevel parentJobLogLevel, VerificationMode mode) {
jobEntry.setLogMessage("TEST");
jobEntry.setEntryLogLevel(LogLevel.ERROR);
doReturn(parentJobLogLevel).when(parentJob).getLogLevel();
jobEntry.setParentJob(parentJob);
LogChannelInterface logChannel = spy(jobEntry.createLogChannel());
doReturn(logChannel).when(jobEntry).createLogChannel();
jobEntry.evaluate(new Result());
verify(logChannel, mode).logError("TEST" + Const.CR);
}
Aggregations