[
https://issues.apache.org/jira/browse/NIFI-1152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15092798#comment-15092798
]
Naveen Madhire commented on NIFI-1152:
--------------------------------------
I looked at this and created a sample test case, which shows how the mock
framework is not giving any exception when invalid relationship is used.
{code}
package org.apache.nifi.util;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processor.*;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
import org.junit.Test;
import java.util.*;
public class MockProcessorTestRelationship {
@Test
public void testProcessor() {
TestRunners.newTestRunner(SimpleProcessor.class).run();
}
protected static class SimpleProcessor extends AbstractProcessor {
static final PropertyDescriptor DEFAULTED_PROP = new
PropertyDescriptor.Builder()
.name("defaultedProp")
.description("A Sample Default property")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.defaultValue("default-value")
.build();
static final Relationship REL_SUCCESS = new Relationship.Builder()
.name("success")
.build();
static final Relationship REL_FAILURE = new Relationship.Builder()
.name("Failure")
.build();
public List<PropertyDescriptor> properties;
public Set<Relationship> relationships =
Collections.singleton(REL_SUCCESS);
@Override
public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
return properties;
}
@Override
public Set<Relationship> getRelationships() {
return relationships;
}
@Override
public void init(final ProcessorInitializationContext context) {
// relationships
final Set<Relationship> procRels = new HashSet<>();
procRels.add(REL_SUCCESS);
relationships = Collections.unmodifiableSet(procRels);
// descriptors
final List<PropertyDescriptor> supDescriptors = new ArrayList<>();
supDescriptors.add(DEFAULTED_PROP);
properties = Collections.unmodifiableList(supDescriptors);
}
@Override
public void onTrigger(final ProcessContext context, final
ProcessSession session) throws ProcessException {
final FlowFile file = session.create();
//Using the correct relationship
//session.transfer(file, REL_SUCCESS);
//Using the incorrect relationship
session.transfer(file, REL_FAILURE);
}
}
}
{code}
> Mock Framework allows processor to route to Relationships that the Processor
> does not support
> ---------------------------------------------------------------------------------------------
>
> Key: NIFI-1152
> URL: https://issues.apache.org/jira/browse/NIFI-1152
> Project: Apache NiFi
> Issue Type: Bug
> Components: Tools and Build
> Reporter: Mark Payne
> Labels: beginner, newbie
>
> If a processor calls ProcessSession.transfer(flowFile,
> NON_EXISTENT_RELATIONSHIP) the NiFi framework will throw a
> FlowFileHandlingException. However, the Mock Framework simply allows it and
> does not throw any sort of Exception. This needs to be addressed so that the
> Mock framework functions the same way as the normal NiFi framework.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)