当前位置: 首页>>代码示例>>Java>>正文


Java TestRunner.assertValid方法代码示例

本文整理汇总了Java中org.apache.nifi.util.TestRunner.assertValid方法的典型用法代码示例。如果您正苦于以下问题:Java TestRunner.assertValid方法的具体用法?Java TestRunner.assertValid怎么用?Java TestRunner.assertValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.nifi.util.TestRunner的用法示例。


在下文中一共展示了TestRunner.assertValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: single_host_without_credentials

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void single_host_without_credentials() throws InitializationException {
    final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
    final StandardMongoClientService service = new StandardMongoClientService();
    runner.addControllerService("test-good1", service);

    runner.setProperty(service, StandardMongoClientService.HOSTS, "localhost:27017");
    runner.enableControllerService(service);

    runner.assertValid(service);
    StandardMongoClientService mongoService = (StandardMongoClientService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-good1");
    assertNotNull(mongoService);
    MongoClient mongoClient = mongoService.getMongoClient();
    assertNotNull(mongoClient);

    assertEquals(0, mongoClient.getDatabase(MONGO_DATABASE_NAME).getCollection("sample").count());
    mongoClient.dropDatabase(MONGO_DATABASE_NAME);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:19,代码来源:StandardMongoClientServiceIT.java

示例2: validateFullConfigWithUserLib

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateFullConfigWithUserLib() throws Exception {
    TestRunner runner = TestRunners.newTestRunner(mock(Processor.class));
    JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider();
    runner.addControllerService("cfProvider", cfProvider);
    runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234");

    runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH,
            new File("test-lib").getAbsolutePath()); // see README in 'test-lib' dir for more info
    runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "org.apache.nifi.jms.testcflib.TestConnectionFactory");
    runner.setProperty(cfProvider, "Foo", "foo");
    runner.setProperty(cfProvider, "Bar", "3");

    runner.enableControllerService(cfProvider);
    runner.assertValid(cfProvider);
    ConnectionFactory cf = cfProvider.getConnectionFactory();
    assertNotNull(cf);
    assertEquals("org.apache.nifi.jms.testcflib.TestConnectionFactory", cf.getClass().getName());
    assertEquals("myhost", this.get("getHost", cf));
    assertEquals(1234, ((Integer) this.get("getPort", cf)).intValue());
    assertEquals("foo", this.get("getFoo", cf));
    assertEquals(3, ((Integer) this.get("getBar", cf)).intValue());
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:25,代码来源:JMSConnectionFactoryProviderTest.java

示例3: validateFullConfigWithUserLib

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateFullConfigWithUserLib() throws Exception {
    TestRunner runner = TestRunners.newTestRunner(mock(Processor.class));


    JNDIConnectionFactoryProvider cfProvider = new JNDIConnectionFactoryProvider();
    //when(cfProvider.getConnectionFactory()).thenReturn(mcf);
    runner.addControllerService("cfProvider", cfProvider);
    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.BROKER_URI, "vm://localhost?broker.persistent=false");
    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.JNDI_CF_LOOKUP, "ConnectionFactory");

    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CLIENT_LIB_DIR_PATH,
            TestUtils.setupActiveMqLibForTesting(false)); // see README in 'test-lib' dir for more info
    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "org.apache.activemq.jndi.ActiveMQInitialContextFactory");

    runner.enableControllerService(cfProvider);
    runner.assertValid(cfProvider);
    ConnectionFactory cf = cfProvider.getConnectionFactory();
    assertNotNull(cf);
    assertEquals("org.apache.activemq.ActiveMQConnectionFactory", cf.getClass().getName());
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:23,代码来源:JNDIConnectionFactoryProviderTest.java

示例4: testBackPressured

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testBackPressured() {
    final TestRunner runner = TestRunners.newTestRunner(RouteOnBackPressure.class);
    runner.assertValid();

    for (int i = 0; i < 100; ++i) {
        runner.enqueue(new byte[0]);
    }

    runner.run(100);

    runner.assertTransferCount(RouteOnBackPressure.PASS_THROUGH, 100);
    runner.assertTransferCount(RouteOnBackPressure.BACK_PRESSURED, 0);

    runner.setRelationshipUnavailable(RouteOnBackPressure.PASS_THROUGH);

    for (int i = 0; i < 100; ++i) {
        runner.enqueue(new byte[0]);
    }

    runner.run(100);

    runner.assertTransferCount(RouteOnBackPressure.PASS_THROUGH, 100);
    runner.assertTransferCount(RouteOnBackPressure.BACK_PRESSURED, 100);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:26,代码来源:RouteOnBackPressureTest.java

示例5: testDropIndexInNamespace

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testDropIndexInNamespace() throws Exception {
    TestRunner runner = TestRunners.newTestRunner(new StoreInMongo());
    addMongoService(runner);
    MongoCollection<Document> collection = mongo.getMongoClient().getDatabase(MONGO_DATABASE_NAME).getCollection("index_test");
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "index_test");
    String index1Json = "[ {\"a\": 1} ]";
    runner.setProperty(MongoProps.INDEX, index1Json);
    runner.assertValid();
    runner.run();
    Set<String> indexNames = AbstractMongoProcessor.getIndexNames(collection);
    String normalizedIndex1Name = AbstractMongoProcessor.normalizeIndexName(index1Json);
    assertTrue(indexNames.contains(normalizedIndex1Name));

    String index2Json = "[ {\"a\": -1} ]";
    runner.setProperty(MongoProps.INDEX, index2Json);
    runner.assertValid();
    runner.run();
    indexNames = AbstractMongoProcessor.getIndexNames(collection);
    String normalizedIndex2Name = AbstractMongoProcessor.normalizeIndexName(index2Json);
    assertTrue(indexNames.contains(normalizedIndex2Name));
    assertTrue(!indexNames.contains(normalizedIndex1Name));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:25,代码来源:StoreInMongoIT.java

示例6: validateFactoryCreationWithActiveMQLibraries

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
/**
 * This test simply validates that {@link ConnectionFactory} can be setup by
 * pointing to the location of the client libraries at runtime. It uses
 * ActiveMQ which is not present at the POM but instead pulled from Maven
 * repo using {@link TestUtils#setupActiveMqLibForTesting(boolean)}, which
 * implies that for this test to run the computer must be connected to the
 * Internet. If computer is not connected to the Internet, this test will
 * quietly fail logging a message.
 */
@Test
public void validateFactoryCreationWithActiveMQLibraries() throws Exception {
    try {
        String libPath = TestUtils.setupActiveMqLibForTesting(true);

        TestRunner runner = TestRunners.newTestRunner(mock(Processor.class));
        JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider();
        runner.addControllerService("cfProvider", cfProvider);
        runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI,
                "vm://localhost?broker.persistent=false");
        runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, libPath);
        runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
                "org.apache.activemq.ActiveMQConnectionFactory");
        runner.enableControllerService(cfProvider);
        runner.assertValid(cfProvider);

        Connection connection = cfProvider.getConnectionFactory().createConnection();
        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = session.createQueue("myqueue");
        MessageProducer producer = session.createProducer(queue);
        MessageConsumer consumer = session.createConsumer(queue);

        TextMessage message = session.createTextMessage("Hello");
        producer.send(message);
        assertEquals("Hello", ((TextMessage) consumer.receive()).getText());
        connection.stop();
        connection.close();
    } catch (Exception e) {
        logger.error("'validateFactoryCreationWithActiveMQLibraries' failed due to ", e);
    }
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:43,代码来源:JMSConnectionFactoryProviderTest.java

示例7: validateFactoryCreationWithActiveMQLibraries

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
/**
 * This test simply validates that {@link ConnectionFactory} can be setup by pointing to the location of the client
 * libraries at runtime. It uses ActiveMQ which is not present at the POM but instead pulled from Maven repo using
 * {@link TestUtils#setupActiveMqLibForTesting(boolean)}, which implies that for this test to run the computer must
 * be connected to the Internet. If computer is not connected to the Internet, this test will quietly fail logging a
 * message.
 */
@Test
public void validateFactoryCreationWithActiveMQLibraries() throws Exception {
    try {
        String libPath = TestUtils.setupActiveMqLibForTesting(true);

        TestRunner runner = TestRunners.newTestRunner(mock(Processor.class));
        JNDIConnectionFactoryProvider cfProvider = new JNDIConnectionFactoryProvider();
        runner.addControllerService("cfProvider", cfProvider);
        runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.BROKER_URI,
                "vm://localhost?broker.persistent=false");
        runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.JNDI_CF_LOOKUP, "ConnectionFactory");
        runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, libPath);
        runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
                "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        runner.enableControllerService(cfProvider);
        runner.assertValid(cfProvider);

        Connection connection = cfProvider.getConnectionFactory().createConnection();
        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = session.createQueue("myqueue");
        MessageProducer producer = session.createProducer(queue);
        MessageConsumer consumer = session.createConsumer(queue);

        TextMessage message = session.createTextMessage("Hello");
        producer.send(message);
        assertEquals("Hello", ((TextMessage) consumer.receive()).getText());
        connection.stop();
        connection.close();
    } catch (Exception e) {
        logger.error("'validateFactoryCreationWithActiveMQLibraries' failed due to ", e);
    }
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:42,代码来源:JNDIConnectionFactoryProviderTest.java

示例8: testService

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testService() throws InitializationException {
    final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
    final StandardMyService service = new StandardMyService();
    runner.addControllerService("test-good", service);

    runner.setProperty(service, StandardMyService.MY_PROPERTY, "test-value");
    runner.enableControllerService(service);

    runner.assertValid(service);
}
 
开发者ID:wadesalazar,项目名称:NIFI-OPCUA,代码行数:12,代码来源:TestStandardMyService.java

示例9: validating_complete_auth_inputs

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validating_complete_auth_inputs() throws InitializationException {
    final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
    final StandardMongoClientService service = new StandardMongoClientService();

    Map<String, String> props = new HashMap<>();
    props.put(StandardMongoClientService.HOSTS.getName(), "localhost:27017");
    props.put(StandardMongoClientService.USERNAME.getName(), "mongouser");
    props.put(StandardMongoClientService.PASSWORD.getName(), "mongouser");
    props.put(StandardMongoClientService.AUTH_DATABASE.getName(), "mongouser");
    runner.addControllerService("test_hosts", service, props);
    runner.assertValid(service);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:14,代码来源:StandardMongoClientServiceIT.java

示例10: testGenerateTimeSeries

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testGenerateTimeSeries() {
    TestRunner runner = TestRunners.newTestRunner(new GenerateTimeSeriesFlowFile());
    runner.setProperty(GenerateTimeSeriesFlowFile.SIMULATOR_CONFIG, getClass().getResource("/configs/basicConfig.json").getPath());
    runner.assertValid();

    runner.run();

    runner.assertTransferCount(GenerateTimeSeriesFlowFile.SUCCESS, 1);
}
 
开发者ID:hashmapinc,项目名称:nifi-simulator-bundle,代码行数:11,代码来源:GenerateTimeSeriesFlowfileTest.java

示例11: onTrigger

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void onTrigger() throws Exception {
    TestRunner runner = TestRunners.newTestRunner(new ProtobufEncoder());

    HashMap<String, String> adressBookProperties = new HashMap<>();
    adressBookProperties.put("protobuf.schemaPath", ProtobufEncoderTest.class.getResource("/schemas/AddressBook.desc").getPath());
    adressBookProperties.put("protobuf.messageType", "AddressBook");

    // AddressBook test
    for (String filename: validTestFiles) {
        InputStream jsonFile = ProtobufEncoderTest.class.getResourceAsStream("/data/" + filename + ".json");
        adressBookProperties.put("testfile", filename);
        runner.enqueue(jsonFile, adressBookProperties);
    }

    // Ensure the configuration is valid as-is
    runner.assertValid();

    // Run the enqueued content, it also takes an int = number of contents queued
    runner.run(validTestFiles.length);
    runner.assertQueueEmpty();

    // Check if the data was processed without failure
    List<MockFlowFile> results = runner.getFlowFilesForRelationship(ProtobufDecoder.SUCCESS);
    Assert.assertEquals("All flowfiles should be returned to success", validTestFiles.length, results.size());

    // Check if the content of the flowfile is as expected
    for (MockFlowFile result: results) {
        result.assertContentEquals(ProtobufEncoderTest.class.getResourceAsStream("/data/" + result.getAttribute("testfile") + ".data"));
    }

}
 
开发者ID:whiver,项目名称:nifi-protobuf-processor,代码行数:33,代码来源:ProtobufEncoderTest.java

示例12: onTrigger

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void onTrigger() throws Exception {
    TestRunner runner = TestRunners.newTestRunner(new ProtobufDecoder());

    // AddressBook test
    HashMap<String, String> addressBookProperties = new HashMap<>();
    addressBookProperties.put("protobuf.schemaPath", ProtobufDecoderTest.class.getResource("/schemas/AddressBook.desc").getPath());
    addressBookProperties.put("protobuf.messageType", "AddressBook");

    // AddressBook test
    for (String filename: validTestFiles) {
        InputStream jsonFile = ProtobufDecoderTest.class.getResourceAsStream("/data/" + filename + ".data");
        addressBookProperties.put("testfile", filename);
        runner.enqueue(jsonFile, addressBookProperties);
    }

    // Ensure the configuration is valid as-is
    runner.assertValid();

    // Run the enqueued content, it also takes an int = number of contents queued
    runner.run(validTestFiles.length);
    runner.assertQueueEmpty();

    // Check if the data was processed without failure
    List<MockFlowFile> results = runner.getFlowFilesForRelationship(ProtobufDecoder.SUCCESS);
    Assert.assertEquals("All flowfiles should be returned to success", validTestFiles.length, results.size());

    // Check if the content of the flowfile is as expected
    ObjectMapper mapper = new ObjectMapper();

    for (MockFlowFile result: results) {
        JsonNode expected = mapper.readTree(this.getClass().getResourceAsStream("/data/" + result.getAttribute("testfile") + ".json"));
        JsonNode given = mapper.readTree(runner.getContentAsByteArray(result));
        Assert.assertEquals("The parsing result of " + result.getAttribute("testfile") + ".data is not as expected", expected, given);
    }
}
 
开发者ID:whiver,项目名称:nifi-protobuf-processor,代码行数:37,代码来源:ProtobufDecoderTest.java

示例13: validating_valid_inputs_1

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validating_valid_inputs_1() throws InitializationException {
    final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
    final StandardMongoClientService service = new StandardMongoClientService();

    Map<String, String> props = new HashMap<>();
    props.put(StandardMongoClientService.HOSTS.getName(), "localhost:27017");
    runner.addControllerService("test_hosts", service, props);
    runner.assertValid(service);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:11,代码来源:StandardMongoClientServiceIT.java

示例14: testValid

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testValid() {
    TestRunner runner = TestRunners.newTestRunner(DelayProcessor.class);
    runner.setValidateExpressionUsage(false);
    runner.setProperty(DelayProcessor.TIME_PERIOD, "10 sec");

    runner.assertValid();
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:9,代码来源:DelayProcessorTest.java

示例15: createSimpleIndexTest

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void createSimpleIndexTest() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new StoreInMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "index_test");
    runner.setProperty(MongoProps.INDEX, "[{\"a\": 1}]");

    runner.assertValid();
    runner.run();
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:12,代码来源:StoreInMongoIT.java


注:本文中的org.apache.nifi.util.TestRunner.assertValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。