Repository: ambari Updated Branches: refs/heads/branch-2.4 afd01101e -> 33c347b07
Revert "AMBARI-18575. Fix for improving time taken by 'ExecutionScheduleManagerTest' and 'UpgradeCatalog221Test' java tests." This reverts commit fdc5bd3fdf23b2035a27648d2db20e22c2159a0b. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/33c347b0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/33c347b0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/33c347b0 Branch: refs/heads/branch-2.4 Commit: 33c347b07ca40768209eb06068179df300ae6d04 Parents: afd0110 Author: Swapan Shridhar <sshrid...@hortonworks.com> Authored: Mon Oct 17 19:27:00 2016 -0700 Committer: Swapan Shridhar <sshrid...@hortonworks.com> Committed: Mon Oct 17 19:27:00 2016 -0700 ---------------------------------------------------------------------- .../scheduler/ExecutionScheduleManagerTest.java | 34 ++++++++-------- .../server/upgrade/UpgradeCatalog221Test.java | 42 ++++++++------------ 2 files changed, 34 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/33c347b0/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java index 3ac69ab..860e647 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionScheduleManagerTest.java @@ -48,8 +48,8 @@ import org.apache.ambari.server.state.scheduler.RequestExecutionFactory; import org.apache.ambari.server.state.scheduler.Schedule; import org.easymock.Capture; import org.easymock.EasyMock; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.quartz.CronTrigger; import org.quartz.JobDataMap; @@ -88,22 +88,22 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; public class ExecutionScheduleManagerTest { - private static Clusters clusters; - private static Cluster cluster; - private static String clusterName; - private static Injector injector; - private static AmbariMetaInfo metaInfo; - private static ExecutionScheduleManager executionScheduleManager; - private static RequestExecutionFactory requestExecutionFactory; - private static ExecutionScheduler executionScheduler; - private static Scheduler scheduler; - static Properties properties; + private Clusters clusters; + private Cluster cluster; + private String clusterName; + private Injector injector; + private AmbariMetaInfo metaInfo; + private ExecutionScheduleManager executionScheduleManager; + private RequestExecutionFactory requestExecutionFactory; + private ExecutionScheduler executionScheduler; + private Scheduler scheduler; + Properties properties; private static final Logger LOG = LoggerFactory.getLogger(ExecutionScheduleManagerTest.class); - @BeforeClass - public static void setup() throws Exception { + @Before + public void setup() throws Exception { InMemoryDefaultTestModule defaultTestModule = new InMemoryDefaultTestModule(); properties = defaultTestModule.getProperties(); injector = Guice.createInjector(Modules.override(defaultTestModule) @@ -129,8 +129,8 @@ public class ExecutionScheduleManagerTest { executionScheduleManager.start(); } - @AfterClass - public static void teardown() throws Exception { + @After + public void teardown() throws Exception { executionScheduleManager.stop(); injector.getInstance(PersistService.class).stop(); } @@ -155,7 +155,7 @@ public class ExecutionScheduleManagerTest { } } - public static class ExecutionSchedulerTestModule implements Module { + public class ExecutionSchedulerTestModule implements Module { @Override public void configure(Binder binder) { binder.bind(ExecutionScheduler.class).to(TestExecutionScheduler.class); http://git-wip-us.apache.org/repos/asf/ambari/blob/33c347b0/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog221Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog221Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog221Test.java index 4663c6c..e754a41 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog221Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog221Test.java @@ -33,10 +33,10 @@ import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.actionmanager.ActionManager; import org.apache.ambari.server.api.services.AmbariMetaInfo; import org.apache.ambari.server.controller.AmbariManagementController; +import org.apache.ambari.server.orm.DBAccessor; import org.apache.ambari.server.controller.AmbariManagementControllerImpl; import org.apache.ambari.server.controller.KerberosHelper; import org.apache.ambari.server.controller.MaintenanceStateHelper; -import org.apache.ambari.server.orm.DBAccessor; import org.apache.ambari.server.orm.GuiceJpaInitializer; import org.apache.ambari.server.orm.InMemoryDefaultTestModule; import org.apache.ambari.server.orm.dao.AlertDefinitionDAO; @@ -46,47 +46,39 @@ import org.apache.ambari.server.orm.entities.StackEntity; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; +import org.apache.ambari.server.state.RepositoryInfo; import org.apache.ambari.server.state.StackId; +import org.apache.ambari.server.state.StackInfo; import org.apache.ambari.server.state.stack.OsFamily; import org.easymock.Capture; import org.easymock.EasyMock; import org.easymock.EasyMockSupport; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import javax.persistence.EntityManager; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.anyString; -import static org.easymock.EasyMock.capture; -import static org.easymock.EasyMock.createMockBuilder; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.createStrictMock; -import static org.easymock.EasyMock.eq; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reset; -import static org.easymock.EasyMock.verify; +import static org.easymock.EasyMock.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public class UpgradeCatalog221Test { - private static Injector injector; - private static Provider<EntityManager> entityManagerProvider = createStrictMock(Provider.class); - private static EntityManager entityManager = createNiceMock(EntityManager.class); - private static UpgradeCatalogHelper upgradeCatalogHelper; - private static StackEntity desiredStackEntity; - - @BeforeClass - public static void init() { + private Injector injector; + private Provider<EntityManager> entityManagerProvider = createStrictMock(Provider.class); + private EntityManager entityManager = createNiceMock(EntityManager.class); + private UpgradeCatalogHelper upgradeCatalogHelper; + private StackEntity desiredStackEntity; + + @Before + public void init() { reset(entityManagerProvider); expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes(); replay(entityManagerProvider); @@ -101,8 +93,8 @@ public class UpgradeCatalog221Test { desiredStackEntity = stackDAO.find("HDP", "2.2.0"); } - @AfterClass - public static void tearDown() { + @After + public void tearDown() { injector.getInstance(PersistService.class).stop(); }