Search in sources :

Example 6 with ConfigSchema

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());
}
Also used : ConfigSchema(org.apache.nifi.minifi.commons.schema.ConfigSchema) Test(org.junit.Test) ConfigSchemaTest(org.apache.nifi.minifi.commons.schema.ConfigSchemaTest)

Example 7 with ConfigSchema

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);
}
Also used : ConfigSchema(org.apache.nifi.minifi.commons.schema.ConfigSchema) Test(org.junit.Test) ConfigSchemaTest(org.apache.nifi.minifi.commons.schema.ConfigSchemaTest)

Example 8 with ConfigSchema

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);
}
Also used : ByteBufferInputStream(org.apache.nifi.minifi.bootstrap.util.ByteBufferInputStream) Properties(java.util.Properties) ByteBuffer(java.nio.ByteBuffer) ConfigSchema(org.apache.nifi.minifi.commons.schema.ConfigSchema) Test(org.junit.Test)

Example 9 with ConfigSchema

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));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) ConfigSchema(org.apache.nifi.minifi.commons.schema.ConfigSchema) Test(org.junit.Test)

Example 10 with ConfigSchema

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));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) ConfigSchema(org.apache.nifi.minifi.commons.schema.ConfigSchema) Test(org.junit.Test)

Aggregations

ConfigSchema (org.apache.nifi.minifi.commons.schema.ConfigSchema)31 Test (org.junit.Test)20 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 IOException (java.io.IOException)5 FileInputStream (java.io.FileInputStream)4 List (java.util.List)4 JAXBException (javax.xml.bind.JAXBException)4 FileNotFoundException (java.io.FileNotFoundException)3 OutputStream (java.io.OutputStream)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 ConfigSchemaTest (org.apache.nifi.minifi.commons.schema.ConfigSchemaTest)3 ConnectionSchema (org.apache.nifi.minifi.commons.schema.ConnectionSchema)3 HttpURLConnection (java.net.HttpURLConnection)2 ByteBuffer (java.nio.ByteBuffer)2 HashSet (java.util.HashSet)2