forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-4664, NIFI-4662, NIFI-4660, NIFI-4659 moved tests which are timi…
…ng/threading/network dependent and brittle to integration tests and un-ignored tests that are IT. Updated travis to reduce impact on infra and appveyor now skips test runs so is just to prove build works on windows. This closes apache#2319 squash
- Loading branch information
Showing
17 changed files
with
1,401 additions
and
1,111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
426 changes: 426 additions & 0 deletions
426
...ssor-utils/src/test/java/org/apache/nifi/processor/util/list/ITAbstractListProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
353 changes: 6 additions & 347 deletions
353
...or-utils/src/test/java/org/apache/nifi/processor/util/list/TestAbstractListProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...0-10-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/ITConsumeKafka.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.nifi.processors.kafka.pubsub; | ||
|
||
import static org.mockito.Matchers.anyObject; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.apache.nifi.logging.ComponentLog; | ||
import org.apache.nifi.processor.ProcessContext; | ||
import org.apache.nifi.util.TestRunner; | ||
import org.apache.nifi.util.TestRunners; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class ITConsumeKafka { | ||
|
||
ConsumerLease mockLease = null; | ||
ConsumerPool mockConsumerPool = null; | ||
|
||
@Before | ||
public void setup() { | ||
mockLease = mock(ConsumerLease.class); | ||
mockConsumerPool = mock(ConsumerPool.class); | ||
} | ||
|
||
@Test | ||
public void validateGetAllMessages() throws Exception { | ||
String groupName = "validateGetAllMessages"; | ||
|
||
when(mockConsumerPool.obtainConsumer(anyObject(), anyObject())).thenReturn(mockLease); | ||
when(mockLease.continuePolling()).thenReturn(Boolean.TRUE, Boolean.TRUE, Boolean.FALSE); | ||
when(mockLease.commit()).thenReturn(Boolean.TRUE); | ||
|
||
ConsumeKafka_0_10 proc = new ConsumeKafka_0_10() { | ||
@Override | ||
protected ConsumerPool createConsumerPool(final ProcessContext context, final ComponentLog log) { | ||
return mockConsumerPool; | ||
} | ||
}; | ||
final TestRunner runner = TestRunners.newTestRunner(proc); | ||
runner.setProperty(KafkaProcessorUtils.BOOTSTRAP_SERVERS, "0.0.0.0:1234"); | ||
runner.setProperty(ConsumeKafka_0_10.TOPICS, "foo,bar"); | ||
runner.setProperty(ConsumeKafka_0_10.GROUP_ID, groupName); | ||
runner.setProperty(ConsumeKafka_0_10.AUTO_OFFSET_RESET, ConsumeKafka_0_10.OFFSET_EARLIEST); | ||
runner.run(1, false); | ||
|
||
verify(mockConsumerPool, times(1)).obtainConsumer(anyObject(), anyObject()); | ||
verify(mockLease, times(3)).continuePolling(); | ||
verify(mockLease, times(2)).poll(); | ||
verify(mockLease, times(1)).commit(); | ||
verify(mockLease, times(1)).close(); | ||
verifyNoMoreInteractions(mockConsumerPool); | ||
verifyNoMoreInteractions(mockLease); | ||
} | ||
|
||
@Test | ||
public void validateGetAllMessagesPattern() throws Exception { | ||
String groupName = "validateGetAllMessagesPattern"; | ||
|
||
when(mockConsumerPool.obtainConsumer(anyObject(), anyObject())).thenReturn(mockLease); | ||
when(mockLease.continuePolling()).thenReturn(Boolean.TRUE, Boolean.TRUE, Boolean.FALSE); | ||
when(mockLease.commit()).thenReturn(Boolean.TRUE); | ||
|
||
ConsumeKafka_0_10 proc = new ConsumeKafka_0_10() { | ||
@Override | ||
protected ConsumerPool createConsumerPool(final ProcessContext context, final ComponentLog log) { | ||
return mockConsumerPool; | ||
} | ||
}; | ||
final TestRunner runner = TestRunners.newTestRunner(proc); | ||
runner.setProperty(KafkaProcessorUtils.BOOTSTRAP_SERVERS, "0.0.0.0:1234"); | ||
runner.setProperty(ConsumeKafka_0_10.TOPICS, "(fo.*)|(ba)"); | ||
runner.setProperty(ConsumeKafka_0_10.TOPIC_TYPE, "pattern"); | ||
runner.setProperty(ConsumeKafka_0_10.GROUP_ID, groupName); | ||
runner.setProperty(ConsumeKafka_0_10.AUTO_OFFSET_RESET, ConsumeKafka_0_10.OFFSET_EARLIEST); | ||
runner.run(1, false); | ||
|
||
verify(mockConsumerPool, times(1)).obtainConsumer(anyObject(), anyObject()); | ||
verify(mockLease, times(3)).continuePolling(); | ||
verify(mockLease, times(2)).poll(); | ||
verify(mockLease, times(1)).commit(); | ||
verify(mockLease, times(1)).close(); | ||
verifyNoMoreInteractions(mockConsumerPool); | ||
verifyNoMoreInteractions(mockLease); | ||
} | ||
|
||
@Test | ||
public void validateGetErrorMessages() throws Exception { | ||
String groupName = "validateGetErrorMessages"; | ||
|
||
when(mockConsumerPool.obtainConsumer(anyObject(), anyObject())).thenReturn(mockLease); | ||
when(mockLease.continuePolling()).thenReturn(true, false); | ||
when(mockLease.commit()).thenReturn(Boolean.FALSE); | ||
|
||
ConsumeKafka_0_10 proc = new ConsumeKafka_0_10() { | ||
@Override | ||
protected ConsumerPool createConsumerPool(final ProcessContext context, final ComponentLog log) { | ||
return mockConsumerPool; | ||
} | ||
}; | ||
final TestRunner runner = TestRunners.newTestRunner(proc); | ||
runner.setProperty(KafkaProcessorUtils.BOOTSTRAP_SERVERS, "0.0.0.0:1234"); | ||
runner.setProperty(ConsumeKafka_0_10.TOPICS, "foo,bar"); | ||
runner.setProperty(ConsumeKafka_0_10.GROUP_ID, groupName); | ||
runner.setProperty(ConsumeKafka_0_10.AUTO_OFFSET_RESET, ConsumeKafka_0_10.OFFSET_EARLIEST); | ||
runner.run(1, false); | ||
|
||
verify(mockConsumerPool, times(1)).obtainConsumer(anyObject(), anyObject()); | ||
verify(mockLease, times(2)).continuePolling(); | ||
verify(mockLease, times(1)).poll(); | ||
verify(mockLease, times(1)).commit(); | ||
verify(mockLease, times(1)).close(); | ||
verifyNoMoreInteractions(mockConsumerPool); | ||
verifyNoMoreInteractions(mockLease); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.