Search in sources :

Example 11 with TestConfigurationStorage

use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage in project ignite-3 by apache.

the class ConfigurationRegistryTest method testComplicatedPolymorphicConfig.

@Test
void testComplicatedPolymorphicConfig() throws Exception {
    ConfigurationRegistry registry = new ConfigurationRegistry(List.of(SixthRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(Fourth0PolymorphicConfigurationSchema.class));
    registry.start();
    try {
        registry.getConfiguration(SixthRootConfiguration.KEY).change(c -> c.changePoly(toFirst0Polymorphic(0)).changePolyNamed(c0 -> c0.create("1", toFirst0Polymorphic(1))).changeEntity(c0 -> c0.changePoly(toFirst0Polymorphic(2)).changePolyNamed(c1 -> c1.create("3", toFirst0Polymorphic(3)))).changeEntityNamed(c0 -> c0.create("4", c1 -> c1.changePoly(toFirst0Polymorphic(4)).changePolyNamed(c2 -> c2.create("5", toFirst0Polymorphic(5)))))).get(1, SECONDS);
    } finally {
        registry.stop();
    }
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) PolymorphicId(org.apache.ignite.configuration.annotation.PolymorphicId) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) Consumer(java.util.function.Consumer) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) Test(org.junit.jupiter.api.Test) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) List(java.util.List) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) PolymorphicConfigInstance(org.apache.ignite.configuration.annotation.PolymorphicConfigInstance) Map(java.util.Map) Config(org.apache.ignite.configuration.annotation.Config) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) PolymorphicConfig(org.apache.ignite.configuration.annotation.PolymorphicConfig) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Value(org.apache.ignite.configuration.annotation.Value) InternalConfiguration(org.apache.ignite.configuration.annotation.InternalConfiguration) Test(org.junit.jupiter.api.Test)

Example 12 with TestConfigurationStorage

use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage in project ignite-3 by apache.

the class ConfigurationRegistryTest method testValidationPolymorphicConfigurationExtensions.

@Test
void testValidationPolymorphicConfigurationExtensions() {
    // There is a polymorphic extension that is missing from the schema.
    assertThrows(IllegalArgumentException.class, () -> new ConfigurationRegistry(List.of(ThirdRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(Second0PolymorphicConfigurationSchema.class)));
    // There are two polymorphic extensions with the same id.
    assertThrows(IllegalArgumentException.class, () -> new ConfigurationRegistry(List.of(ThirdRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(First0PolymorphicConfigurationSchema.class, ErrorFirst0PolymorphicConfigurationSchema.class)));
    // Check that everything is fine.
    ConfigurationRegistry configRegistry = new ConfigurationRegistry(List.of(ThirdRootConfiguration.KEY, FourthRootConfiguration.KEY, FifthRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(First0PolymorphicConfigurationSchema.class, First1PolymorphicConfigurationSchema.class, Second0PolymorphicConfigurationSchema.class, Third0PolymorphicConfigurationSchema.class, Third1PolymorphicConfigurationSchema.class));
    configRegistry.stop();
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Test(org.junit.jupiter.api.Test)

Example 13 with TestConfigurationStorage

use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage in project ignite-3 by apache.

the class NamedListNodeTest method before.

/**
 * Before each.
 */
@BeforeEach
public void before() {
    storage = new TestConfigurationStorage(LOCAL);
    changer = new TestConfigurationChanger(cgen, List.of(FirstConfiguration.KEY), Map.of(), storage, List.of(), List.of());
    changer.start();
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) TestConfigurationChanger(org.apache.ignite.internal.configuration.TestConfigurationChanger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with TestConfigurationStorage

use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage in project ignite-3 by apache.

the class ConfigurationUtilTest method testCheckConfigurationTypeNoError.

@Test
void testCheckConfigurationTypeNoError() {
    checkConfigurationType(List.of(LocalFirstConfiguration.KEY, LocalSecondConfiguration.KEY), new TestConfigurationStorage(LOCAL));
    checkConfigurationType(List.of(DistributedFirstConfiguration.KEY, DistributedSecondConfiguration.KEY), new TestConfigurationStorage(DISTRIBUTED));
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Test(org.junit.jupiter.api.Test)

Example 15 with TestConfigurationStorage

use of org.apache.ignite.internal.configuration.storage.TestConfigurationStorage in project ignite-3 by apache.

the class HoconConverterTest method beforeAll.

/**
 * Before all.
 */
@BeforeAll
public static void beforeAll() {
    registry = new ConfigurationRegistry(List.of(HoconRootConfiguration.KEY, HoconInjectedNameRootConfiguration.KEY), Map.of(), new TestConfigurationStorage(LOCAL), List.of(), List.of(HoconFirstPolymorphicInstanceConfigurationSchema.class, HoconSecondPolymorphicInstanceConfigurationSchema.class));
    registry.start();
    configuration = registry.getConfiguration(HoconRootConfiguration.KEY);
    injectedNameRootConfig = registry.getConfiguration(HoconInjectedNameRootConfiguration.KEY);
}
Also used : TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

TestConfigurationStorage (org.apache.ignite.internal.configuration.storage.TestConfigurationStorage)15 Test (org.junit.jupiter.api.Test)9 List (java.util.List)7 Map (java.util.Map)7 ConfigurationRegistry (org.apache.ignite.internal.configuration.ConfigurationRegistry)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 LOCAL (org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL)5 AfterEach (org.junit.jupiter.api.AfterEach)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)5 SECONDS (java.util.concurrent.TimeUnit.SECONDS)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 ConfigValue (org.apache.ignite.configuration.annotation.ConfigValue)3 Value (org.apache.ignite.configuration.annotation.Value)3 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)3 Collections (java.util.Collections)2 Config (org.apache.ignite.configuration.annotation.Config)2 ConfigurationRoot (org.apache.ignite.configuration.annotation.ConfigurationRoot)2 NamedConfigValue (org.apache.ignite.configuration.annotation.NamedConfigValue)2 PolymorphicConfig (org.apache.ignite.configuration.annotation.PolymorphicConfig)2 PolymorphicConfigInstance (org.apache.ignite.configuration.annotation.PolymorphicConfigInstance)2