Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-04-19 16:36:53 -0400
committerRyan D. Brooks2011-04-19 16:36:53 -0400
commit04251ce4c39c5df402c317aca5190951ec237271 (patch)
treefcb143a2788b64e3e098780285d0f0e643d173df /plugins/org.eclipse.osee.framework.skynet.core.test
parent3e531a33701e66f7af01f4ab52e3a825f3d32dee (diff)
downloadorg.eclipse.osee-04251ce4c39c5df402c317aca5190951ec237271.tar.gz
org.eclipse.osee-04251ce4c39c5df402c317aca5190951ec237271.tar.xz
org.eclipse.osee-04251ce4c39c5df402c317aca5190951ec237271.zip
refactor: Remove test methods from DbUtil
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core.test')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractPurgeTest.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPurgeTest.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AttributePurgeTest.java4
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/BranchPurgeTest.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeTransactionTest.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/mocks/DbTestUtil.java37
6 files changed, 52 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractPurgeTest.java
index a5aa27bd8b..04620590db 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractPurgeTest.java
@@ -16,7 +16,7 @@ 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.framework.skynet.core.mocks.DbTestUtil;
import org.eclipse.osee.support.test.util.TestUtil;
import org.junit.After;
import org.junit.AfterClass;
@@ -83,12 +83,12 @@ public abstract class AbstractPurgeTest {
protected void getPreTableCount() throws OseeCoreException {
// Count rows in tables prior to purge
- DbUtil.getTableRowCounts(preCreateArtifactsCount, getTables());
+ DbTestUtil.getTableRowCounts(preCreateArtifactsCount, getTables());
}
protected void getPostTableCount() throws OseeCoreException {
// Count rows and check that same as when began
- DbUtil.getTableRowCounts(postPurgeCount, getTables());
+ DbTestUtil.getTableRowCounts(postPurgeCount, getTables());
}
public abstract void runPurgeOperation() throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPurgeTest.java
index 2326f186e3..c6b9422705 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPurgeTest.java
@@ -10,18 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-
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.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.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
@@ -59,7 +57,7 @@ public class ArtifactPurgeTest extends AbstractPurgeTest {
}
// Count rows and check that increased
- DbUtil.getTableRowCounts(postCreateArtifactsCount, getTables());
+ DbTestUtil.getTableRowCounts(postCreateArtifactsCount, getTables());
TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
new PurgeArtifacts(softArts).execute();
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AttributePurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AttributePurgeTest.java
index caa1f7278d..f86de55400 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AttributePurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/AttributePurgeTest.java
@@ -23,9 +23,9 @@ 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.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.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
@@ -60,7 +60,7 @@ public class AttributePurgeTest extends AbstractPurgeTest {
}
// Count rows and check that increased
- DbUtil.getTableRowCounts(postCreateArtifactsCount, tables);
+ DbTestUtil.getTableRowCounts(postCreateArtifactsCount, tables);
TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
Set<Attribute<?>> attributesToPurge = new HashSet<Attribute<?>>();
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 24b9faee34..68256ff31f 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
@@ -11,21 +11,19 @@
package org.eclipse.osee.framework.skynet.core.artifact;
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.data.SystemUser;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.UserManager;
+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.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
import org.junit.After;
@@ -56,7 +54,7 @@ public class BranchPurgeTest {
@org.junit.Test
public void testPurgeBranch() throws Exception {
// Count rows in tables prior to purge
- DbUtil.getTableRowCounts(preCreateCount, tables);
+ DbTestUtil.getTableRowCounts(preCreateCount, tables);
// create a new working branch
Branch branch =
@@ -82,7 +80,7 @@ public class BranchPurgeTest {
}
// Count rows and check that increased
- DbUtil.getTableRowCounts(postCreateBranchCount, tables);
+ DbTestUtil.getTableRowCounts(postCreateBranchCount, tables);
TestUtil.checkThatIncreased(preCreateCount, postCreateBranchCount);
// Purge branch
@@ -91,7 +89,7 @@ public class BranchPurgeTest {
TestUtil.sleep(4000);
// Count rows and check that same as when began
- DbUtil.getTableRowCounts(postPurgeCount, tables);
+ DbTestUtil.getTableRowCounts(postPurgeCount, tables);
// TODO looks like artifacts are not being removed when purge a branch
TestUtil.checkThatEqual(preCreateCount, postPurgeCount);
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 1cc5b1aa35..61a5b420f6 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
@@ -11,13 +11,11 @@
package org.eclipse.osee.framework.skynet.core.artifact;
import static org.junit.Assert.assertEquals;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
@@ -27,9 +25,9 @@ import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.test.mocks.Asserts;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
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.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
@@ -76,7 +74,7 @@ public class PurgeTransactionTest {
}
private void createArtifacts() throws Exception {
- DbUtil.getTableRowCounts(preCreateCount, tables);
+ DbTestUtil.getTableRowCounts(preCreateCount, tables);
createTransaction = new SkynetTransaction(branch, "Purge Transaction Test");
softArts =
FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, getClass().getSimpleName(),
@@ -89,7 +87,7 @@ public class PurgeTransactionTest {
}
private void modifyArtifacts() throws Exception {
- DbUtil.getTableRowCounts(preModifyCount, tables);
+ DbTestUtil.getTableRowCounts(preModifyCount, tables);
modifyTransaction = new SkynetTransaction(branch, "Purge Transaction Test");
for (Artifact softArt : softArts) {
softArt.addAttribute(CoreAttributeTypes.StaticId, getClass().getSimpleName());
@@ -103,7 +101,7 @@ public class PurgeTransactionTest {
IOperation operation =
new PurgeTransactionOperation(Activator.getInstance().getOseeDatabaseService(), true, transactionId);
Asserts.testOperation(operation, IStatus.OK);
- DbUtil.getTableRowCounts(dbCount, tables);
+ DbTestUtil.getTableRowCounts(dbCount, tables);
}
private int getCurrentRows() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/mocks/DbTestUtil.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/mocks/DbTestUtil.java
new file mode 100644
index 0000000000..dca11afc27
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/mocks/DbTestUtil.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.mocks;
+
+import java.util.Collection;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+
+/**
+ * @author Donald G. Dunne
+ */
+public final class DbTestUtil {
+
+ private DbTestUtil() {
+ // Utility Class - class should only have static methods
+ }
+
+ public static void getTableRowCounts(Map<String, Integer> tableCount, Collection<String> tableNames) throws OseeCoreException {
+ for (String tableName : tableNames) {
+ tableCount.put(tableName, getTableRowCount(tableName));
+ }
+ }
+
+ private static int getTableRowCount(String tableName) throws OseeCoreException {
+ return ConnectionHandler.runPreparedQueryFetchInt(0, "SELECT count(1) FROM " + tableName);
+ }
+
+}

Back to the top