use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-metaverse by pentaho.
the class BaseRuntimeExtensionPointTest method testTransCreateExecutionProfile.
@Test
public void testTransCreateExecutionProfile() throws Exception {
Trans trans = Mockito.mock(Trans.class);
IExecutionProfile profile = extensionPoint.createExecutionProfile(null, trans);
assertEquals(profile, TransLineageHolderMap.getInstance().getLineageHolder(trans).getExecutionProfile());
assertNull(profile.getExecutionData().getLoggingChannelId());
// reset the execution profile
TransLineageHolderMap.getInstance().getLineageHolder(trans).setExecutionProfile(null);
final String logChannelId = "channel-id";
LogChannelInterface logChannelInterface = Mockito.mock(LogChannelInterface.class);
when(logChannelInterface.getLogChannelId()).thenReturn(logChannelId);
profile = extensionPoint.createExecutionProfile(logChannelInterface, trans);
assertEquals(logChannelId, profile.getExecutionData().getLoggingChannelId());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class GetStatusServletTest method setupForTransDroppedFromMap.
private void setupForTransDroppedFromMap(HttpServletRequest mockHttpServletRequest, HttpServletResponse mockHttpServletResponse, StringWriter out) throws IOException {
KettleLogStore.init();
Trans mockTrans = mock(Trans.class);
TransMeta mockTransMeta = mock(TransMeta.class);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
PrintWriter printWriter = new PrintWriter(out);
CarteObjectEntry carteObjectEntry1 = new CarteObjectEntry("name1", "testTranId1");
CarteObjectEntry carteObjectEntry2 = new CarteObjectEntry("name2", "testTranId2");
when(mockHttpServletRequest.getContextPath()).thenReturn(GetStatusServlet.CONTEXT_PATH);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
Job mockJob = mock(Job.class);
when(mockTransformationMap.getTransformationObjects()).thenReturn(Arrays.asList(carteObjectEntry1, carteObjectEntry2));
when(mockTransformationMap.getTransformation(carteObjectEntry1)).thenReturn(// Would have done this anyways but this line is to show it is required
null);
when(mockTransformationMap.getTransformation(carteObjectEntry2)).thenReturn(mockTrans);
}
use of org.pentaho.di.core.logging.LogChannelInterface 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.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class ExtensionPointIntegrationTest method test.
@Test
public void test() throws Exception {
// check that all extension points are added to the map
assertEquals(KettleExtensionPoint.values().length, ExtensionPointMap.getInstance().getNumberOfRows());
// check that all extension points are executed
final LogChannelInterface log = mock(LogChannelInterface.class);
for (KettleExtensionPoint ep : KettleExtensionPoint.values()) {
final ExtensionPointInterface currentEP = ExtensionPointMap.getInstance().getTableValue(ep.id, "id" + ep.id);
assertFalse(currentEP.getClass().getField(EXECUTED_FIELD_NAME).getBoolean(currentEP));
ExtensionPointHandler.callExtensionPoint(log, ep.id, null);
assertTrue(currentEP.getClass().getField(EXECUTED_FIELD_NAME).getBoolean(currentEP));
}
// check modification of extension point
final KettleExtensionPoint jobAfterOpen = KettleExtensionPoint.JobAfterOpen;
final ExtensionPointInterface int1 = ExtensionPointMap.getInstance().getTableValue(jobAfterOpen.id, "id" + jobAfterOpen.id);
ExtensionPointPluginType.getInstance().registerCustom(createClassRuntime(jobAfterOpen, "Edited"), "custom", "id" + jobAfterOpen.id, jobAfterOpen.id, "no description", null);
assertNotSame(int1, ExtensionPointMap.getInstance().getTableValue(jobAfterOpen.id, "id" + jobAfterOpen.id));
assertEquals(KettleExtensionPoint.values().length, ExtensionPointMap.getInstance().getNumberOfRows());
// check removal of extension point
PluginRegistry.getInstance().removePlugin(ExtensionPointPluginType.class, PluginRegistry.getInstance().getPlugin(ExtensionPointPluginType.class, "id" + jobAfterOpen.id));
assertTrue(ExtensionPointMap.getInstance().getTableValue(jobAfterOpen.id, "id" + jobAfterOpen.id) == null);
assertEquals(KettleExtensionPoint.values().length - 1, ExtensionPointMap.getInstance().getNumberOfRows());
}
use of org.pentaho.di.core.logging.LogChannelInterface in project pentaho-kettle by pentaho.
the class ExtensionPointIntegrationTest method testExtensionPointMapConcurrency.
@Test
public void testExtensionPointMapConcurrency() throws InterruptedException {
final LogChannelInterface log = mock(LogChannelInterface.class);
List<Runnable> parallelTasksList = new ArrayList<>(TOTAL_THREADS_TO_RUN);
for (int i = 0; i < TOTAL_THREADS_TO_RUN; i++) {
parallelTasksList.add(() -> {
KettleExtensionPoint kettleExtensionPoint = getRandomKettleExtensionPoint();
PluginInterface pluginInterface = PluginRegistry.getInstance().getPlugin(ExtensionPointPluginType.class, "id" + kettleExtensionPoint.id);
try {
PluginRegistry.getInstance().removePlugin(ExtensionPointPluginType.class, pluginInterface);
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
} catch (KettlePluginException e) {
e.printStackTrace();
} catch (NullPointerException e) {
// NullPointerException can be thrown if trying to remove a plugin that doesn't exit, discarding occurence
}
ExtensionPointMap.getInstance().reInitialize();
try {
ExtensionPointMap.getInstance().callExtensionPoint(log, kettleExtensionPoint.id, null);
} catch (KettleException e) {
e.printStackTrace();
}
});
}
assertConcurrent(parallelTasksList);
}
Aggregations