use of org.apache.nifi.minifi.commons.schema.ConfigSchema in project nifi-minifi by apache.
the class ConfigSchemaV1Test method testValidationIssuesFromNewer.
@Test
public void testValidationIssuesFromNewer() throws IOException, SchemaLoaderException {
Map<String, Object> yamlAsMap = SchemaLoader.loadYamlAsMap(ConfigSchemaTest.class.getClassLoader().getResourceAsStream("config-minimal-v2.yml"));
ConfigSchema configSchema = new ConfigSchemaV1(yamlAsMap).convert();
List<String> validationIssues = configSchema.getValidationIssues();
assertNotEquals(0, validationIssues.size());
}
use of org.apache.nifi.minifi.commons.schema.ConfigSchema in project nifi-minifi by apache.
the class ConfigSchemaV1Test method testValid.
@Test
public void testValid() throws IOException, SchemaLoaderException {
Map<String, Object> yamlAsMap = SchemaLoader.loadYamlAsMap(ConfigSchemaTest.class.getClassLoader().getResourceAsStream("config-minimal.yml"));
ConfigSchema configSchema = new ConfigSchemaV1(yamlAsMap).convert();
List<String> validationIssues = configSchema.getValidationIssues();
assertEquals(new ArrayList<>(), validationIssues);
}
use of org.apache.nifi.minifi.commons.schema.ConfigSchema in project nifi-minifi by apache.
the class PullHttpChangeIngestorCommonTest method testSecurityOverride.
@Test
public void testSecurityOverride() throws IOException, SchemaLoaderException {
Properties properties = new Properties();
properties.put(PullHttpChangeIngestor.OVERRIDE_SECURITY, "false");
properties.put(RunMiNiFi.MINIFI_CONFIG_FILE_KEY, "src/test/resources/config.yml");
properties.put(PATH_KEY, "/config-minimal.yml");
pullHttpChangeIngestorInit(properties);
when(mockDifferentiator.isNew(Mockito.any(ByteBuffer.class))).thenReturn(true);
pullHttpChangeIngestor.run();
ArgumentCaptor<ByteBuffer> argument = ArgumentCaptor.forClass(ByteBuffer.class);
verify(testNotifier, Mockito.times(1)).notifyListeners(argument.capture());
ConvertableSchema<ConfigSchema> configSchema = SchemaLoader.loadConvertableSchemaFromYaml(new ByteBufferInputStream(argument.getValue()));
ConfigSchema newSchema = configSchema.convert();
assertNotNull(newSchema.getSecurityProperties().getKeystore());
assertEquals(newSchema.getProcessGroupSchema().getProcessors().size(), 2);
}
use of org.apache.nifi.minifi.commons.schema.ConfigSchema in project nifi-minifi by apache.
the class ConfigTransformerTest method testNifiPropertiesOverrides.
@Test
public void testNifiPropertiesOverrides() throws IOException, ConfigurationChangeException, SchemaLoaderException {
Properties pre216Properties = new Properties();
try (InputStream pre216PropertiesStream = ConfigTransformerTest.class.getClassLoader().getResourceAsStream("MINIFI-216/nifi.properties.before")) {
pre216Properties.load(pre216PropertiesStream);
}
pre216Properties.setProperty(ConfigTransformer.NIFI_VERSION_KEY, ConfigTransformer.NIFI_VERSION);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (InputStream configStream = ConfigTransformerTest.class.getClassLoader().getResourceAsStream("MINIFI-216/configOverrides.yml")) {
ConfigSchema configSchema = SchemaLoader.loadConfigSchemaFromYaml(configStream);
assertTrue(configSchema.getNifiPropertiesOverrides().size() > 0);
for (Map.Entry<String, String> entry : configSchema.getNifiPropertiesOverrides().entrySet()) {
pre216Properties.setProperty(entry.getKey(), entry.getValue());
}
ConfigTransformer.writeNiFiProperties(configSchema, outputStream);
}
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(outputStream.toByteArray()));
for (String name : pre216Properties.stringPropertyNames()) {
assertEquals("Property key " + name + " doesn't match.", pre216Properties.getProperty(name), properties.getProperty(name));
}
}
use of org.apache.nifi.minifi.commons.schema.ConfigSchema in project nifi-minifi by apache.
the class ConfigTransformerTest method testNifiPropertiesVariableRegistry.
@Test
public void testNifiPropertiesVariableRegistry() throws IOException, ConfigurationChangeException, SchemaLoaderException {
Properties initialProperties = new Properties();
try (InputStream pre216PropertiesStream = ConfigTransformerTest.class.getClassLoader().getResourceAsStream("MINIFI-277/nifi.properties")) {
initialProperties.load(pre216PropertiesStream);
}
initialProperties.setProperty(ConfigTransformer.NIFI_VERSION_KEY, ConfigTransformer.NIFI_VERSION);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (InputStream configStream = ConfigTransformerTest.class.getClassLoader().getResourceAsStream("MINIFI-277/config.yml")) {
ConfigSchema configSchema = SchemaLoader.loadConfigSchemaFromYaml(configStream);
ConfigTransformer.writeNiFiProperties(configSchema, outputStream);
}
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(outputStream.toByteArray()));
for (String name : initialProperties.stringPropertyNames()) {
assertEquals("Property key " + name + " doesn't match.", initialProperties.getProperty(name), properties.getProperty(name));
}
}
Aggregations