Search in sources :

Example 1 with SandboxedNodeCreator

use of org.knime.core.node.exec.SandboxedNodeCreator in project knime-core by knime.

the class BugAP7010_DataLoadedWithSandboxedNodeCreator method testExecuteAfterSandboxedNodeCreation.

/**
 * Creates an SandboxedNode of a node of the workflow and
 * executes the workflow afterwards.
 * @throws Exception
 */
@Test(timeout = 30000L)
public void testExecuteAfterSandboxedNodeCreation() throws Exception {
    WorkflowManager manager = getManager();
    checkState(manager, CONFIGURED);
    // Get some things we need to create the SandboxedNode
    NodeContainer tableCreator = findNodeContainer(m_tableCreator);
    NodeContainer rowSplitter = findNodeContainer(m_rowSplitter);
    PortObject[] inputData = new PortObject[2];
    inputData[1] = tableCreator.getOutPort(1).getPortObject();
    ExecutionMonitor exec = new ExecutionMonitor();
    // Set the location and the WFM
    File sandboxedDir = FileUtil.createTempDir(getClass().getSimpleName() + "-sandboxed");
    // Create the SandboxedNode
    SandboxedNodeCreator nodeCreator = new SandboxedNodeCreator(rowSplitter, inputData, m_sandboxedWM);
    nodeCreator.setLocalWorkflowDir(CheckUtils.checkArgumentNotNull(sandboxedDir));
    nodeCreator.setCopyData(true);
    NodeContext.pushContext(rowSplitter);
    NodeID workflowID;
    try (SandboxedNode node = nodeCreator.createSandbox(exec)) {
        workflowID = node.getSandboxNode(NodeContainer.class).getParent().getID();
    } finally {
        NodeContext.removeLastContext();
    }
    // Now, try to execute the original workflow. This should still work
    executeAllAndWait();
    checkState(manager, EXECUTED);
}
Also used : SandboxedNodeCreator(org.knime.core.node.exec.SandboxedNodeCreator) SandboxedNode(org.knime.core.node.exec.SandboxedNodeCreator.SandboxedNode) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) PortObject(org.knime.core.node.port.PortObject) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)1 SandboxedNodeCreator (org.knime.core.node.exec.SandboxedNodeCreator)1 SandboxedNode (org.knime.core.node.exec.SandboxedNodeCreator.SandboxedNode)1 PortObject (org.knime.core.node.port.PortObject)1