use of org.apache.hop.core.logging.ILogChannel in project hop by apache.
the class StartPipelineServletTest method testStartPipelineServletEscapesHtmlWhenPipelineFound.
@Test
@PrepareForTest({ Encode.class })
public void testStartPipelineServletEscapesHtmlWhenPipelineFound() throws ServletException, IOException {
HopLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Pipeline mockPipeline = mock(Pipeline.class);
PipelineMeta mockPipelineMeta = mock(PipelineMeta.class);
ILogChannel mockChannelInterface = mock(ILogChannel.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(StartPipelineServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockPipelineMap.getPipeline(any(HopServerObjectEntry.class))).thenReturn(mockPipeline);
when(mockPipeline.getLogChannel()).thenReturn(mockChannelInterface);
when(mockPipeline.getLogChannelId()).thenReturn("test");
when(mockPipeline.getPipelineMeta()).thenReturn(mockPipelineMeta);
when(mockPipelineMeta.getMaximum()).thenReturn(new Point(10, 10));
startPipelineServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(Encode.class);
Encode.forHtml(anyString());
}
use of org.apache.hop.core.logging.ILogChannel in project hop by apache.
the class StartWorkflowServletTest method testStartWorkflowServletEscapesHtmlWhenPipelineFound.
@Test
@PrepareForTest({ Encode.class })
public void testStartWorkflowServletEscapesHtmlWhenPipelineFound() throws ServletException, IOException {
HopLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
IWorkflowEngine<WorkflowMeta> mockWorkflow = mock(Workflow.class);
WorkflowMeta mockWorkflowMeta = mock(WorkflowMeta.class);
ILogChannel mockLogChannelInterface = mock(ILogChannel.class);
mockWorkflowMeta.setName(ServletTestUtils.BAD_STRING_TO_TEST);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(StartWorkflowServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockWorkflowMap.getWorkflow(any(HopServerObjectEntry.class))).thenReturn(mockWorkflow);
when(mockWorkflow.getLogChannelId()).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockWorkflow.getLogChannel()).thenReturn(mockLogChannelInterface);
when(mockWorkflow.getWorkflowMeta()).thenReturn(mockWorkflowMeta);
when(mockWorkflowMeta.getMaximum()).thenReturn(new Point(10, 10));
startJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(Encode.class);
Encode.forHtml(anyString());
}
use of org.apache.hop.core.logging.ILogChannel in project hop by apache.
the class HopPipelineMetaToBeamPipelineConverter method createPipeline.
public Pipeline createPipeline() throws Exception {
try {
ILogChannel log = LogChannel.GENERAL;
// Create a new Pipeline
//
RunnerType runnerType = pipelineRunConfiguration.getRunnerType();
Class<? extends PipelineRunner<?>> runnerClass = getPipelineRunnerClass(runnerType);
PipelineOptions pipelineOptions = pipelineRunConfiguration.getPipelineOptions();
// The generic options
//
pipelineOptions.setUserAgent(variables.resolve(pipelineRunConfiguration.getUserAgent()));
pipelineOptions.setTempLocation(variables.resolve(pipelineRunConfiguration.getTempLocation()));
pipelineOptions.setJobName(sanitizeJobName(pipelineMeta.getName()));
pipelineOptions.setRunner(runnerClass);
Pipeline pipeline = Pipeline.create(pipelineOptions);
pipeline.getCoderRegistry().registerCoderForClass(HopRow.class, new HopRowCoder());
log.logBasic("Created Apache Beam pipeline with name '" + pipelineOptions.getJobName() + "'");
// Keep track of which transform outputs which Collection
//
Map<String, PCollection<HopRow>> transformCollectionMap = new HashMap<>();
// Handle io
//
handleBeamInputTransforms(log, transformCollectionMap, pipeline);
// Transform all the other transforms...
//
handleGenericTransform(transformCollectionMap, pipeline);
// Output handling
//
handleBeamOutputTransforms(log, transformCollectionMap, pipeline);
return pipeline;
} catch (Throwable e) {
throw new Exception("Error converting Hop pipeline to Beam", e);
}
}
use of org.apache.hop.core.logging.ILogChannel in project hop by apache.
the class ExtensionPointHandlerTest method callExtensionPointTest.
@Test
public void callExtensionPointTest() throws Exception {
IPluginMock pluginInterface = mock(IPluginMock.class);
when(pluginInterface.getName()).thenReturn(TEST_NAME);
when(pluginInterface.getMainType()).thenReturn((Class) IExtensionPoint.class);
when(pluginInterface.getIds()).thenReturn(new String[] { "testID" });
IExtensionPoint extensionPoint = mock(IExtensionPoint.class);
when(pluginInterface.loadClass(IExtensionPoint.class)).thenReturn(extensionPoint);
PluginRegistry.addPluginType(ExtensionPointPluginType.getInstance());
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
final ILogChannel log = mock(ILogChannel.class);
ExtensionPointHandler.callExtensionPoint(log, null, "noPoint", null);
verify(extensionPoint, never()).callExtensionPoint(any(ILogChannel.class), any(), any());
ExtensionPointHandler.callExtensionPoint(log, null, TEST_NAME, null);
verify(extensionPoint, times(1)).callExtensionPoint(eq(log), any(), isNull());
}
use of org.apache.hop.core.logging.ILogChannel in project hop by apache.
the class ExtensionPointIntegrationTest method test.
@Test
public void test() throws Exception {
// check that all extension points are added to the map
assertEquals(HopExtensionPoint.values().length, ExtensionPointMap.getInstance().getNumberOfRows());
// check that all extension points are executed
final ILogChannel log = mock(ILogChannel.class);
for (HopExtensionPoint ep : HopExtensionPoint.values()) {
final IExtensionPoint currentEP = ExtensionPointMap.getInstance().getTableValue(ep.id, "id" + ep.id);
assertFalse(currentEP.getClass().getField(EXECUTED_FIELD_NAME).getBoolean(currentEP));
ExtensionPointHandler.callExtensionPoint(log, null, ep.id, null);
assertTrue(currentEP.getClass().getField(EXECUTED_FIELD_NAME).getBoolean(currentEP));
}
// check modification of extension point
final HopExtensionPoint jobAfterOpen = HopExtensionPoint.WorkflowAfterOpen;
final IExtensionPoint 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(HopExtensionPoint.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(HopExtensionPoint.values().length - 1, ExtensionPointMap.getInstance().getNumberOfRows());
}
Aggregations