summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-10-10 17:55:50 (EDT)
committer Roberto E. Escobar2011-10-10 17:55:50 (EDT)
commiteff0bb3d1d748468c5beefceb91f088d8fa44630 (patch)
tree7558ffa98e2ae74f6fef81df5e45b1b2784e39d8
parent3d0041327f8a46d2da75b0ee9f84a33979cc3754 (diff)
downloadorg.eclipse.osee-eff0bb3d1d748468c5beefceb91f088d8fa44630.zip
org.eclipse.osee-eff0bb3d1d748468c5beefceb91f088d8fa44630.tar.gz
org.eclipse.osee-eff0bb3d1d748468c5beefceb91f088d8fa44630.tar.bz2
refactor: Checks for data consistency on tests
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/CoverageParametersTest.java5
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageOptionManagerStoreTest.java5
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoveragePreferencesTest.java5
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageUnitPersistTest.java5
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/TestUnitCacheTest.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/UserManagerTest.java11
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java25
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java6
9 files changed, 57 insertions, 16 deletions
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/CoverageParametersTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/CoverageParametersTest.java
index db4da15..27728e9 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/CoverageParametersTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/CoverageParametersTest.java
@@ -26,7 +26,9 @@ import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -34,6 +36,9 @@ import org.junit.Test;
*/
public class CoverageParametersTest {
+ @Rule
+ public OseeHousekeepingRule hk = new OseeHousekeepingRule();
+
public static CoverageImport coverageImport = null;
@Test
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageOptionManagerStoreTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageOptionManagerStoreTest.java
index 2e335da..8c8a3e7 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageOptionManagerStoreTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageOptionManagerStoreTest.java
@@ -22,9 +22,11 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.KeyValueArtifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -32,6 +34,9 @@ import org.junit.Test;
*/
public class CoverageOptionManagerStoreTest {
+ @Rule
+ public OseeHousekeepingRule hk = new OseeHousekeepingRule();
+
@BeforeClass
public static void setUp() throws OseeCoreException {
SkynetTransaction transaction = new SkynetTransaction(CoverageTestUtil.getTestBranch(), "delete");
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoveragePreferencesTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoveragePreferencesTest.java
index 704149e..9b0edd0 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoveragePreferencesTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoveragePreferencesTest.java
@@ -17,9 +17,11 @@ import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -27,6 +29,9 @@ import org.junit.Test;
*/
public class CoveragePreferencesTest {
+ @Rule
+ public OseeHousekeepingRule hk = new OseeHousekeepingRule();
+
@BeforeClass
public static void setUp() throws OseeCoreException {
SkynetTransaction transaction = new SkynetTransaction(CoverageTestUtil.getTestBranch(), "delete");
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageUnitPersistTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageUnitPersistTest.java
index 1a99cab..36277e0 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageUnitPersistTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/model/CoverageUnitPersistTest.java
@@ -34,10 +34,12 @@ import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -53,6 +55,9 @@ public class CoverageUnitPersistTest {
public static CoveragePackage saveCoveragePackage;
public static CoveragePackage loadCoveragePackage;
+ @Rule
+ public OseeHousekeepingRule hk = new OseeHousekeepingRule();
+
@BeforeClass
@AfterClass
public static void testCleanup() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/TestUnitCacheTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/TestUnitCacheTest.java
index 2725f14..eed0f5d 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/TestUnitCacheTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/TestUnitCacheTest.java
@@ -27,6 +27,8 @@ import org.eclipse.osee.coverage.store.TestUnitCache;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -34,6 +36,9 @@ import org.junit.Test;
*/
public class TestUnitCacheTest {
+ @Rule
+ public OseeHousekeepingRule hk = new OseeHousekeepingRule();
+
private CoverageItem createCoverageItem(TestUnitCache tc) throws OseeCoreException {
CoverageUnit parent = new CoverageUnit(null, "Top", "C:/UserData/", null);
CoverageItem ci1 = new CoverageItem(parent, CoverageOptionManager.Deactivated_Code, "1");
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/UserManagerTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/UserManagerTest.java
index c2d25b2..1178a9d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/UserManagerTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/UserManagerTest.java
@@ -27,7 +27,10 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* @author Karol M. Wilk
@@ -47,7 +50,7 @@ public final class UserManagerTest {
return user;
}
- @org.junit.Test
+ @Test
public void testCreateUser() throws Exception {
SkynetTransaction transaction =
@@ -80,12 +83,12 @@ public final class UserManagerTest {
Assert.assertTrue("Members not subscribed to right groups.", verifiedNames.size() == TEST_DEFAULT_GROUPS.length);
}
- @org.junit.BeforeClass
+ @BeforeClass
public static void setUpOnce() throws Exception {
createSampleDefaultGroups(CoreBranches.COMMON, TEST_DEFAULT_GROUPS);
}
- @org.junit.AfterClass
+ @AfterClass
public static void tearDownOnce() throws Exception {
deleteSampleDefaultGroups(CoreBranches.COMMON, TEST_DEFAULT_GROUPS);
}
@@ -102,7 +105,7 @@ public final class UserManagerTest {
//Create relation between containing folder and new UserGroup
Artifact groupRoot = ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "User Groups", branch);
groupRoot.addRelation(CoreRelationTypes.Default_Hierarchical__Child, groupArt);
- groupRoot.persist("Create user group");
+ groupRoot.persist(UserManagerTest.class.getSimpleName() + ": Create user group");
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java
index 694a49e..ebfe51a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java
@@ -20,12 +20,15 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.CompositeOperation;
import org.eclipse.osee.framework.core.operation.NullOperationLogger;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.database.operation.PurgeUnusedBackingDataAndTransactions;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.httpRequests.PurgeBranchHttpRequestOperation;
+import org.eclipse.osee.framework.skynet.core.internal.Activator;
import org.eclipse.osee.framework.skynet.core.mocks.DbTestUtil;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
@@ -59,35 +62,39 @@ public class BranchPurgeTest {
public void testPurgeBranch() throws Exception {
Operations.executeWorkAndCheckStatus(new PurgeUnusedBackingDataAndTransactions(NullOperationLogger.getSingleton()));
+ String name = getClass().getSimpleName();
+
// Count rows in tables prior to purge
DbTestUtil.getTableRowCounts(preCreateCount, tables);
// create a new working branch
Branch branch =
- BranchManager.createWorkingBranch(DemoSawBuilds.SAW_Bld_2, getClass().getSimpleName(),
- UserManager.getUser(SystemUser.OseeSystem));
+ BranchManager.createWorkingBranch(DemoSawBuilds.SAW_Bld_2, name, UserManager.getUser(SystemUser.OseeSystem));
// create some software artifacts
Collection<Artifact> softArts =
- FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, getClass().getSimpleName(),
- branch);
+ FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, name, branch);
Artifacts.persistInTransaction("Test purge branch", softArts);
+ SkynetTransaction transaction = new SkynetTransaction(branch, name);
// make more changes to artifacts
for (Artifact softArt : softArts) {
- softArt.addAttribute(CoreAttributeTypes.StaticId, getClass().getSimpleName());
- softArt.persist(getClass().getSimpleName());
+ softArt.addAttribute(CoreAttributeTypes.StaticId, name);
+ softArt.persist(transaction);
}
+ transaction.execute();
// Count rows and check that increased
DbTestUtil.getTableRowCounts(postCreateBranchCount, tables);
TestUtil.checkThatIncreased(preCreateCount, postCreateBranchCount);
- Operations.executeWorkAndCheckStatus(new PurgeBranchHttpRequestOperation(branch, false));
+ CompositeOperation operation =
+ new CompositeOperation("PurgeBranchHttpRequest and PurgeUnusedBackingDataAndTransactions Ops",
+ Activator.PLUGIN_ID, new PurgeBranchHttpRequestOperation(branch, false),
+ new PurgeUnusedBackingDataAndTransactions(NullOperationLogger.getSingleton()));
- TestUtil.sleep(4000);
+ Operations.executeWorkAndCheckStatus(operation);
- Operations.executeWorkAndCheckStatus(new PurgeUnusedBackingDataAndTransactions(NullOperationLogger.getSingleton()));
// Count rows and check that same as when began
DbTestUtil.getTableRowCounts(postPurgeCount, tables);
// TODO looks like artifacts are not being removed when purge a branch
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java
index 8ca2794..2caee32 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java
@@ -26,12 +26,12 @@ public class DirtyArtifactCacheTest {
@org.junit.Test
public void testArtifactCacheNotDirty() {
final Collection<Artifact> dirtyArtifacts = ArtifactCache.getDirtyArtifacts();
- Assert.assertTrue(String.format(
- "After all tests are run, there should be no dirty artifacts in Artifact Cache; Found [%s]",
- Artifacts.getNames(dirtyArtifacts)), dirtyArtifacts.isEmpty());
for (Artifact artifact : dirtyArtifacts) {
OseeLog.logf(getClass(), Level.WARNING, "Name: %s Type: %s ", artifact.getName(),
artifact.getArtifactTypeName());
}
+ Assert.assertTrue(String.format(
+ "After all tests are run, there should be no dirty artifacts in Artifact Cache; \n Found [%s]",
+ Artifacts.getNames(dirtyArtifacts)), dirtyArtifacts.isEmpty());
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java
index 21bb4b7..4a1e888 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java
@@ -33,6 +33,7 @@ import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
import org.eclipse.osee.framework.skynet.core.utility.PurgeTransactionOperationWithListener;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.BeforeClass;
/**
* @author Ryan Schmitt
@@ -51,6 +52,11 @@ public class PurgeTransactionTest {
private static final List<String> tables = Arrays.asList("osee_attribute", "osee_artifact", "osee_relation_link",
"osee_tx_details", "osee_txs");
+ @BeforeClass
+ public static void setUpOnce() throws Exception {
+ Operations.executeWorkAndCheckStatus(new PurgeUnusedBackingDataAndTransactions(NullOperationLogger.getSingleton()));
+ }
+
@org.junit.Test
public void testPurgeTransaction() throws Exception {
init();