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);
}
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);
}
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"));
}
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"));
}
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"));
}
Aggregations