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


Java TestRunner.addControllerService方法代码示例

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


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

示例1: test_mongoservice_not_enabled

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

    runner.addControllerService("test-mongo-closed", service);
    runner.enableControllerService(service);

    // Close MongoClient
    MongoClient client = service.getMongoClient();

    // NOTE: This test requires mongo to be running
    assertEquals("localhost:27017", client.getConnectPoint());

    // Close the mongo connection
    client.close();

    // Now, this should throw an illegal state exception
    thrown.expect(IllegalStateException.class);
    client.getConnectPoint();
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:22,代码来源: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: validateFailedPublishAndTransferToFailure

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateFailedPublishAndTransferToFailure() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);

    PublishJMS pubProc = new PublishJMS();
    TestRunner runner = TestRunners.newTestRunner(pubProc);
    JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class);
    when(cs.getIdentifier()).thenReturn("cfProvider");
    when(cs.getConnectionFactory()).thenReturn(cf);

    runner.addControllerService("cfProvider", cs);
    runner.enableControllerService(cs);

    runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider");
    runner.setProperty(PublishJMS.DESTINATION, "fooQueue");

    runner.enqueue("Hello Joe".getBytes());

    runner.run();
    Thread.sleep(200);

    assertTrue(runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).isEmpty());
    assertNotNull(runner.getFlowFilesForRelationship(PublishJMS.REL_FAILURE).get(0));
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:25,代码来源:PublishJMSTest.java

示例4: validateSuccessfulPublishAndTransferToSuccessOverJNDI

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateSuccessfulPublishAndTransferToSuccessOverJNDI() throws Exception {
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) CommonTest.buildJmsJndiConnectionFactory();

    final String destinationName = "fooQueue";
    PublishJMS pubProc = new PublishJMS();
    TestRunner runner = TestRunners.newTestRunner(pubProc);
    JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class);
    when(cs.getIdentifier()).thenReturn("cfProvider");
    when(cs.getConnectionFactory()).thenReturn(cf);

    runner.addControllerService("cfProvider", cs);
    runner.enableControllerService(cs);

    runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider");
    runner.setProperty(PublishJMS.DESTINATION, destinationName);

    Map<String, String> attributes = new HashMap<>();
    attributes.put("foo", "foo");
    attributes.put(JmsHeaders.REPLY_TO, "cooQueue");
    runner.enqueue("Hey dude!".getBytes(), attributes);
    runner.run(1, false);

    final MockFlowFile successFF = runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).get(0);
    assertNotNull(successFF);

    JmsTemplate jmst = new JmsTemplate(cf);
    BytesMessage message = (BytesMessage) jmst.receive(destinationName);

    byte[] messageBytes = MessageBodyToBytesConverter.toBytes(message);
    assertEquals("Hey dude!", new String(messageBytes));
    assertEquals("cooQueue", ((Queue) message.getJMSReplyTo()).getQueueName());
    assertEquals("foo", message.getStringProperty("foo"));
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:35,代码来源:PublishJMSTest.java

示例5: 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

示例6: addMongoService

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
protected void addMongoService(TestRunner runner) throws InitializationException {
    HashMap<String, String> props = new HashMap<>();

    // Add mongo controller service
    runner.addControllerService(MONGO_CONTROLLER_SERVICE, mongo, props);
    runner.setProperty(MongoProps.MONGO_SERVICE, MONGO_CONTROLLER_SERVICE);
    runner.enableControllerService(mongo);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:9,代码来源:UpdateMongoIT.java

示例7: validateFailsIfURICfAndNotSolace

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

    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "test-lib");
    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "org.apache.nifi.jms.testcflib.TestConnectionFactory");
    runner.enableControllerService(cfProvider);
    runner.assertNotValid(cfProvider);
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:15,代码来源:JNDIConnectionFactoryProviderTest.java

示例8: validating_incomplete_auth_inputs_1

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validating_incomplete_auth_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");
    props.put(StandardMongoClientService.USERNAME.getName(), "mongouser");
    runner.addControllerService("test_hosts", service, props);
    runner.assertNotValid(service);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:12,代码来源:StandardMongoClientServiceIT.java

示例9: validateSuccessfulConsumeAndTransferToSuccess

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateSuccessfulConsumeAndTransferToSuccess() throws Exception {
    final String destinationName = "cooQueue";
    JmsTemplate jmsTemplate = CommonTest.buildJmsTemplateForDestination(false);
    JMSPublisher sender = new JMSPublisher(jmsTemplate, mock(ComponentLog.class));
    final Map<String, String> senderAttributes = new HashMap<>();
    senderAttributes.put("filename", "message.txt");
    senderAttributes.put("attribute_from_sender", "some value");
    sender.publish(destinationName, "Hey dude!".getBytes(), senderAttributes);
    TestRunner runner = TestRunners.newTestRunner(new ConsumeJMS());
    JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class);
    when(cs.getIdentifier()).thenReturn("cfProvider");
    when(cs.getConnectionFactory()).thenReturn(jmsTemplate.getConnectionFactory());
    runner.addControllerService("cfProvider", cs);
    runner.enableControllerService(cs);

    runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider");
    runner.setProperty(ConsumeJMS.DESTINATION, destinationName);
    runner.setProperty(ConsumeJMS.DESTINATION_TYPE, ConsumeJMS.QUEUE);
    runner.run(1, false);
    //
    final MockFlowFile successFF = runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).get(0);
    assertNotNull(successFF);
    successFF.assertAttributeExists(JmsHeaders.DESTINATION);
    successFF.assertAttributeEquals(JmsHeaders.DESTINATION, destinationName);
    successFF.assertAttributeExists("filename");
    successFF.assertAttributeEquals("filename", "message.txt");
    successFF.assertAttributeExists("attribute_from_sender");
    successFF.assertAttributeEquals("attribute_from_sender", "some value");
    successFF.assertContentEquals("Hey dude!".getBytes());
    String sourceDestination = successFF.getAttribute(ConsumeJMS.JMS_SOURCE_DESTINATION_NAME);
    assertNotNull(sourceDestination);

    ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:36,代码来源:ConsumeJMSTest.java

示例10: validateOnConfigureFailsIfCNFonConnectionFactory

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test(expected = AssertionError.class)
public void validateOnConfigureFailsIfCNFonConnectionFactory() 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, "test-lib");
    runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "foo.bar.NonExistingConnectionFactory");
    runner.enableControllerService(cfProvider);
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:13,代码来源:JMSConnectionFactoryProviderTest.java

示例11: validateNotValidForNonExistingLibPath

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validateNotValidForNonExistingLibPath() 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, "foo");
    runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "org.apache.nifi.jms.testcflib.TestConnectionFactory");
    runner.assertNotValid(cfProvider);
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:13,代码来源:JMSConnectionFactoryProviderTest.java

示例12: validating_incomplete_auth_inputs_3

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void validating_incomplete_auth_inputs_3() 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.AUTH_DATABASE.getName(), "mongouser");
    runner.addControllerService("test_hosts", service, props);
    runner.assertNotValid(service);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:12,代码来源:StandardMongoClientServiceIT.java

示例13: validateNotValidForNonExistingLibPath

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

    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "foo");
    runner.setProperty(cfProvider, JNDIConnectionFactoryProvider.CONNECTION_FACTORY_IMPL,
            "org.apache.nifi.jms.testcflib.TestConnectionFactory");
    runner.assertNotValid(cfProvider);
}
 
开发者ID:SolaceLabs,项目名称:solace-integration-guides,代码行数:14,代码来源:JNDIConnectionFactoryProviderTest.java

示例14: 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

示例15: 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:SolaceLabs,项目名称:solace-integration-guides,代码行数:42,代码来源:JNDIConnectionFactoryProviderTest.java


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