Search in sources :

Example 1 with ContextMock

use of com.codingchili.core.testing.ContextMock in project chili-core by codingchili.

the class ConfigurationsTest method testLoadDefaultsFromConfigurable.

@Test
public void testLoadDefaultsFromConfigurable(TestContext test) {
    Async async = test.async();
    Configurations.setWarnOnDefaultsLoaded(true);
    Configurations.initialize(new ContextMock(context) {

        @Override
        public Logger logger(Class aClass) {
            return new ConsoleLogger(aClass) {

                @Override
                public void onConfigurationDefaultsLoaded(String path, Class<?> clazz) {
                    if (path.equals(CoreStrings.testFile(CONFIGURATIONS, DEFAULT_JSON))) {
                        Configurations.reset();
                        async.complete();
                    }
                }
            };
        }
    });
    load(CoreStrings.testFile(CONFIGURATIONS, DEFAULT_JSON), ConfigurableTest.class);
}
Also used : Async(io.vertx.ext.unit.Async) ConsoleLogger(com.codingchili.core.logging.ConsoleLogger) ContextMock(com.codingchili.core.testing.ContextMock) Logger(com.codingchili.core.logging.Logger) ConsoleLogger(com.codingchili.core.logging.ConsoleLogger) ConfigurableTest(com.codingchili.core.configuration.ConfigurableTest)

Example 2 with ContextMock

use of com.codingchili.core.testing.ContextMock in project chili-core by codingchili.

the class DelayTest method setUp.

@Before
public void setUp() {
    this.context = new ContextMock() {

        @Override
        public SystemSettings system() {
            SystemSettings settings = new SystemSettings();
            settings.setShutdownLogTimeout(1);
            return settings;
        }
    };
    Delay.initialize(context);
}
Also used : ContextMock(com.codingchili.core.testing.ContextMock) SystemSettings(com.codingchili.core.configuration.system.SystemSettings) Before(org.junit.Before)

Example 3 with ContextMock

use of com.codingchili.core.testing.ContextMock in project chili-core by codingchili.

the class SecuritySettingsTest method testLoadKeyStore.

@Test
public void testLoadKeyStore(TestContext test) {
    ContextMock mock = new ContextMock();
    try {
        getKeystoreBuilder().build();
        TrustAndKeyProvider provider = security().getKeystore(mock, IDENTIFIER);
        test.assertNotNull(provider);
    } finally {
        mock.close();
    }
}
Also used : TrustAndKeyProvider(com.codingchili.core.security.TrustAndKeyProvider) ContextMock(com.codingchili.core.testing.ContextMock) Test(org.junit.Test)

Example 4 with ContextMock

use of com.codingchili.core.testing.ContextMock in project chili-core by codingchili.

the class SystemContextTest method setUp.

@Before
public void setUp() {
    this.settings = Configurations.system();
    settings.getMetrics().setRate(100);
    settings.getMetrics().setEnabled(true);
    this.context = new ContextMock() {

        @Override
        public Logger logger(Class aClass) {
            return new AbstractLogger(getClass()) {

                @Override
                public void onMetricsSnapshot(JsonObject metrics) {
                    listener.onMetric(metrics);
                }
            };
        }

        @Override
        public SystemSettings system() {
            return settings;
        }
    };
}
Also used : JsonObject(io.vertx.core.json.JsonObject) ContextMock(com.codingchili.core.testing.ContextMock) AbstractLogger(com.codingchili.core.logging.AbstractLogger) Logger(com.codingchili.core.logging.Logger) SystemSettings(com.codingchili.core.configuration.system.SystemSettings) AbstractLogger(com.codingchili.core.logging.AbstractLogger)

Example 5 with ContextMock

use of com.codingchili.core.testing.ContextMock in project chili-core by codingchili.

the class AuthenticationGeneratorIT method setUp.

@Before
public void setUp() {
    context = new ContextMock();
    Configurations.put(createSecuritySettings());
    generator = new AuthenticationGenerator(context, CoreStrings.testDirectory(AUTHENTICATION_GENERATOR) + DIR_ROOT);
}
Also used : ContextMock(com.codingchili.core.testing.ContextMock)

Aggregations

ContextMock (com.codingchili.core.testing.ContextMock)9 SystemSettings (com.codingchili.core.configuration.system.SystemSettings)2 Logger (com.codingchili.core.logging.Logger)2 Async (io.vertx.ext.unit.Async)2 Before (org.junit.Before)2 ConfigurableTest (com.codingchili.core.configuration.ConfigurableTest)1 ClusterListener (com.codingchili.core.listener.transport.ClusterListener)1 AbstractLogger (com.codingchili.core.logging.AbstractLogger)1 ConsoleLogger (com.codingchili.core.logging.ConsoleLogger)1 TrustAndKeyProvider (com.codingchili.core.security.TrustAndKeyProvider)1 JsonObject (io.vertx.core.json.JsonObject)1 Test (org.junit.Test)1