Skip to content

Commit

Permalink
Remove deprecated jpa test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed Oct 12, 2017
1 parent 4d0282b commit f07aae6
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ public H2JpaCleaner(DataSource dataSource) {
this.dataSource = dataSource;
}

/** @deprecated use {@link H2JpaCleaner(H2DBTestServer)} instead. */
@Deprecated
public H2JpaCleaner() {
this(H2TestHelper.inMemoryDefault());
}

@Override
public void clean() {
super.clean();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
*/
package org.eclipse.che.multiuser.organization.spi.tck.jpa;

import static org.eclipse.che.commons.test.db.H2TestHelper.inMemoryDefault;

import com.google.inject.TypeLiteral;
import com.google.inject.persist.jpa.JpaPersistModule;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.commons.test.db.H2DBTestServer;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.tck.TckModule;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
Expand Down Expand Up @@ -42,10 +41,11 @@ public class OrganizationJpaTckModule extends TckModule {
@Override
protected void configure() {
install(new JpaPersistModule("main"));
H2DBTestServer server = H2DBTestServer.startDefault();
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(inMemoryDefault(), "che-schema"));
.toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));

bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {}).to(OrganizationDomain.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
*/
package org.eclipse.che.multiuser.resource.spi.tck.jpa;

import static org.eclipse.che.commons.test.db.H2TestHelper.inMemoryDefault;

import com.google.inject.TypeLiteral;
import com.google.inject.persist.jpa.JpaPersistModule;
import org.eclipse.che.account.spi.AccountImpl;
import org.eclipse.che.commons.test.db.H2DBTestServer;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.tck.TckModule;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
Expand All @@ -33,10 +32,11 @@ public class ResourceTckModule extends TckModule {
@Override
protected void configure() {
install(new JpaPersistModule("main"));
H2DBTestServer server = H2DBTestServer.startDefault();
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(inMemoryDefault(), "che-schema"));
.toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));

bind(new TypeLiteral<TckRepository<FreeResourcesLimitImpl>>() {})
.toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.eclipse.che.commons.test.db.H2TestHelper.inMemoryDefault;
import static org.eclipse.che.multiuser.api.permission.server.AbstractPermissionsDomain.SET_PERMISSIONS;
import static org.eclipse.che.multiuser.integration.jpa.cascaderemoval.TestObjectsFactory.createAccount;
import static org.eclipse.che.multiuser.integration.jpa.cascaderemoval.TestObjectsFactory.createFactory;
Expand Down Expand Up @@ -85,8 +84,7 @@
import org.eclipse.che.commons.env.EnvironmentContext;
import org.eclipse.che.commons.lang.Pair;
import org.eclipse.che.commons.subject.SubjectImpl;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
import org.eclipse.che.commons.test.db.H2DBTestServer;
import org.eclipse.che.core.db.DBInitializer;
import org.eclipse.che.core.db.cascade.CascadeEventSubscriber;
import org.eclipse.che.core.db.cascade.event.CascadeEvent;
Expand Down Expand Up @@ -222,12 +220,12 @@ public void setUp() throws Exception {
new AbstractModule() {
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new JpaPersistModule("main"));
bind(EventService.class).in(Singleton.class);
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(inMemoryDefault(), "che-schema"));
.toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
install(new InitModule(PostConstruct.class));
install(new UserJpaModule());
install(new AccountModule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.persistence.EntityManager;
import org.eclipse.che.api.recipe.OldRecipeImpl;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.machine.recipe.RecipePermissionsImpl;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
Expand Down Expand Up @@ -106,7 +105,6 @@ public void cleanup() {
@AfterClass
public void shutdown() throws Exception {
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import org.eclipse.che.api.recipe.OldRecipeImpl;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.commons.test.db.H2DBTestServer;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.db.PersistTestModuleBuilder;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
import org.eclipse.che.core.db.DBInitializer;
import org.eclipse.che.core.db.h2.jpa.eclipselink.H2ExceptionHandler;
import org.eclipse.che.core.db.schema.SchemaInitializer;
Expand Down Expand Up @@ -50,7 +48,6 @@ protected void configure() {
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(DBInitializer.class).asEagerSingleton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import javax.persistence.EntityManager;
import org.eclipse.che.api.recipe.OldRecipeImpl;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.machine.recipe.RecipePermissionsImpl;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
Expand Down Expand Up @@ -118,7 +117,6 @@ public void cleanup() {
@AfterClass
public void shutdown() throws Exception {
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.che.api.recipe.JpaRecipeDao;
import org.eclipse.che.api.recipe.OldRecipeImpl;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.machine.jpa.JpaRecipePermissionsDao.RemovePermissionsBeforeRecipeRemovedEventSubscriber;
import org.eclipse.che.multiuser.permission.machine.recipe.RecipePermissionsImpl;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -110,7 +109,6 @@ public void cleanup() {
public void shutdown() throws Exception {
subscriber.unsubscribe();
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import javax.persistence.EntityManager;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.workspace.server.spi.jpa.MultiuserJpaStackDao;
import org.eclipse.che.multiuser.permission.workspace.server.stack.StackPermissionsImpl;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -132,7 +131,6 @@ public void cleanup() {
@AfterClass
public void shutdown() throws Exception {
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@
package org.eclipse.che.multiuser.permission.workspace.server.jpa;

import static java.util.Arrays.asList;
import static org.eclipse.che.commons.test.db.H2TestHelper.inMemoryDefault;
import static org.testng.Assert.assertTrue;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import com.google.inject.persist.jpa.JpaPersistModule;
import java.util.List;
import javax.persistence.EntityManager;
import org.eclipse.che.api.core.Page;
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.api.workspace.server.event.BeforeStackRemovedEvent;
import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.core.db.DBInitializer;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer;
import org.eclipse.che.multiuser.api.permission.server.AbstractPermissionsDomain;
import org.eclipse.che.multiuser.permission.workspace.server.spi.jpa.JpaStackPermissionsDao;
import org.eclipse.che.multiuser.permission.workspace.server.stack.StackPermissionsImpl;
Expand Down Expand Up @@ -123,7 +115,6 @@ public void cleanup() {
@AfterClass
public void shutdown() throws Exception {
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down Expand Up @@ -170,18 +161,6 @@ public void shouldRemoveStackPublicPermission() throws Exception {
assertTrue(byInstance.getItems().stream().filter(p -> "*".equals(p.getUserId())).count() == 0);
}

private class TestModule extends AbstractModule {
@Override
protected void configure() {
install(new JpaPersistModule("main"));
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(inMemoryDefault(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(new TypeLiteral<AbstractPermissionsDomain<StackPermissionsImpl>>() {})
.to(TestDomain.class);
}
}

public static class TestDomain extends AbstractPermissionsDomain<StackPermissionsImpl> {
public TestDomain() {
super("stack", asList("read", "write", "use", "delete"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl;
import org.eclipse.che.multiuser.permission.workspace.server.spi.jpa.MultiuserJpaWorkspaceDao;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -122,7 +121,6 @@ public void cleanup() {
@AfterClass
public void shutdown() throws Exception {
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*/
package org.eclipse.che.multiuser.permission.workspace.server.spi.jpa;

import static org.eclipse.che.commons.test.db.H2TestHelper.inMemoryDefault;

import com.google.inject.TypeLiteral;
import org.eclipse.che.account.spi.AccountImpl;
import org.eclipse.che.api.recipe.OldRecipeImpl;
Expand Down Expand Up @@ -105,8 +103,8 @@ protected void configure() {
.toInstance(new JpaTckRepository<>(WorkspaceImpl.class));

bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(inMemoryDefault(), "che-schema"));
.toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.che.api.user.server.model.impl.UserImpl;
import org.eclipse.che.api.workspace.server.jpa.JpaStackDao;
import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.api.permission.server.AbstractPermissionsDomain;
import org.eclipse.che.multiuser.permission.machine.recipe.RecipePermissionsImpl;
import org.eclipse.che.multiuser.permission.workspace.server.spi.jpa.JpaStackPermissionsDao.RemovePermissionsBeforeStackRemovedEventSubscriber;
Expand Down Expand Up @@ -105,7 +104,6 @@ public void cleanup() {
public void shutdown() throws Exception {
subscriber.unsubscribe();
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.che.api.workspace.server.jpa.JpaWorkspaceDao;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.multiuser.permission.workspace.server.model.impl.WorkerImpl;
import org.eclipse.che.multiuser.permission.workspace.server.spi.jpa.JpaWorkerDao.RemoveWorkersBeforeWorkspaceRemovedEventSubscriber;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -119,7 +118,6 @@ public void cleanup() {
public void shutdown() throws Exception {
subscriber.unsubscribe();
manager.getEntityManagerFactory().close();
H2TestHelper.shutdownDefault();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.tck.JpaCleaner;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand All @@ -39,14 +38,14 @@ public class JpaWorkspaceDaoTest {

private EntityManager manager;
private JpaWorkspaceDao workspaceDao;
private JpaCleaner cleaner;
private TckResourcesCleaner cleaner;

@BeforeMethod
private void setUpManager() {
final Injector injector = Guice.createInjector(new WorkspaceTckModule());
manager = injector.getInstance(EntityManager.class);
workspaceDao = injector.getInstance(JpaWorkspaceDao.class);
cleaner = injector.getInstance(H2JpaCleaner.class);
cleaner = injector.getInstance(TckResourcesCleaner.class);
}

@AfterMethod
Expand Down

0 comments on commit f07aae6

Please sign in to comment.