Search in sources :

Example 71 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi by apache.

the class TestProcessorLifecycle method buildFlowControllerForTest.

private FlowControllerAndSystemBundle 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(propsFile, addProps);
    final Bundle systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties, mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(), new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()), mock(FlowRegistryClient.class));
    return new FlowControllerAndSystemBundle(flowController, systemBundle);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) HashMap(java.util.HashMap) Bundle(org.apache.nifi.bundle.Bundle) SystemBundle(org.apache.nifi.nar.SystemBundle) FlowRegistryClient(org.apache.nifi.registry.flow.FlowRegistryClient) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) FlowController(org.apache.nifi.controller.FlowController) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry)

Example 72 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi by apache.

the class StandardFlowSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    final FlowFileEventRepository flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    final AuditService 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 NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    final StringEncryptor encryptor = StringEncryptor.createEncryptor(nifiProperties);
    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final AbstractPolicyBasedAuthorizer authorizer = new MockPolicyBasedAuthorizer();
    final VariableRegistry variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
    final BulletinRepository bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer, auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class));
    serializer = new StandardFlowSerializer(encryptor);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) HashMap(java.util.HashMap) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) VariableRegistry(org.apache.nifi.registry.VariableRegistry) AbstractPolicyBasedAuthorizer(org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) StringEncryptor(org.apache.nifi.encrypt.StringEncryptor) MockPolicyBasedAuthorizer(org.apache.nifi.authorization.MockPolicyBasedAuthorizer) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 73 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi by apache.

the class TestFlowConfigurationArchiveManager method testNiFiPropertiesDefault.

@Test
public void testNiFiPropertiesDefault() throws Exception {
    final NiFiProperties defaultProperties = mock(NiFiProperties.class);
    when(defaultProperties.getFlowConfigurationArchiveMaxCount()).thenReturn(null);
    when(defaultProperties.getFlowConfigurationArchiveMaxTime()).thenReturn(null);
    when(defaultProperties.getFlowConfigurationArchiveMaxStorage()).thenReturn(null);
    final FlowConfigurationArchiveManager archiveManager = new FlowConfigurationArchiveManager(flowFile.toPath(), defaultProperties);
    assertNull(getPrivateFieldValue(archiveManager, "maxCount"));
    assertEquals(60L * 60L * 24L * 30L * 1000L, getPrivateFieldValue(archiveManager, "maxTimeMillis"));
    assertEquals(500L * 1024L * 1024L, getPrivateFieldValue(archiveManager, "maxStorageBytes"));
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) Test(org.junit.Test)

Example 74 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi by apache.

the class TestFlowConfigurationArchiveManager method testNiFiPropertiesCount.

@Test
public void testNiFiPropertiesCount() throws Exception {
    final NiFiProperties onlyCount = mock(NiFiProperties.class);
    when(onlyCount.getFlowConfigurationArchiveMaxCount()).thenReturn(10);
    when(onlyCount.getFlowConfigurationArchiveMaxTime()).thenReturn(null);
    when(onlyCount.getFlowConfigurationArchiveMaxStorage()).thenReturn(null);
    final FlowConfigurationArchiveManager archiveManager = new FlowConfigurationArchiveManager(flowFile.toPath(), onlyCount);
    assertEquals(10, getPrivateFieldValue(archiveManager, "maxCount"));
    assertNull(getPrivateFieldValue(archiveManager, "maxTimeMillis"));
    assertNull(getPrivateFieldValue(archiveManager, "maxStorageBytes"));
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) Test(org.junit.Test)

Example 75 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi by apache.

the class TestFlowConfigurationArchiveManager method testNiFiPropertiesMaxTime.

@Test
public void testNiFiPropertiesMaxTime() throws Exception {
    final NiFiProperties withMaxTime = mock(NiFiProperties.class);
    when(withMaxTime.getFlowConfigurationArchiveMaxCount()).thenReturn(null);
    when(withMaxTime.getFlowConfigurationArchiveMaxTime()).thenReturn("10 days");
    when(withMaxTime.getFlowConfigurationArchiveMaxStorage()).thenReturn(null);
    final FlowConfigurationArchiveManager archiveManager = new FlowConfigurationArchiveManager(flowFile.toPath(), withMaxTime);
    assertNull(getPrivateFieldValue(archiveManager, "maxCount"));
    assertEquals(60L * 60L * 24L * 10L * 1000L, getPrivateFieldValue(archiveManager, "maxTimeMillis"));
    assertNull(getPrivateFieldValue(archiveManager, "maxStorageBytes"));
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) Test(org.junit.Test)

Aggregations

NiFiProperties (org.apache.nifi.util.NiFiProperties)98 Test (org.junit.Test)63 HashMap (java.util.HashMap)28 Properties (java.util.Properties)24 File (java.io.File)16 Bundle (org.apache.nifi.bundle.Bundle)13 Matchers.anyString (org.mockito.Matchers.anyString)13 IOException (java.io.IOException)10 HashSet (java.util.HashSet)10 Map (java.util.Map)8 X509Certificate (java.security.cert.X509Certificate)7 Mockito.anyString (org.mockito.Mockito.anyString)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)6 SystemBundle (org.apache.nifi.nar.SystemBundle)6 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IdentityMapping (org.apache.nifi.authorization.util.IdentityMapping)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileInputStream (java.io.FileInputStream)4