Java Code Examples for org.apache.nifi.util.NiFiProperties#createBasicNiFiProperties()

The following examples show how to use org.apache.nifi.util.NiFiProperties#createBasicNiFiProperties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestProcessorLifecycle.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private FlowController buildFlowControllerForTest(final String propKey, final String propValue) throws Exception {
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "1 sec");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_CONFIG_FILE, "target/test-classes/state-management.xml");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_LOCAL_PROVIDER_ID, "local-provider");
    addProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    addProps.put("nifi.remote.input.socket.port", "");
    addProps.put("nifi.remote.input.secure", "");
    if (propKey != null && propValue != null) {
        addProps.put(propKey, propValue);
    }
    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(null, addProps);
    return FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties,
            mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(),
            new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()));
}
 
Example 2
Source File: Cluster.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public Node createNode() {
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.ZOOKEEPER_CONNECT_STRING, getZooKeeperConnectString());
    addProps.put(NiFiProperties.CLUSTER_IS_NODE, "true");

    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties("src/test/resources/conf/nifi.properties", addProps);

    final FingerprintFactory fingerprintFactory = new FingerprintFactory(StringEncryptor.createEncryptor(nifiProperties));
    final FlowElection flowElection = new PopularVoteFlowElection(flowElectionTimeoutMillis, TimeUnit.MILLISECONDS, flowElectionMaxNodes, fingerprintFactory);

    final Node node = new Node(nifiProperties, flowElection);
    node.start();
    nodes.add(node);

    return node;
}
 
Example 3
Source File: TestDataTransferResource.java    From nifi with Apache License 2.0 6 votes vote down vote up
private DataTransferResource getDataTransferResource() {
    final NiFiServiceFacade serviceFacade = mock(NiFiServiceFacade.class);

    final HttpFlowFileServerProtocol serverProtocol = mock(HttpFlowFileServerProtocol.class);
    final DataTransferResource resource = new DataTransferResource(NiFiProperties.createBasicNiFiProperties(null)) {
        @Override
        protected void authorizeDataTransfer(AuthorizableLookup lookup, ResourceType resourceType, String identifier) {
        }

        @Override
        HttpFlowFileServerProtocol getHttpFlowFileServerProtocol(VersionNegotiator versionNegotiator) {
            return serverProtocol;
        }
    };
    resource.setProperties(NiFiProperties.createBasicNiFiProperties(null));
    resource.setServiceFacade(serviceFacade);
    return resource;
}
 
Example 4
Source File: TestCuratorACLProviderFactory.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testSaslAuthSchemeNoHostWithRealm(){

    final NiFiProperties nifiProperties;
    final CuratorACLProviderFactory factory;
    otherProps.put("nifi.zookeeper.kerberos.removeHostFromPrincipal", "true");
    otherProps.put("nifi.zookeeper.kerberos.removeRealmFromPrincipal", "false");
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    factory = new CuratorACLProviderFactory();
    ZooKeeperClientConfig config = ZooKeeperClientConfig.createConfig(nifiProperties);
    ACLProvider provider = factory.create(config);
    assertFalse(provider instanceof DefaultACLProvider);
    List<ACL> acls = provider.getDefaultAcl();
    assertNotNull(acls);
    assertEquals(acls.get(0).getId().toString().trim(),"'sasl,'[email protected]");

}
 
Example 5
Source File: TestRocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoNotRemoveOrphans() throws Exception {
    final TestQueue testQueue = new TestQueue();

    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {

        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(testQueue.provider);

        repo.updateRepository(testQueue.getRepositoryRecord(new StandardFlowFileRecord.Builder()
                .id(1L)
                .addAttribute("abc", "xyz")
                .size(0L)
                .build()
        ));
    }

    // restore (& confirm present)
    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {
        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(testQueue.provider);
        assertEquals(1, repo.getInMemoryFlowFiles());
    }

    // restore with empty queue provider (should throw exception)
    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {
        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(new TestQueueProvider());
        fail();
    } catch (IOException expected) {
        assertTrue(expected.getMessage().contains("Found FlowFile in repository without a corresponding queue"));
    }
}
 
Example 6
Source File: TestVolatileContentRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleReadWrite() throws IOException {
    System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestVolatileContentRepository.class.getResource("/conf/nifi.properties").getFile());
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(VolatileContentRepository.MAX_SIZE_PROPERTY, "11 MB");
    final NiFiProperties nifiProps = NiFiProperties.createBasicNiFiProperties(null, addProps);
    final VolatileContentRepository contentRepo = new VolatileContentRepository(nifiProps);
    contentRepo.initialize(claimManager);
    final ContentClaim claim = contentRepo.create(true);

    final OutputStream out = contentRepo.write(claim);
    final int byteCount = 2398473 * 4;
    final byte[] x = new byte[4];
    x[0] = 48;
    x[1] = 29;
    x[2] = 49;
    x[3] = 51;

    for (int i = 0; i < byteCount / 4; i++) {
        out.write(x);
    }

    out.close();

    final InputStream in = contentRepo.read(claim);
    for (int i = 0; i < byteCount; i++) {
        final int val = in.read();
        final int index = i % 4;
        final byte expectedVal = x[index];
        assertEquals(expectedVal, val);
    }

    assertEquals(-1, in.read());
}
 
Example 7
Source File: TestRocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testSwapLocationsUpdatedOnRepoUpdate() throws IOException {
    final Path path = Paths.get("target/test-swap-repo");
    if (Files.exists(path)) {
        FileUtils.deleteFile(path.toFile(), true);
    }

    final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties));
    repo.initialize(new StandardResourceClaimManager());

    final TestRocksDBFlowFileRepository.TestQueueProvider queueProvider = new TestRocksDBFlowFileRepository.TestQueueProvider();
    repo.loadFlowFiles(queueProvider);

    final Connection connection = Mockito.mock(Connection.class);
    when(connection.getIdentifier()).thenReturn("1234");

    final FlowFileQueue queue = Mockito.mock(FlowFileQueue.class);
    when(queue.getIdentifier()).thenReturn("1234");
    when(connection.getFlowFileQueue()).thenReturn(queue);

    queueProvider.addConnection(connection);

    StandardFlowFileRecord.Builder ffBuilder = new StandardFlowFileRecord.Builder();
    ffBuilder.id(1L);
    ffBuilder.size(0L);
    final FlowFileRecord flowFileRecord = ffBuilder.build();

    final List<RepositoryRecord> records = new ArrayList<>();
    final StandardRepositoryRecord record = new StandardRepositoryRecord(queue, flowFileRecord, "/tmp/swap123");
    record.setDestination(queue);
    records.add(record);

    assertFalse(repo.isValidSwapLocationSuffix("swap123"));
    repo.updateRepository(records);
    assertTrue(repo.isValidSwapLocationSuffix("swap123"));
    repo.close();
}
 
Example 8
Source File: TestRocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testUnknownVersion() throws Exception {
    final NiFiProperties niFiProperties = NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties);

    // create db with known version
    try (RocksDBMetronome db = new RocksDBMetronome.Builder().setStoragePath(RocksDBFlowFileRepository.getFlowFileRepoPath(niFiProperties)).build()) {
        db.initialize();
        db.putConfiguration(RocksDBFlowFileRepository.REPOSITORY_VERSION_KEY, "UNKNOWN".getBytes(StandardCharsets.UTF_8));
    }
    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {
        repo.initialize(new StandardResourceClaimManager());
    }
}
 
Example 9
Source File: JettyServerTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigureSslContextFactoryWithKeyPassword() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
    // Expect that with no KeyStore password, we will only need to set Key Manager Password
    String testKeyPassword = "testKeyPassword";

    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.SECURITY_KEY_PASSWD, testKeyPassword);
    NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(null, addProps);
    SslContextFactory contextFactory = mock(SslContextFactory.class);

    JettyServer.configureSslContextFactory(contextFactory, nifiProperties);

    verify(contextFactory).setKeyManagerPassword(testKeyPassword);
    verify(contextFactory, never()).setKeyStorePassword(anyString());
}
 
Example 10
Source File: TestRocksDBFlowFileRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testRemoveOrphans() throws Exception {
    final TestQueue testQueue = new TestQueue();

    additionalProperties.put(RocksDBFlowFileRepository.RocksDbProperty.REMOVE_ORPHANED_FLOWFILES.propertyName, "true");

    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {

        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(testQueue.provider);

        repo.updateRepository(testQueue.getRepositoryRecord(new StandardFlowFileRecord.Builder()
                .id(1L)
                .addAttribute("abc", "xyz")
                .size(0L)
                .build()
        ));
    }

    // restore (& confirm present)
    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {
        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(testQueue.provider);
        assertEquals(1, repo.getInMemoryFlowFiles());
    }
    // restore with empty queue provider (should throw exception)
    try (final RocksDBFlowFileRepository repo = new RocksDBFlowFileRepository(NiFiProperties.createBasicNiFiProperties(nifiPropertiesPath, additionalProperties))) {
        repo.initialize(new StandardResourceClaimManager());
        repo.loadFlowFiles(new TestQueueProvider());
        assertEquals(0, repo.getInMemoryFlowFiles());
    }
}
 
Example 11
Source File: TestFileSystemRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimalArchiveCleanupIntervalHonoredAndLogged() throws Exception {
    // We are going to construct our own repository using different properties, so
    // we need to shutdown the existing one.
    shutdown();

    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    ListAppender<ILoggingEvent> testAppender = new ListAppender<>();
    testAppender.setName("Test");
    testAppender.start();
    root.addAppender(testAppender);
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY, "1 millis");
    final NiFiProperties localProps = NiFiProperties.createBasicNiFiProperties(TestFileSystemRepository.class.getResource("/conf/nifi.properties").getFile(), addProps);
    repository = new FileSystemRepository(localProps);
    repository.initialize(new StandardResourceClaimManager());
    repository.purge();

    boolean messageFound = false;
    String message = "The value of nifi.content.repository.archive.cleanup.frequency property "
            + "is set to '1 millis' which is below the allowed minimum of 1 second (1000 milliseconds). "
            + "Minimum value of 1 sec will be used as scheduling interval for archive cleanup task.";

    // Must synchronize on testAppender, because the call to append() is synchronized and this synchronize
    // keyword guards testAppender.list. Since we are accessing testAppender.list, we must do so in a thread-safe manner.
    synchronized (testAppender) {
        for (ILoggingEvent event : testAppender.list) {
            String actualMessage = event.getFormattedMessage();
            if (actualMessage.equals(message)) {
                assertEquals(event.getLevel(), Level.WARN);
                messageFound = true;
                break;
            }
        }
    }

    assertTrue(messageFound);
}
 
Example 12
Source File: TestStandardControllerServiceProvider.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * This test is similar to the above, but different combination of service
 * dependencies
 *
 */
@Test
public void validateEnableServices2() {
    StandardProcessScheduler scheduler = createScheduler();
    FlowController controller = Mockito.mock(FlowController.class);
    StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null,
            stateManagerProvider, variableRegistry, NiFiProperties.createBasicNiFiProperties(null, null));
    ProcessGroup procGroup = new MockProcessGroup();
    Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup);

    ControllerServiceNode A = provider.createControllerService(ServiceC.class.getName(), "A", false);
    ControllerServiceNode B = provider.createControllerService(ServiceA.class.getName(), "B", false);
    ControllerServiceNode C = provider.createControllerService(ServiceB.class.getName(), "C", false);
    ControllerServiceNode D = provider.createControllerService(ServiceA.class.getName(), "D", false);
    ControllerServiceNode F = provider.createControllerService(ServiceA.class.getName(), "F", false);

    procGroup.addControllerService(A);
    procGroup.addControllerService(B);
    procGroup.addControllerService(C);
    procGroup.addControllerService(D);
    procGroup.addControllerService(F);

    setProperty(A, ServiceC.REQ_SERVICE_1.getName(), "B");
    setProperty(A, ServiceC.REQ_SERVICE_2.getName(), "D");
    setProperty(B, ServiceA.OTHER_SERVICE.getName(), "C");

    setProperty(F, ServiceA.OTHER_SERVICE.getName(), "D");
    setProperty(D, ServiceA.OTHER_SERVICE.getName(), "C");

    provider.enableControllerServices(Arrays.asList(C, F, A, B, D));

    assertTrue(A.isActive());
    assertTrue(B.isActive());
    assertTrue(C.isActive());
    assertTrue(D.isActive());
    assertTrue(F.isActive());
}
 
Example 13
Source File: TestFileSystemRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException {
    nifiProperties = NiFiProperties.createBasicNiFiProperties(TestFileSystemRepository.class.getResource("/conf/nifi.properties").getFile());
    if (rootFile.exists()) {
        DiskUtils.deleteRecursively(rootFile);
    }
    repository = new FileSystemRepository(nifiProperties);
    claimManager = new StandardResourceClaimManager();
    repository.initialize(claimManager);
    repository.purge();
}
 
Example 14
Source File: JettyServerTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigureSslContextFactoryWithJksKeyStore() {
    // Expect that we will not set provider for jks keystore
    final Map<String, String> addProps = new HashMap<>();
    String keyStoreType = KeystoreType.JKS.toString();
    addProps.put(NiFiProperties.SECURITY_KEYSTORE_TYPE, keyStoreType);
    NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(null, addProps);
    SslContextFactory contextFactory = mock(SslContextFactory.class);

    JettyServer.configureSslContextFactory(contextFactory, nifiProperties);

    verify(contextFactory).setKeyStoreType(keyStoreType);
    verify(contextFactory).setKeyStoreProvider(SUN_PROVIDER_NAME);
}
 
Example 15
Source File: TestStatusAnalyticsModelMapFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    final Map<String, String> otherProps = new HashMap<>();
    final String propsFile = "src/test/resources/conf/nifi.properties";
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);

    // use the system bundle
    Bundle systemBundle = SystemBundle.create(nifiProperties);
    extensionManager = new StandardExtensionDiscoveringManager();
    ((StandardExtensionDiscoveringManager) extensionManager).discoverExtensions(systemBundle, Collections.emptySet());
}
 
Example 16
Source File: NarThreadContextClassLoaderTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void validateWithWrongConstructor() throws Exception {
    NiFiProperties properties = NiFiProperties.createBasicNiFiProperties("src/test/resources/nifi.properties", null);
    NarThreadContextClassLoader.createInstance(WrongConstructor.class.getName(), WrongConstructor.class, properties);
}
 
Example 17
Source File: TestFlowController.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {

    flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    auditService = Mockito.mock(AuditService.class);
    final Map<String, String> otherProps = new HashMap<>();
    otherProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    otherProps.put("nifi.remote.input.socket.port", "");
    otherProps.put("nifi.remote.input.secure", "");
    final String propsFile = "src/test/resources/flowcontrollertest.nifi.properties";
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    encryptor = createEncryptorFromProperties(nifiProperties);

    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    extensionManager = new StandardExtensionDiscoveringManager();
    extensionManager.discoverExtensions(systemBundle, Collections.emptySet());

    User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
    User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();

    Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
    Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();

    AccessPolicy policy1 = new AccessPolicy.Builder()
            .identifier("policy-id-1")
            .resource("resource1")
            .action(RequestAction.READ)
            .addUser(user1.getIdentifier())
            .addUser(user2.getIdentifier())
            .build();

    AccessPolicy policy2 = new AccessPolicy.Builder()
            .identifier("policy-id-2")
            .resource("resource2")
            .action(RequestAction.READ)
            .addGroup(group1.getIdentifier())
            .addGroup(group2.getIdentifier())
            .addUser(user1.getIdentifier())
            .addUser(user2.getIdentifier())
            .build();

    Set<Group> groups1 = new LinkedHashSet<>();
    groups1.add(group1);
    groups1.add(group2);

    Set<User> users1 = new LinkedHashSet<>();
    users1.add(user1);
    users1.add(user2);

    Set<AccessPolicy> policies1 = new LinkedHashSet<>();
    policies1.add(policy1);
    policies1.add(policy2);

    authorizer = new MockPolicyBasedAuthorizer(groups1, users1, policies1);
    variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());

    bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer,
        auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class), extensionManager);
}
 
Example 18
Source File: AccessControlHelper.java    From nifi with Apache License 2.0 4 votes vote down vote up
public AccessControlHelper(final String nifiPropertiesPath) throws Exception {
    // configure the location of the nifi properties
    File nifiPropertiesFile = new File(nifiPropertiesPath);
    System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, nifiPropertiesFile.getAbsolutePath());
    NiFiProperties props = NiFiProperties.createBasicNiFiProperties(null);
    flowXmlPath = props.getProperty(NiFiProperties.FLOW_CONFIGURATION_FILE);

    final File libTargetDir = new File("target/test-classes/access-control/lib");
    libTargetDir.mkdirs();

    final File libSourceDir = new File("src/test/resources/lib");
    for (final File libFile : libSourceDir.listFiles()) {
        final File libDestFile = new File(libTargetDir, libFile.getName());
        Files.copy(libFile.toPath(), libDestFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    }

    final Bundle systemBundle = SystemBundle.create(props);
    NarUnpacker.unpackNars(props, systemBundle);
    NarClassLoadersHolder.getInstance().init(props.getFrameworkWorkingDirectory(), props.getExtensionsWorkingDirectory());

    // load extensions
    final ExtensionDiscoveringManager extensionManager = new StandardExtensionDiscoveringManager();
    extensionManager.discoverExtensions(systemBundle, NarClassLoadersHolder.getInstance().getBundles());
    ExtensionManagerHolder.init(extensionManager);

    // start the server
    server = new NiFiTestServer("src/main/webapp", CONTEXT_PATH, props);
    server.startServer();
    server.loadFlow();

    // get the base url
    baseUrl = server.getBaseUrl() + CONTEXT_PATH;

    // create the users - user purposefully decoupled from clientId (same user different browsers tabs)
    readUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.READ_USER_DN);
    writeUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.WRITE_USER_DN);
    readWriteUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.READ_WRITE_USER_DN);
    noneUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.NONE_USER_DN);
    privilegedUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.PRIVILEGED_USER_DN);
    executeCodeUser = new NiFiTestUser(server.getClient(), NiFiTestAuthorizer.EXECUTED_CODE_USER_DN);
    anonymousUser = new NiFiTestUser(server.getClient(), StringUtils.EMPTY);

    // populate the initial data flow
    NiFiWebApiTest.populateFlow(server.getClient(), baseUrl, readWriteUser, READ_WRITE_CLIENT_ID);
}
 
Example 19
Source File: TestStandardControllerServiceProvider.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private StandardProcessScheduler createScheduler() {
    return new StandardProcessScheduler(null, null, stateManagerProvider, variableRegistry, NiFiProperties.createBasicNiFiProperties(null, null));
}
 
Example 20
Source File: TestVolatileProvenanceRepository.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testIndexAndCompressOnRolloverAndSubsequentSearchAsync() throws InterruptedException {
    repo = new VolatileProvenanceRepository(NiFiProperties.createBasicNiFiProperties(null, null));

    final String uuid = "00000000-0000-0000-0000-000000000000";
    final Map<String, String> attributes = new HashMap<>();
    attributes.put("abc", "xyz");
    attributes.put("xyz", "abc");
    attributes.put("filename", "file-" + uuid);

    final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder();
    builder.setEventTime(System.currentTimeMillis());
    builder.setEventType(ProvenanceEventType.RECEIVE);
    builder.setTransitUri("nifi://unit-test");
    builder.fromFlowFile(createFlowFile(3L, 3000L, attributes));
    builder.setComponentId("1234");
    builder.setComponentType("dummy processor");

    for (int i = 0; i < 10; i++) {
        attributes.put("uuid", "00000000-0000-0000-0000-00000000000" + i);
        builder.fromFlowFile(createFlowFile(i, 3000L, attributes));
        repo.registerEvent(builder.build());
    }

    final Query query = new Query(UUID.randomUUID().toString());
    query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.FlowFileUUID, "00000*"));
    query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.Filename, "file-*"));
    query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.ComponentID, "12?4"));
    query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.TransitURI, "nifi://*"));
    query.setMaxResults(100);

    final QuerySubmission submission = repo.submitQuery(query, createUser());
    while (!submission.getResult().isFinished()) {
        Thread.sleep(100L);
    }

    assertEquals(10, submission.getResult().getMatchingEvents().size());
    for (final ProvenanceEventRecord match : submission.getResult().getMatchingEvents()) {
        System.out.println(match);
    }
}