Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 1f635ea24 -> fdc5bd3fd


AMBARI-18575. Fix for improving time taken by 'ExecutionScheduleManagerTest' 
and 'UpgradeCatalog221Test' java tests.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fdc5bd3f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fdc5bd3f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fdc5bd3f

Branch: refs/heads/branch-2.4
Commit: fdc5bd3fdf23b2035a27648d2db20e22c2159a0b
Parents: 1f635ea
Author: Swapan Shridhar <sshrid...@hortonworks.com>
Authored: Wed Oct 12 15:51:26 2016 -0700
Committer: Swapan Shridhar <sshrid...@hortonworks.com>
Committed: Wed Oct 12 15:55:12 2016 -0700

----------------------------------------------------------------------
 .../scheduler/ExecutionScheduleManagerTest.java | 34 ++++++++--------
 .../server/upgrade/UpgradeCatalog221Test.java   | 42 ++++++++++++--------
 2 files changed, 42 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fdc5bd3f/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 860e647..3ac69ab 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.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 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 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 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 static final Logger LOG =
     LoggerFactory.getLogger(ExecutionScheduleManagerTest.class);
 
-  @Before
-  public void setup() throws Exception {
+  @BeforeClass
+  public static 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();
   }
 
-  @After
-  public void teardown() throws Exception {
+  @AfterClass
+  public static void teardown() throws Exception {
     executionScheduleManager.stop();
     injector.getInstance(PersistService.class).stop();
   }
@@ -155,7 +155,7 @@ public class ExecutionScheduleManagerTest {
     }
   }
 
-  public class ExecutionSchedulerTestModule implements Module {
+  public static 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/fdc5bd3f/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 e754a41..4663c6c 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,39 +46,47 @@ 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.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 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.*;
+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.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class UpgradeCatalog221Test {
-  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() {
+  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() {
     reset(entityManagerProvider);
     expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
     replay(entityManagerProvider);
@@ -93,8 +101,8 @@ public class UpgradeCatalog221Test {
     desiredStackEntity = stackDAO.find("HDP", "2.2.0");
   }
 
-  @After
-  public void tearDown() {
+  @AfterClass
+  public static void tearDown() {
     injector.getInstance(PersistService.class).stop();
   }
 

Reply via email to