nandorsoma commented on code in PR #6046:
URL: https://github.com/apache/nifi/pull/6046#discussion_r881342030
##########
nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPIT.java:
##########
@@ -73,82 +69,84 @@ public class GetSNMPIT {
registerManagedObjects(v3TestAgent);
}
- @Parameterized.Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {v1TestAgent, v1TestRunnerFactory},
- {v2cTestAgent, v2cTestRunnerFactory},
- {v3TestAgent, v3TestRunnerFactory}
- });
+ private static Stream<Arguments> provideArguments() {
+ return Stream.of(
+ Arguments.of(v1TestAgent, v1TestRunnerFactory),
+ Arguments.of(v2cTestAgent, v2cTestRunnerFactory),
+ Arguments.of(v3TestAgent, v3TestRunnerFactory)
+ );
}
- private final TestAgent testAgent;
- private final SNMPTestRunnerFactory testRunnerFactory;
-
- public GetSNMPIT(final TestAgent testAgent, final SNMPTestRunnerFactory
testRunnerFactory) {
- this.testAgent = testAgent;
- this.testRunnerFactory = testRunnerFactory;
- }
-
- @Before
- public void setUp() throws IOException {
+ @ParameterizedTest
+ @MethodSource("provideArguments")
+ void testSnmpGet(TestAgent testAgent, SNMPTestRunnerFactory
testRunnerFactory) throws IOException {
testAgent.start();
+ try {
+ final TestRunner runner =
testRunnerFactory.createSnmpGetTestRunner(testAgent.getPort(), READ_ONLY_OID_1,
GET);
+ runner.run();
+ final MockFlowFile successFF =
runner.getFlowFilesForRelationship(GetSNMP.REL_SUCCESS).get(0);
+
+ assertNotNull(successFF);
+ assertEquals(READ_ONLY_OID_VALUE_1,
successFF.getAttribute(SNMPUtils.SNMP_PROP_PREFIX + READ_ONLY_OID_1 +
SNMPUtils.SNMP_PROP_DELIMITER + "4"));
+ } catch (Exception ignored) {
Review Comment:
Why do you ignore the exception? This way in case of an unwanted error the
test will pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]