Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2011-06-02 18:28:50 +0000
committerRyan D. Brooks2011-06-02 18:28:50 +0000
commitb8963787d44b6164900308c18dd507fb1a940042 (patch)
treea6288659f977f8bd76ea7861202e86b58ab8a179 /plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse
parent8b7d51e5cabfc70416464b8cb894a6c8f9d24221 (diff)
downloadorg.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.tar.gz
org.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.tar.xz
org.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.zip
refactor[ats_LKP2X]: Make change to support attribute purge
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java98
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java79
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java68
4 files changed, 192 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
index 73279e8956c..37b2f27721a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.skynet.core.test;
import static org.junit.Assert.assertTrue;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
+import org.eclipse.osee.framework.skynet.core.test.artifact.AttributePurgeTest;
import org.eclipse.osee.framework.skynet.core.test.branch.BranchTestSuite;
import org.eclipse.osee.framework.skynet.core.test.cases.ArtifactLoaderTest;
import org.eclipse.osee.framework.skynet.core.test.cases.ArtifactPurgeTest;
@@ -56,6 +57,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
ReplaceWithAttributeTest.class,
+ AttributePurgeTest.class,
CrossBranchLinkTest.class,
UpdateBookmarkIdTest.class,
ArtifactEventFiltersTest.class,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java
new file mode 100644
index 00000000000..da5fadb3bc0
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.test.artifact;
+
+import static org.junit.Assert.assertFalse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
+import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
+import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
+ * and txs tables, creating artifacts, changing them and then purging them. If it works properly, all rows should be
+ * equal.
+ *
+ * @author Jeff C. Phillips
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractPurgeTest {
+
+ private static SevereLoggingMonitor monitorLog;
+ protected Map<String, Integer> preCreateArtifactsCount;
+ protected Map<String, Integer> postCreateArtifactsCount;
+ protected Map<String, Integer> postPurgeCount;
+
+ @BeforeClass
+ public static void testInitialize() throws Exception {
+ monitorLog = TestUtil.severeLoggingStart();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // This test should only be run on test db
+ assertFalse(TestUtil.isProductionDb());
+ preCreateArtifactsCount = new HashMap<String, Integer>();
+ postCreateArtifactsCount = new HashMap<String, Integer>();
+ postPurgeCount = new HashMap<String, Integer>();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (preCreateArtifactsCount != null) {
+ preCreateArtifactsCount.clear();
+ preCreateArtifactsCount = null;
+ }
+ if (postCreateArtifactsCount != null) {
+ postCreateArtifactsCount.clear();
+ postCreateArtifactsCount = null;
+ }
+ if (postPurgeCount != null) {
+ postPurgeCount.clear();
+ postPurgeCount = null;
+ }
+ }
+
+ @AfterClass
+ public static void testCleanup() throws Exception {
+ TestUtil.severeLoggingEnd(monitorLog);
+ }
+
+ @org.junit.Test
+ public void testPurge() throws Exception {
+ runPurgeOperation();
+
+ // TODO Looks like attributes created after initial artifact creation are not getting purged. Needs Fix.
+ TestUtil.checkThatEqual(preCreateArtifactsCount, postPurgeCount);
+ }
+
+ protected void getPreTableCount() throws OseeCoreException {
+ // Count rows in tables prior to purge
+ DbUtil.getTableRowCounts(preCreateArtifactsCount, getTables());
+ }
+
+ protected void getPostTableCount() throws OseeCoreException {
+ // Count rows and check that same as when began
+ DbUtil.getTableRowCounts(postPurgeCount, getTables());
+ }
+
+ public abstract void runPurgeOperation() throws OseeCoreException;
+
+ public abstract List<String> getTables();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java
new file mode 100644
index 00000000000..74f7774a817
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.test.artifact;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeAttribute;
+import org.eclipse.osee.framework.skynet.core.test.util.FrameworkTestUtil;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
+import org.eclipse.osee.support.test.util.DemoSawBuilds;
+import org.eclipse.osee.support.test.util.TestUtil;
+
+/**
+ * This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
+ * and txs tables, creating artifacts, changing them and then purging them. If it works properly, all rows should be
+ * equal.
+ *
+ * @author Jeff C. Phillips
+ */
+public class AttributePurgeTest extends AbstractPurgeTest {
+ private static final List<String> tables = Arrays.asList("osee_attribute", "osee_txs");
+
+ @Override
+ public void runPurgeOperation() throws OseeCoreException {
+ // Create some software artifacts
+ Branch branch = BranchManager.getBranch(DemoSawBuilds.SAW_Bld_2.getName());
+ SkynetTransaction transaction = new SkynetTransaction(branch, "Test purge artifacts");
+ Collection<Artifact> softArts =
+ FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, getClass().getSimpleName(),
+ branch);
+ for (Artifact softArt : softArts) {
+ softArt.persist(transaction);
+ }
+ transaction.execute();
+
+ getPreTableCount();
+ // make more changes to artifacts
+ for (Artifact softArt : softArts) {
+ softArt.addAttribute(CoreAttributeTypes.StaticId, getClass().getSimpleName());
+ softArt.persist();
+ }
+
+ // Count rows and check that increased
+ DbUtil.getTableRowCounts(postCreateArtifactsCount, tables);
+ TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
+
+ Set<Attribute<?>> attributesToPurge = new HashSet<Attribute<?>>();
+ for (Artifact softArt : softArts) {
+ attributesToPurge.addAll(softArt.getAttributes(CoreAttributeTypes.StaticId));
+ }
+ new PurgeAttribute(attributesToPurge).execute();
+
+ getPostTableCount();
+ }
+
+ @Override
+ public List<String> getTables() {
+ return tables;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
index 1b7a5a4f8fa..751619e8085 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
@@ -10,28 +10,22 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.test.cases;
-import static org.junit.Assert.assertFalse;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
+import org.eclipse.osee.framework.skynet.core.test.artifact.AbstractPurgeTest;
import org.eclipse.osee.framework.skynet.core.test.util.FrameworkTestUtil;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
/**
* This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
@@ -40,55 +34,14 @@ import org.junit.BeforeClass;
*
* @author Donald G. Dunne
*/
-public class ArtifactPurgeTest {
-
- private static SevereLoggingMonitor monitorLog;
- private Map<String, Integer> preCreateArtifactsCount;
- private Map<String, Integer> postCreateArtifactsCount;
- private Map<String, Integer> postPurgeCount;
-
+public class ArtifactPurgeTest extends AbstractPurgeTest {
private static final List<String> tables = Arrays.asList("osee_attribute", "osee_artifact", "osee_relation_link",
"osee_tx_details", "osee_txs");
- @BeforeClass
- public static void testInitialize() throws Exception {
- monitorLog = TestUtil.severeLoggingStart();
- }
-
- @Before
- public void setUp() throws Exception {
- // This test should only be run on test db
- assertFalse(TestUtil.isProductionDb());
- preCreateArtifactsCount = new HashMap<String, Integer>();
- postCreateArtifactsCount = new HashMap<String, Integer>();
- postPurgeCount = new HashMap<String, Integer>();
- }
-
- @After
- public void tearDown() throws Exception {
- if (preCreateArtifactsCount != null) {
- preCreateArtifactsCount.clear();
- preCreateArtifactsCount = null;
- }
- if (postCreateArtifactsCount != null) {
- postCreateArtifactsCount.clear();
- postCreateArtifactsCount = null;
- }
- if (postPurgeCount != null) {
- postPurgeCount.clear();
- postPurgeCount = null;
- }
- }
-
- @AfterClass
- public static void testCleanup() throws Exception {
- TestUtil.severeLoggingEnd(monitorLog);
- }
-
- @org.junit.Test
- public void testPurgeArtifacts() throws Exception {
+ @Override
+ public void runPurgeOperation() throws OseeCoreException {
// Count rows in tables prior to purge
- DbUtil.getTableRowCounts(preCreateArtifactsCount, tables);
+ getPostTableCount();
// Create some software artifacts
Branch branch = BranchManager.getBranch(DemoSawBuilds.SAW_Bld_2.getName());
@@ -108,16 +61,21 @@ public class ArtifactPurgeTest {
}
// Count rows and check that increased
- DbUtil.getTableRowCounts(postCreateArtifactsCount, tables);
+ DbUtil.getTableRowCounts(postCreateArtifactsCount, getTables());
TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
new PurgeArtifacts(softArts).execute();
// Count rows and check that same as when began
- DbUtil.getTableRowCounts(postPurgeCount, tables);
+ getPostTableCount();
// TODO Looks like attributes created after initial artifact creation are not getting purged. Needs Fix.
TestUtil.checkThatEqual(preCreateArtifactsCount, postPurgeCount);
}
+ @Override
+ public List<String> getTables() {
+ return tables;
+ }
+
}

Back to the top