summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-07-10 20:53:17 (EDT)
committer Ryan D. Brooks2011-07-10 20:53:17 (EDT)
commita5b63b9a6908d47f524f049ce4f8b0a5c13919aa (patch)
treea713c41f476b57fefe38839bcd96fe0c8694de68
parent2cf4bbad2f769d6b24c512439b5a6d5a43bf205c (diff)
downloadorg.eclipse.osee-a5b63b9a6908d47f524f049ce4f8b0a5c13919aa.zip
org.eclipse.osee-a5b63b9a6908d47f524f049ce4f8b0a5c13919aa.tar.gz
org.eclipse.osee-a5b63b9a6908d47f524f049ce4f8b0a5c13919aa.tar.bz2
refactor: Reduce running time of BranchManagerTest from ~20msec to ~6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManagerTest.java61
1 files changed, 30 insertions, 31 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManagerTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManagerTest.java
index 7e9df9e..a3d7f7e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManagerTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManagerTest.java
@@ -11,15 +11,16 @@
package org.eclipse.osee.framework.skynet.core.artifact;
import static org.junit.Assert.assertFalse;
-import java.util.Arrays;
import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.BranchDoesNotExist;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.UserManager;
-import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
import org.eclipse.osee.support.test.util.TestUtil;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* @author Donald G. Dunne
@@ -29,47 +30,45 @@ public class BranchManagerTest {
public static String branchName = "BranchManagerTest";
public static String branchReNamed = "BranchManagerTest-Renamed";
- @Before
- public void setUp() throws Exception {
+ private static Branch testBranch;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
// This test should only be run on test db
assertFalse(TestUtil.isProductionDb());
- cleanup();
- }
-
- @org.junit.Test
- public void testRenameBranch() throws Exception {
-
- Assert.assertEquals("Branch should not exist", 0, BranchManager.getBranchesByName(branchName).size());
- Assert.assertEquals("Branch should not exist", 0, BranchManager.getBranchesByName(branchReNamed).size());
- // create a new working branch
- Branch branch =
+ testBranch =
BranchManager.createWorkingBranch(BranchManager.getCommonBranch(), branchName,
UserManager.getUser(SystemUser.OseeSystem));
+ }
+
+ @Test
+ public void testBranchRetrieval() throws Exception {
+ testBranch.equals(BranchManager.getBranch(branchName));
+ }
- Assert.assertNotNull(BranchManager.getBranch(branchName));
- Assert.assertEquals("Branch should not exist", 0, BranchManager.getBranchesByName(branchReNamed).size());
+ @Test
+ public void testRenameBranch() throws Exception {
+ Assert.assertEquals(branchName, testBranch.getName());
- branch.setName(branchReNamed);
- BranchManager.persist(branch);
+ testBranch.setName(branchReNamed);
+ BranchManager.persist(testBranch);
- Assert.assertEquals("Branch should not exist", 0, BranchManager.getBranchesByName(branchName).size());
- Assert.assertNotNull(BranchManager.getBranch(branchReNamed));
+ testBranch = BranchManager.getBranch(branchReNamed);
+ Assert.assertEquals(branchReNamed, testBranch.getName());
+ }
+ @Test(expected = BranchDoesNotExist.class)
+ public void testLookForOldBranch() throws OseeCoreException {
+ Assert.assertNull("Old branch is found and should be renamed...", BranchManager.getBranch(branchName));
}
- @After
- public void testCleanupPost() throws Exception {
+ @AfterClass
+ public static void testCleanupPost() throws Exception {
cleanup();
}
private static void cleanup() throws Exception {
- if (BranchManager.getBranchesByName(branchName).size() > 0) {
- FrameworkTestUtil.purgeWorkingBranches(Arrays.asList(branchName));
- }
- if (BranchManager.getBranchesByName(branchReNamed).size() > 0) {
- FrameworkTestUtil.purgeWorkingBranches(Arrays.asList(branchReNamed));
- }
+ BranchManager.purgeBranch(BranchManager.getBranch(branchReNamed));
}
-
}