Search in sources :

Example 1 with AppConfig

use of io.vertigo.app.config.AppConfig in project vertigo by KleeGroup.

the class ComponentSpace3Test method testInjectPluginsAttribute.

@Test
public void testInjectPluginsAttribute() {
    final AppConfig appConfig = createHomeWithInjectPluginsAttribute(true);
    try (AutoCloseableApp app = new AutoCloseableApp(appConfig)) {
        final FunctionManager functionManager = app.getComponentSpace().resolve(FunctionManager.class);
        assertEquals(4, functionManager.compute("x+1", 3));
        assertEquals(6, functionManager.compute("2x", 3));
        assertEquals(15, functionManager.compute("4x+3", 3));
        assertEquals(1, functionManager.compute("0x+1", 3));
        assertEquals(-7, functionManager.compute("x-10", 3));
        assertEquals(-9, functionManager.computeAll(3));
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) AppConfig(io.vertigo.app.config.AppConfig) FunctionManager(io.vertigo.core.spaces.component.data.FunctionManager) Test(org.junit.jupiter.api.Test)

Example 2 with AppConfig

use of io.vertigo.app.config.AppConfig in project vertigo by KleeGroup.

the class ComponentSpace3Test method testInjectPluginsConstructor.

@Test
public void testInjectPluginsConstructor() {
    final AppConfig appConfig = createHomeWithInjectPluginsConstructor(true);
    try (AutoCloseableApp app = new AutoCloseableApp(appConfig)) {
        final FunctionManager functionManager = app.getComponentSpace().resolve(FunctionManager.class);
        assertEquals(4, functionManager.compute("x+1", 3));
        assertEquals(6, functionManager.compute("2x", 3));
        assertEquals(15, functionManager.compute("4x+3", 3));
        assertEquals(1, functionManager.compute("0x+1", 3));
        assertEquals(-7, functionManager.compute("x-10", 3));
        assertEquals(-9, functionManager.computeAll(3));
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) AppConfig(io.vertigo.app.config.AppConfig) FunctionManager(io.vertigo.core.spaces.component.data.FunctionManager) Test(org.junit.jupiter.api.Test)

Example 3 with AppConfig

use of io.vertigo.app.config.AppConfig in project vertigo by KleeGroup.

the class ComponentSpaceTest method testHome.

@Test
public void testHome() {
    final AppConfig appConfig = AppConfig.builder().beginBoot().withLogConfig(new LogConfig("/log4j.xml")).endBoot().addModule(ModuleConfig.builder("Bio").addComponent(BioManager.class, BioManagerImpl.class).addComponent(MathManager.class, MathManagerImpl.class, Param.of("start", "100")).addPlugin(MathPlugin.class, Param.of("factor", "20")).build()).build();
    try (AutoCloseableApp app = new AutoCloseableApp(appConfig)) {
        final BioManager bioManager = app.getComponentSpace().resolve(BioManager.class);
        final int res = bioManager.add(1, 2, 3);
        assertEquals(366, res);
        assertTrue(bioManager.isActive());
    }
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) AppConfig(io.vertigo.app.config.AppConfig) BioManager(io.vertigo.core.spaces.component.data.BioManager) MathPlugin(io.vertigo.core.spaces.component.data.MathPlugin) BioManagerImpl(io.vertigo.core.spaces.component.data.BioManagerImpl) LogConfig(io.vertigo.app.config.LogConfig) Test(org.junit.jupiter.api.Test)

Example 4 with AppConfig

use of io.vertigo.app.config.AppConfig in project vertigo by KleeGroup.

the class ComponentSpaceTest method testHome2.

@Test
public void testHome2() {
    final AppConfig appConfig = AppConfig.builder().beginBoot().withLogConfig(new LogConfig("/log4j.xml")).endBoot().addModule(ModuleConfig.builder("Bio").addComponent(BioManager.class, BioManagerImpl.class).addPlugin(DummyPlugin.class).addComponent(MathManager.class, MathManagerImpl.class, Param.of("start", "100")).addPlugin(MathPlugin.class, Param.of("factor", "20")).build()).build();
    Assertions.assertThrows(RuntimeException.class, () -> {
        try (AutoCloseableApp app = new AutoCloseableApp(appConfig)) {
        // 
        }
    });
}
Also used : AutoCloseableApp(io.vertigo.app.AutoCloseableApp) AppConfig(io.vertigo.app.config.AppConfig) DummyPlugin(io.vertigo.core.spaces.component.data.DummyPlugin) MathPlugin(io.vertigo.core.spaces.component.data.MathPlugin) LogConfig(io.vertigo.app.config.LogConfig) Test(org.junit.jupiter.api.Test)

Example 5 with AppConfig

use of io.vertigo.app.config.AppConfig in project vertigo by KleeGroup.

the class AppConfig2Test method HomeTest.

@Test
public void HomeTest() {
    final AppConfig appConfig = new XMLAppConfigBuilder().withModules(getClass(), new Properties(), "bio.xml").build();
    testBioManager(appConfig);
}
Also used : AppConfig(io.vertigo.app.config.AppConfig) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Aggregations

AppConfig (io.vertigo.app.config.AppConfig)14 AutoCloseableApp (io.vertigo.app.AutoCloseableApp)11 Test (org.junit.jupiter.api.Test)11 FunctionManager (io.vertigo.core.spaces.component.data.FunctionManager)4 LogConfig (io.vertigo.app.config.LogConfig)3 MathPlugin (io.vertigo.core.spaces.component.data.MathPlugin)3 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3 Properties (java.util.Properties)3 Test (org.junit.Test)3 BioManager (io.vertigo.core.spaces.component.data.BioManager)2 BioManagerImpl (io.vertigo.core.spaces.component.data.BioManagerImpl)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 DynamoDefinitionProvider (io.vertigo.dynamo.plugins.environment.DynamoDefinitionProvider)2 XmlParamPlugin (io.vertigo.core.plugins.param.xml.XmlParamPlugin)1 DummyPlugin (io.vertigo.core.spaces.component.data.DummyPlugin)1 StartedManager (io.vertigo.core.spaces.component.data.StartedManager)1 StartedManagerInitializer (io.vertigo.core.spaces.component.data.StartedManagerInitializer)1