Search in sources :

Example 1 with PersistTestModuleBuilder

use of org.eclipse.che.commons.test.db.PersistTestModuleBuilder in project che by eclipse.

the class SshTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(SshPairImpl.class, UserImpl.class, AccountImpl.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(SshDao.class).to(JpaSshDao.class);
    bind(new TypeLiteral<TckRepository<SshPairImpl>>() {
    }).toInstance(new JpaTckRepository<>(SshPairImpl.class));
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserImpl.class));
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) SshPairImpl(org.eclipse.che.api.ssh.server.model.impl.SshPairImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl)

Example 2 with PersistTestModuleBuilder

use of org.eclipse.che.commons.test.db.PersistTestModuleBuilder in project che by eclipse.

the class WorkspaceTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
    }).toInstance(new WorkspaceRepository());
    bind(new TypeLiteral<TckRepository<StackImpl>>() {
    }).toInstance(new StackRepository());
    bind(WorkspaceDao.class).to(JpaWorkspaceDao.class);
    bind(StackDao.class).to(JpaStackDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) StackDao(org.eclipse.che.api.workspace.server.spi.StackDao) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao)

Example 3 with PersistTestModuleBuilder

use of org.eclipse.che.commons.test.db.PersistTestModuleBuilder in project che by eclipse.

the class JpaTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(UserImpl.class, ProfileImpl.class, PreferenceEntity.class, AccountImpl.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server.getDataSource()));
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).to(UserJpaTckRepository.class);
    bind(new TypeLiteral<TckRepository<ProfileImpl>>() {
    }).toInstance(new JpaTckRepository<>(ProfileImpl.class));
    bind(new TypeLiteral<TckRepository<Pair<String, Map<String, String>>>>() {
    }).to(PreferenceJpaTckRepository.class);
    bind(UserDao.class).to(JpaUserDao.class);
    bind(ProfileDao.class).to(JpaProfileDao.class);
    bind(PreferenceDao.class).to(JpaPreferenceDao.class);
    // SHA-512 encryptor is faster than PBKDF2 so it is better for testing
    bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) SHA512PasswordEncryptor(org.eclipse.che.security.SHA512PasswordEncryptor) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) TypeLiteral(com.google.inject.TypeLiteral) UserDao(org.eclipse.che.api.user.server.spi.UserDao) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) DBInitializer(org.eclipse.che.core.db.DBInitializer) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Pair(org.eclipse.che.commons.lang.Pair)

Example 4 with PersistTestModuleBuilder

use of org.eclipse.che.commons.test.db.PersistTestModuleBuilder in project che by eclipse.

the class AccountJpaTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClass(AccountImpl.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(AccountDao.class).to(JpaAccountDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) AccountDao(org.eclipse.che.account.spi.AccountDao) JpaAccountDao(org.eclipse.che.account.spi.jpa.JpaAccountDao) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner)

Example 5 with PersistTestModuleBuilder

use of org.eclipse.che.commons.test.db.PersistTestModuleBuilder in project che by eclipse.

the class CascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    server = H2DBTestServer.startDefault();
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class, SshPairImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").setExceptionHandler(H2ExceptionHandler.class).build());
            bind(EventService.class).in(Singleton.class);
            install(new InitModule(PostConstruct.class));
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new WorkspaceJpaModule());
            install(new MachineJpaModule());
            bind(WorkspaceManager.class);
            final WorkspaceRuntimes wR = mock(WorkspaceRuntimes.class);
            when(wR.hasRuntime(anyString())).thenReturn(false);
            bind(WorkspaceRuntimes.class).toInstance(wR);
            bind(AccountManager.class);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_snapshot")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_restore")).toInstance(false);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null));
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    userDao = injector.getInstance(UserDao.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    snapshotDao = injector.getInstance(SnapshotDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
}
Also used : EventService(org.eclipse.che.api.core.notification.EventService) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) AccountDao(org.eclipse.che.account.spi.AccountDao) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) InitModule(org.eclipse.che.inject.lifecycle.InitModule) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) AbstractModule(com.google.inject.AbstractModule) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) SnapshotDao(org.eclipse.che.api.machine.server.spi.SnapshotDao) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) MachineJpaModule(org.eclipse.che.api.machine.server.jpa.MachineJpaModule) WorkspaceRuntimes(org.eclipse.che.api.workspace.server.WorkspaceRuntimes) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) PostConstruct(javax.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) WorkspaceJpaModule(org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

PersistTestModuleBuilder (org.eclipse.che.commons.test.db.PersistTestModuleBuilder)6 DBInitializer (org.eclipse.che.core.db.DBInitializer)6 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)6 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)6 TypeLiteral (com.google.inject.TypeLiteral)5 AccountImpl (org.eclipse.che.account.spi.AccountImpl)5 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)5 AccountDao (org.eclipse.che.account.spi.AccountDao)3 SshDao (org.eclipse.che.api.ssh.server.spi.SshDao)3 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)3 PreferenceDao (org.eclipse.che.api.user.server.spi.PreferenceDao)3 ProfileDao (org.eclipse.che.api.user.server.spi.ProfileDao)3 UserDao (org.eclipse.che.api.user.server.spi.UserDao)3 WorkspaceDao (org.eclipse.che.api.workspace.server.spi.WorkspaceDao)3 H2DBTestServer (org.eclipse.che.commons.test.db.H2DBTestServer)3 H2JpaCleaner (org.eclipse.che.commons.test.db.H2JpaCleaner)3 JpaAccountDao (org.eclipse.che.account.spi.jpa.JpaAccountDao)2 SnapshotDao (org.eclipse.che.api.machine.server.spi.SnapshotDao)2 SshPairImpl (org.eclipse.che.api.ssh.server.model.impl.SshPairImpl)2 ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)2