Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/761#discussion_r73238649
--- Diff:
nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-pubsub-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/StubPublishKafka.java
---
@@ -85,21 +95,31 @@ protected KafkaPublisher
buildKafkaResource(ProcessContext context, ProcessSessi
@SuppressWarnings("unchecked")
private void instrumentProducer(Producer<byte[], byte[]> producer,
boolean failRandomly) {
+
when(producer.send(Mockito.any(ProducerRecord.class))).then(new
Answer<Future<RecordMetadata>>() {
- @SuppressWarnings("rawtypes")
@Override
public Future<RecordMetadata> answer(InvocationOnMock
invocation) throws Throwable {
ProducerRecord<byte[], byte[]> record =
(ProducerRecord<byte[], byte[]>) invocation.getArguments()[0];
- String value = new String(record.value(),
StandardCharsets.UTF_8);
+ final String value = new String(record.value(),
StandardCharsets.UTF_8);
if ("fail".equals(value) && !StubPublishKafka.this.failed)
{
StubPublishKafka.this.failed = true;
throw new RuntimeException("intentional");
}
- Future future = mock(Future.class);
- if ("futurefail".equals(value) &&
!StubPublishKafka.this.failed) {
- StubPublishKafka.this.failed = true;
- when(future.get(Mockito.anyLong(),
Mockito.any(TimeUnit.class))).thenThrow(ExecutionException.class);
- }
+
+ Future<RecordMetadata> future = executor.submit(new
Callable<RecordMetadata>() {
+ @Override
+ public RecordMetadata call() throws Exception {
+ if ("futurefail".equals(value) &&
!StubPublishKafka.this.failed) {
+ // System.out.println("FAIL");
--- End diff --
Can remove this line?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---