Search in sources :

Example 1 with ServiceContext

use of keywhiz.test.ServiceContext in project keywhiz by square.

the class BackfillOwnershipCommandTest method backfill.

private int backfill() {
    ServiceContext context = ServiceContext.create();
    Namespace namespace = new Namespace(Collections.emptyMap());
    return new BackfillOwnershipCommand().execute(context.getBootstrap(), namespace, context.getConfig());
}
Also used : ServiceContext(keywhiz.test.ServiceContext) Namespace(net.sourceforge.argparse4j.inf.Namespace)

Example 2 with ServiceContext

use of keywhiz.test.ServiceContext in project keywhiz by square.

the class ServiceDataSourceModuleTest method injectsDataSources.

@Test
public void injectsDataSources() {
    class Holder {

        @Inject
        ManagedDataSource readWrite;

        @Inject
        @Readonly
        ManagedDataSource readonly;
    }
    Holder holder = new Holder();
    ServiceContext context = ServiceContext.create();
    Guice.createInjector(new ContextModule(context.getConfig(), context.getEnvironment()), new ServiceDataSourceModule()).injectMembers(holder);
    assertNotNull(holder.readWrite);
    assertNotNull(holder.readonly);
}
Also used : ServiceContext(keywhiz.test.ServiceContext) ContextModule(keywhiz.inject.ContextModule) ServiceDataSourceModule(keywhiz.ServiceDataSourceModule) ManagedDataSource(io.dropwizard.db.ManagedDataSource) Test(org.junit.Test)

Example 3 with ServiceContext

use of keywhiz.test.ServiceContext in project keywhiz by square.

the class AddUserCommandTest method injectsUserDAO.

@Test
public void injectsUserDAO() {
    ServiceContext context = ServiceContext.create();
    assertNotNull(AddUserCommand.getUserDAO(context.getBootstrap(), context.getConfig()));
}
Also used : ServiceContext(keywhiz.test.ServiceContext) Test(org.junit.Test)

Example 4 with ServiceContext

use of keywhiz.test.ServiceContext in project keywhiz by square.

the class KeywhizServiceTest method ensuresInjectorIsCreated.

@Test
public void ensuresInjectorIsCreated() {
    ServiceContext context = ServiceContext.create();
    KeywhizService service = context.getService();
    assertNull(service.getInjector());
    service.ensureInjectorCreated(context.getConfig(), context.getEnvironment());
    assertNotNull(service.getInjector());
}
Also used : ServiceContext(keywhiz.test.ServiceContext) Test(org.junit.Test)

Example 5 with ServiceContext

use of keywhiz.test.ServiceContext in project keywhiz by square.

the class DropDeletedSecretsCommandTest method injectsDao.

@Test
public void injectsDao() {
    ServiceContext context = ServiceContext.create();
    assertNotNull(DropDeletedSecretsCommand.getSecretDAO(context.getBootstrap(), context.getConfig()));
}
Also used : ServiceContext(keywhiz.test.ServiceContext) Test(org.junit.Test)

Aggregations

ServiceContext (keywhiz.test.ServiceContext)8 Test (org.junit.Test)7 Injector (com.google.inject.Injector)2 ManagedDataSource (io.dropwizard.db.ManagedDataSource)2 ServiceDataSourceModule (keywhiz.ServiceDataSourceModule)2 ContextModule (keywhiz.inject.ContextModule)2 Configuration (io.dropwizard.Configuration)1 Environment (io.dropwizard.setup.Environment)1 KeywhizConfig (keywhiz.KeywhizConfig)1 Namespace (net.sourceforge.argparse4j.inf.Namespace)1