summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-06-17 02:11:34 (EDT)
committerRyan D. Brooks2011-06-17 02:11:34 (EDT)
commitd9660c717c3ae4213efac1e48314400cdb40a20a (patch)
tree3e99bc056be8dcf56e6440fea32d5022b03bd683
parentc8f3fdb89e4a3af16c8848e8ded9c8401945f452 (diff)
downloadorg.eclipse.osee-d9660c717c3ae4213efac1e48314400cdb40a20a.zip
org.eclipse.osee-d9660c717c3ae4213efac1e48314400cdb40a20a.tar.gz
org.eclipse.osee-d9660c717c3ae4213efac1e48314400cdb40a20a.tar.bz2
bug: Fixes for test failures on 0.9.9_dev
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/ArtifactTestUnitStoreTest.java4
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/DirtyArtifactCacheTest.java23
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/NativeArtifactTest.java39
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationDeletionTest.java22
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationOrderingTest.java8
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/ArtifactEventTest.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/BranchEventTest.java188
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/relation/order/RelationOrderMergeUtilityTest.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/rule/OseeHousekeepingRule.java59
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/CsvArtifactTest.java20
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactCache.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/DeleteBranchOperation.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java3
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/PreviewAndMultiPreviewTest.java280
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/widgets/workflow/WorkPageAdapterTest.java21
19 files changed, 365 insertions, 343 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
index 355d72c..1a83a30 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
@@ -41,6 +41,7 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.messaging.event.res.test,
org.eclipse.osee.framework.skynet.core,
org.eclipse.osee.framework.skynet.core.artifact,
+ org.eclipse.osee.framework.skynet.core.rule,
org.eclipse.osee.framework.ui.plugin.xnavigate,
org.eclipse.osee.framework.ui.skynet.render,
org.eclipse.osee.framework.ui.skynet.test,
diff --git a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/ArtifactTestUnitStoreTest.java b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/ArtifactTestUnitStoreTest.java
index f11afe7..88aa2d1 100644
--- a/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/ArtifactTestUnitStoreTest.java
+++ b/plugins/org.eclipse.osee.coverage.test/src/org/eclipse/osee/coverage/test/store/ArtifactTestUnitStoreTest.java
@@ -36,7 +36,7 @@ import org.junit.Test;
public class ArtifactTestUnitStoreTest {
private static final String testInputData = "1|test1\n2|test2\n3|test3";
- Branch testBranch;
+ private Branch testBranch;
private static final String testArtifactGuid = "AEas7qndRl+k+g6YpkwA";
private CoverageItem createCoverageItem(TestUnitCache tc) throws OseeCoreException {
@@ -93,7 +93,5 @@ public class ArtifactTestUnitStoreTest {
String actual = testArtifact.getSoleAttributeValueAsString(CoreAttributeTypes.GeneralStringData, "");
String expected = testInputData + "\n4|test10";
Assert.assertEquals(expected, actual);
-
}
-
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
index ec64248..c48a2f6 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Export-Package: org.eclipse.osee.framework.skynet.core,
org.eclipse.osee.framework.skynet.core.relation.order,
org.eclipse.osee.framework.skynet.core.relation.sorters,
org.eclipse.osee.framework.skynet.core.revision,
+ org.eclipse.osee.framework.skynet.core.rule,
org.eclipse.osee.framework.skynet.core.transaction,
org.eclipse.osee.framework.skynet.core.util,
org.eclipse.osee.framework.skynet.core.utility,
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 e09976e..d2a86c8 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
@@ -1,11 +1,19 @@
-/*
- * Created on May 17, 2011
+/*******************************************************************************
+ * Copyright (c) 2011 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
*
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact;
+import java.util.Collection;
+import java.util.logging.Level;
import junit.framework.Assert;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
/**
@@ -17,8 +25,13 @@ 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(ArtifactCache.getDirtyArtifacts())), ArtifactCache.getDirtyArtifacts().isEmpty());
+ Artifacts.getNames(dirtyArtifacts)), dirtyArtifacts.isEmpty());
+ for (Artifact artifact : dirtyArtifacts) {
+ OseeLog.format(getClass(), Level.WARNING, "Name: %s Type: %s ", artifact.getName(),
+ artifact.getArtifactTypeName());
+ }
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/NativeArtifactTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/NativeArtifactTest.java
index f87a851..22641c9 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/NativeArtifactTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/NativeArtifactTest.java
@@ -11,19 +11,19 @@
package org.eclipse.osee.framework.skynet.core.artifact;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.utility.CsvArtifact;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.junit.AfterClass;
@@ -34,18 +34,24 @@ import org.junit.BeforeClass;
*/
public class NativeArtifactTest {
+ private final static String ARTIFACT_NAME = NativeArtifactTest.class.getSimpleName();
+ private final static Set<Artifact> testArtifacts = new HashSet<Artifact>();
+
@BeforeClass
@AfterClass
public static void cleanup() throws Exception {
- Collection<Artifact> arts =
- ArtifactQuery.getArtifactListFromName(NativeArtifactTest.class.getSimpleName(), DemoSawBuilds.SAW_Bld_2,
- EXCLUDE_DELETED);
- new PurgeArtifacts(arts).execute();
+ new PurgeArtifacts(testArtifacts).execute();
+ }
+
+ @org.junit.Test
+ public void testGetFileExtension() throws Exception {
+ Artifact nativeArtifact = getNativeArtifact();
+ assertTrue(nativeArtifact.getSoleAttributeValue(CoreAttributeTypes.Extension, "").equals("csv"));
}
@org.junit.Test
public void testNativeArtifact() throws Exception {
- CsvArtifact csvArtifact = CsvArtifact.getCsvArtifact(getClass().getSimpleName(), DemoSawBuilds.SAW_Bld_2, true);
+ CsvArtifact csvArtifact = getCsvArtifact(true);
assertNotNull(csvArtifact);
Artifact artifact = csvArtifact.getArtifact();
assertTrue(artifact.isAttributeTypeValid(CoreAttributeTypes.NativeContent));
@@ -53,12 +59,6 @@ public class NativeArtifactTest {
}
@org.junit.Test
- public void testGetFileExtension() throws Exception {
- Artifact nativeArtifact = getNativeArtifact();
- assertTrue(nativeArtifact.getSoleAttributeValue(CoreAttributeTypes.Extension, "").equals("csv"));
- }
-
- @org.junit.Test
public void testSetAndGetValueAsString() throws Exception {
Artifact nativeArtifact = getNativeArtifact();
nativeArtifact.setSoleAttributeFromString(CoreAttributeTypes.NativeContent, "hello world");
@@ -84,8 +84,13 @@ public class NativeArtifactTest {
}
}
- private Artifact getNativeArtifact() throws Exception {
- return CsvArtifact.getCsvArtifact(getClass().getSimpleName(), DemoSawBuilds.SAW_Bld_2, false).getArtifact();
+ private Artifact getNativeArtifact() throws OseeCoreException {
+ return getCsvArtifact(false).getArtifact();
}
-}
+ private CsvArtifact getCsvArtifact(boolean create) throws OseeCoreException {
+ CsvArtifact csvArtifact = CsvArtifact.getCsvArtifact(ARTIFACT_NAME, DemoSawBuilds.SAW_Bld_2, create);
+ testArtifacts.add(csvArtifact.getArtifact());
+ return csvArtifact;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationDeletionTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationDeletionTest.java
index 3484d46..18b8e8a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationDeletionTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationDeletionTest.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.skynet.core.artifact;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.IArtifactType;
@@ -21,20 +22,35 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
+import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.MethodRule;
/**
* @author Andrew M. Finkbeiner
*/
public class RelationDeletionTest {
+ private final List<Artifact> artifacts = new ArrayList<Artifact>();
+
+ @Rule
+ public MethodRule oseeHousekeepingRule = new OseeHousekeepingRule();
+
@Before
public void setUp() throws Exception {
// This test should only be run on test db
assertFalse(ClientSessionManager.isProductionDataStore());
}
- @org.junit.Test
+ @After
+ public void cleanUp() throws OseeCoreException {
+ new PurgeArtifacts(artifacts).execute();
+ }
+
+ @Test
public void testDeleteRelationPersistsBothSides() throws Exception {
SevereLoggingMonitor monitor = new SevereLoggingMonitor();
OseeLog.registerLoggerListener(monitor);
@@ -72,6 +88,8 @@ public class RelationDeletionTest {
}
private Artifact createArtifact(IArtifactType artifactType, Branch branch) throws OseeCoreException {
- return ArtifactTypeManager.addArtifact(artifactType, branch);
+ Artifact newArtifact = ArtifactTypeManager.addArtifact(artifactType, branch);
+ artifacts.add(newArtifact);
+ return newArtifact;
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationOrderingTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationOrderingTest.java
index 9357ceb..bd6a3d1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationOrderingTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/RelationOrderingTest.java
@@ -81,10 +81,10 @@ public class RelationOrderingTest {
@After
public void cleanupArtifacts() throws Exception {
- // parent.deleteAndPersist();
- // child1.deleteAndPersist();
- // child2.deleteAndPersist();
- // child3.deleteAndPersist();
+ for (Artifact artifact : new Artifact[] {parent, child1, child2, child3}) {
+ ArtifactCache.deCache(artifact);
+ artifact.deleteAndPersist();
+ }
}
@org.junit.Test
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/ArtifactEventTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/ArtifactEventTest.java
index e984a0b..ae73b1e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/ArtifactEventTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/ArtifactEventTest.java
@@ -189,7 +189,7 @@ public class ArtifactEventTest {
newArt.persist(getClass().getSimpleName());
Assert.assertEquals(2, resultEventArtifacts.size());
- Assert.assertEquals("No relations events should be sent", 0, resultEventRelations.size());
+ Assert.assertTrue("No relations events should be sent", resultEventRelations.isEmpty());
if (isRemoteTest()) {
Assert.assertTrue(resultSender.isRemote());
} else {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/BranchEventTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/BranchEventTest.java
index 4411f69..12a2c6f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/BranchEventTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/event/model/BranchEventTest.java
@@ -25,7 +25,9 @@ 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.core.operation.Operations;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -38,18 +40,20 @@ import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter;
import org.eclipse.osee.framework.skynet.core.event.listener.IBranchEventListener;
import org.eclipse.osee.framework.skynet.core.httpRequests.PurgeBranchHttpRequestOperation;
import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.AfterClass;
/**
* @author Donald G. Dunne
*/
public class BranchEventTest {
- private BranchEvent resultBranchEvent = null;
- private Sender resultSender = null;
public static List<String> ignoreLogging = Arrays.asList("");
private static String BRANCH_NAME_PREFIX = "BranchEventManagerTest";
+ private static String TOP_LEVEL_BRANCH_NAME = String.format("%s - top level branch", BRANCH_NAME_PREFIX);
private static Branch topLevel;
+ private final BranchEventListener branchEventListener = new BranchEventListener();
+
@org.junit.Test
public void testRegistration() throws Exception {
SevereLoggingMonitor monitorLog = TestUtil.severeLoggingStart();
@@ -66,7 +70,10 @@ public class BranchEventTest {
TestUtil.severeLoggingEnd(monitorLog);
}
- @org.junit.Test
+ /**
+ * If all branch tests take longer than 10seconds, fail test, something went wrong.
+ */
+ @org.junit.Test(timeout = 10000)
public void testEvents() throws Exception {
SevereLoggingMonitor monitorLog = TestUtil.severeLoggingStart();
OseeEventManager.removeAllListeners();
@@ -89,12 +96,12 @@ public class BranchEventTest {
TestUtil.severeLoggingEnd(monitorLog, (isRemoteTest() ? ignoreLogging : new ArrayList<String>()));
} finally {
OseeEventManager.getPreferences().setPendRunning(false);
+ OseeEventManager.removeListener(branchEventListener);
}
-
}
private Branch testEvents__changeArchiveState(Branch committedBranch) throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
Assert.assertNotNull(committedBranch);
final String guid = committedBranch.getGuid();
@@ -102,21 +109,16 @@ public class BranchEventTest {
BranchManager.updateBranchArchivedState(null, committedBranch.getId(), committedBranch.getGuid(),
BranchArchivedState.UNARCHIVED);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.ArchiveStateUpdated, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.ArchiveStateUpdated, guid);
+
Assert.assertEquals(BranchArchivedState.UNARCHIVED, committedBranch.getArchiveState());
Assert.assertFalse(committedBranch.isEditable());
return committedBranch;
}
private Branch testEvents__committed() throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - to commit", UserManager.getUser());
@@ -129,21 +131,16 @@ public class BranchEventTest {
ConflictManagerExternal conflictManager = new ConflictManagerExternal(topLevel, workingBranch);
BranchManager.commitBranch(null, conflictManager, true, true);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Committed, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.Committed, guid);
+
Assert.assertEquals(BranchState.COMMITTED, workingBranch.getBranchState());
Assert.assertFalse(workingBranch.isEditable());
return workingBranch;
}
private Branch testEvents__purged() throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - to purge", UserManager.getUser());
@@ -154,14 +151,8 @@ public class BranchEventTest {
Operations.executeWorkAndCheckStatus(new PurgeBranchHttpRequestOperation(workingBranch, false));
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Purged, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.Purged, guid);
+
Assert.assertEquals(BranchState.CREATED, workingBranch.getBranchState());
Assert.assertEquals(StorageState.PURGED, workingBranch.getStorageState());
Assert.assertFalse(workingBranch.isEditable());
@@ -175,150 +166,143 @@ public class BranchEventTest {
}
private Branch testEvents__deleted(Branch workingBranch) throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
final String guid = workingBranch.getGuid();
Assert.assertNotNull(workingBranch);
Assert.assertNotSame(BranchState.DELETED, workingBranch.getBranchState());
Operations.executeWork(new DeleteBranchOperation(workingBranch));
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Deleted, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.Deleted, guid);
+
Assert.assertEquals(BranchState.DELETED, workingBranch.getBranchState());
return workingBranch;
}
private Branch testEvents__stateChange(Branch workingBranch) throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
final String guid = workingBranch.getGuid();
Assert.assertNotNull(workingBranch);
Assert.assertEquals(BranchState.CREATED, workingBranch.getBranchState());
BranchManager.updateBranchState(null, workingBranch.getId(), workingBranch.getGuid(), BranchState.MODIFIED);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.StateUpdated, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.StateUpdated, guid);
+
Assert.assertEquals(BranchState.MODIFIED, workingBranch.getBranchState());
return workingBranch;
}
private Branch testEvents__typeChange(Branch workingBranch) throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
final String guid = workingBranch.getGuid();
Assert.assertNotNull(workingBranch);
Assert.assertEquals(BranchType.WORKING, workingBranch.getBranchType());
BranchManager.updateBranchType(null, workingBranch.getId(), workingBranch.getGuid(), BranchType.BASELINE);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.TypeUpdated, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.TypeUpdated, guid);
+
Assert.assertEquals(BranchType.BASELINE, workingBranch.getBranchType());
return workingBranch;
}
private Branch testEvents__workingRenamed(Branch workingBranch) throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
final String guid = workingBranch.getGuid();
Assert.assertNotNull(workingBranch);
String newName = BRANCH_NAME_PREFIX + " - working renamed";
workingBranch.setName(newName);
BranchManager.persist(workingBranch);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Renamed, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
+ verifyReceivedBranchStates(BranchEventType.Renamed, guid);
+
Assert.assertEquals(newName, workingBranch.getName());
Assert.assertNotNull(BranchManager.getBranchesByName(newName));
return workingBranch;
}
private Branch testEvents__workingAdded() throws Exception {
- clearEventCollections();
+ branchEventListener.reset();
+
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - working", UserManager.getUser());
Assert.assertNotNull(workingBranch);
- Thread.sleep(4000);
+ verifyReceivedBranchStates(BranchEventType.Added, null);
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Added, resultBranchEvent.getEventType());
- if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
- } else {
- Assert.assertTrue(resultSender.isLocal());
- }
return workingBranch;
}
private Branch testEvents__topLevelAdded() throws Exception {
- clearEventCollections();
- final String guid = GUID.create();
- final String branchName = String.format("%s - top level branch", BRANCH_NAME_PREFIX);
+ branchEventListener.reset();
+
+ String guid = GUID.create();
+ String branchName = TOP_LEVEL_BRANCH_NAME;
IOseeBranch branchToken = TokenFactory.createBranch(guid, branchName);
topLevel = BranchManager.createTopLevelBranch(branchToken);
Assert.assertNotNull(topLevel);
- Thread.sleep(2000);
+ verifyReceivedBranchStates(BranchEventType.Added, guid);
+
+ return topLevel;
+ }
- Assert.assertNotNull(resultBranchEvent);
- Assert.assertEquals(BranchEventType.Added, resultBranchEvent.getEventType());
+ private void verifyReceivedBranchStates(BranchEventType expectedEnumState, String expectedBranchGuid) throws InterruptedException {
+ Pair<Sender, BranchEvent> update = branchEventListener.getResults();
+ Sender receivedSender = update.getFirst();
+ BranchEvent receivedBranchEvent = update.getSecond();
+
+ Assert.assertEquals(expectedEnumState, receivedBranchEvent.getEventType());
if (isRemoteTest()) {
- Assert.assertTrue(resultSender.isRemote());
+ Assert.assertTrue(receivedSender.isRemote());
} else {
- Assert.assertTrue(resultSender.isLocal());
+ Assert.assertTrue(receivedSender.isLocal());
+ }
+
+ if (Strings.isValid(expectedBranchGuid)) {
+ Assert.assertEquals(expectedBranchGuid, receivedBranchEvent.getBranchGuid());
}
- Assert.assertEquals(guid, resultBranchEvent.getBranchGuid());
- return topLevel;
}
protected boolean isRemoteTest() {
return false;
}
- public class BranchEventListener implements IBranchEventListener {
+ @AfterClass
+ public static void cleanUp() throws OseeCoreException {
+ Operations.executeWorkAndCheckStatus(new PurgeBranchHttpRequestOperation(topLevel, true));
+ }
+
+ private class BranchEventListener implements IBranchEventListener {
+ private BranchEvent branchEvent;
+ private Sender sender;
+ private boolean receivedUpdate = false;
- @Override
- public void handleBranchEvent(Sender sender, BranchEvent branchEvent) {
- resultBranchEvent = branchEvent;
- resultSender = sender;
+ public synchronized void reset() {
+ receivedUpdate = false;
}
@Override
public List<? extends IEventFilter> getEventFilters() {
return null;
}
- }
- @org.junit.AfterClass
- public static void cleanUpAfter() throws OseeCoreException {
- Operations.executeWorkAndCheckStatus(new PurgeBranchHttpRequestOperation(topLevel, true));
- }
-
- // artifact listener create for use by all tests to just capture result eventArtifacts for query
- private final BranchEventListener branchEventListener = new BranchEventListener();
+ @Override
+ public synchronized void handleBranchEvent(Sender sender, BranchEvent branchEvent) {
+ this.branchEvent = branchEvent;
+ this.sender = sender;
+ receivedUpdate = true;
+ notify();
+ }
- public void clearEventCollections() {
- resultBranchEvent = null;
- }
+ public synchronized Pair<Sender, BranchEvent> getResults() throws InterruptedException {
+ while (!receivedUpdate) {
+ wait();
+ }
+ receivedUpdate = false;
+ return new Pair<Sender, BranchEvent>(sender, branchEvent);
+ }
+ };
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/relation/order/RelationOrderMergeUtilityTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/relation/order/RelationOrderMergeUtilityTest.java
index f644bb2..66c99ac 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/relation/order/RelationOrderMergeUtilityTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/relation/order/RelationOrderMergeUtilityTest.java
@@ -27,16 +27,23 @@ 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.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.MethodRule;
/**
* @author Ryan Schmitt
*/
public class RelationOrderMergeUtilityTest {
+
+ @Rule
+ public final MethodRule oseeHousekeeping = new OseeHousekeepingRule();
+
private final IRelationTypeSide defaultHierarchy = CoreRelationTypes.Default_Hierarchical__Child;
private final IRelationSorterId ascOrder = RelationOrderBaseTypes.LEXICOGRAPHICAL_ASC;
private final IRelationSorterId descOrder = RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC;
@@ -48,8 +55,7 @@ public class RelationOrderMergeUtilityTest {
@Before
public void createBranch() throws OseeCoreException {
- String branchName = GUID.create();
- destBranch = BranchManager.createWorkingBranch(BranchManager.getSystemRootBranch(), branchName, null);
+ destBranch = BranchManager.createWorkingBranch(BranchManager.getSystemRootBranch(), GUID.create(), null);
hierType = RelationTypeManager.getType(defaultHierarchy);
hierSide = defaultHierarchy.getSide();
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/rule/OseeHousekeepingRule.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/rule/OseeHousekeepingRule.java
new file mode 100644
index 0000000..b1803f4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/rule/OseeHousekeepingRule.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.rule;
+
+import java.util.Collection;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
+
+/**
+ * <p>
+ * Not related to {@link Rule}.
+ * </p>
+ * <p>
+ * Checks Artifact Cache for dirty artifacts. Executes after a passing test. Fails tests that have passed but left dirty
+ * artifacts in the cache.
+ * </p>
+ * <p>
+ * In the future the behavior of this class could be modified to clean up after a test, regardless of test's context.
+ * </p>
+ */
+public class OseeHousekeepingRule implements MethodRule {
+
+ @Override
+ public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ base.evaluate();
+ verify(method, target);
+ }
+ };
+ }
+
+ private void verify(FrameworkMethod method, Object target) throws Throwable {
+ final Collection<Artifact> dirtyArtifacts = ArtifactCache.getDirtyArtifacts();
+
+ if (!dirtyArtifacts.isEmpty()) {
+ StringBuilder entireMessage = new StringBuilder();
+ entireMessage.append("Dirty artifacts in Artifact Cache:");
+ for (Artifact artifact : dirtyArtifacts) {
+ entireMessage.append(String.format("\n[%s] of type [%s] found while executing: %s.%s()",
+ artifact.getName(), artifact.getArtifactType(), target.getClass().getSimpleName(), method.getName()));
+ }
+ Assert.fail(entireMessage.toString());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/CsvArtifactTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/CsvArtifactTest.java
index c2cd97e..2caf239 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/CsvArtifactTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/CsvArtifactTest.java
@@ -31,16 +31,20 @@ public class CsvArtifactTest {
private static String csvData = "Name, Value1, Value2\narf,1,3\nbarn,3,5";
private static String appendData = "snarf,6,3";
+ private static CsvArtifact csv;
+
@BeforeClass
@AfterClass
public static void cleanup() throws Exception {
+ if (csv == null) {
+ csv = CsvArtifact.getCsvArtifact(id, DemoSawBuilds.SAW_Bld_2, true);
+ }
Collection<Artifact> arts = ArtifactQuery.getArtifactListFromName(id, DemoSawBuilds.SAW_Bld_2, EXCLUDE_DELETED);
new PurgeArtifacts(arts).execute();
}
@org.junit.Test
public void testCreateCsvArtifact() throws Exception {
- CsvArtifact csv = CsvArtifact.getCsvArtifact(id, DemoSawBuilds.SAW_Bld_2, true);
assertEquals(csv.getCsvData(), "");
csv.getArtifact().setName(id);
csv.setCsvData(csvData);
@@ -49,18 +53,16 @@ public class CsvArtifactTest {
@org.junit.Test
public void testgetCsvArtifactAndAppendData() throws Exception {
- CsvArtifact csvArt = CsvArtifact.getCsvArtifact(id, DemoSawBuilds.SAW_Bld_2, false);
- assertNotNull(csvArt);
- assertEquals(csvData, csvArt.getCsvData());
- csvArt.appendData(appendData);
- csvArt.getArtifact().persist(getClass().getSimpleName());
+ assertNotNull(csv);
+ assertEquals(csvData, csv.getCsvData());
+ csv.appendData(appendData);
+ csv.getArtifact().persist(getClass().getSimpleName());
}
@org.junit.Test
public void testCsvGetData() throws Exception {
- CsvArtifact csvArt = CsvArtifact.getCsvArtifact(id, DemoSawBuilds.SAW_Bld_2, false);
- assertNotNull(csvArt);
- assertEquals(csvData + "\n" + appendData, csvArt.getCsvData());
+ assertNotNull(csv);
+ assertEquals(csvData + "\n" + appendData, csv.getCsvData());
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactCache.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactCache.java
index 8b00140..305b554 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactCache.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactCache.java
@@ -59,6 +59,24 @@ public final class ArtifactCache {
cache.deCache(artifact);
}
+ /**
+ * <p>
+ * De-caches all artifacts from <code>HISTORICAL_CACHE</code> and <code>ACTIVE_CACHE</code> for a specific branch.
+ * This method is usually called by a purge operation or at the end of a unit test/suite.
+ * </p>
+ *
+ * @param branch of which artifacts (all) will be de-cache'ed.
+ */
+ public static void deCache(IOseeBranch branch) {
+ for (AbstractArtifactCache cache : new AbstractArtifactCache[] {HISTORICAL_CACHE, ACTIVE_CACHE}) {
+ for (Artifact artifact : cache.getAll()) {
+ if (artifact.getBranch().equals(branch)) {
+ cache.deCache(artifact);
+ }
+ }
+ }
+ }
+
public static List<Artifact> getArtifactsByName(IArtifactType artifactType, String name) {
List<Artifact> arts = new ArrayList<Artifact>();
for (Artifact artifact : getArtifactsByType(artifactType)) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/DeleteBranchOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/DeleteBranchOperation.java
index bf2817e..d55040a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/DeleteBranchOperation.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/DeleteBranchOperation.java
@@ -36,6 +36,9 @@ public class DeleteBranchOperation extends AbstractOperation {
Branch branch = BranchManager.getBranch(this.branch);
BranchState originalState = branch.getBranchState();
BranchArchivedState originalArchivedState = branch.getArchiveState();
+
+ ArtifactCache.deCache(this.branch);
+
try {
branch.setBranchState(BranchState.DELETED);
branch.setArchived(true);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
index b7537d6..e0a2c55 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
@@ -23,6 +23,7 @@ import org.eclipse.osee.framework.core.message.PurgeBranchRequest;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.HttpClientMessage;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
@@ -51,6 +52,8 @@ public final class PurgeBranchHttpRequestOperation extends AbstractOperation {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("function", Function.PURGE_BRANCH.name());
+ ArtifactCache.deCache(branch);
+
AcquireResult response =
HttpClientMessage.send(OseeServerContext.BRANCH_CONTEXT, parameters, CoreTranslatorId.PURGE_BRANCH_REQUEST,
requestData, null);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java
index 82a1939..d7ef0ad 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java
@@ -23,6 +23,7 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
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.relation.order.RelationOrderData;
@@ -88,6 +89,7 @@ public class ArtifactPasteOperationTest {
private static void delete(Artifact artifact) throws OseeCoreException {
if (artifact != null) {
+ ArtifactCache.deCache(artifact);
artifact.deleteAndPersist();
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/PreviewAndMultiPreviewTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/PreviewAndMultiPreviewTest.java
index c0cb0ed..9e88ce3 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/PreviewAndMultiPreviewTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/PreviewAndMultiPreviewTest.java
@@ -10,21 +10,20 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.test.cases;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
-
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.logging.IHealthStatus;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
-import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
@@ -37,39 +36,48 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.MethodRule;
/**
* @author Megumi Telles
*/
public class PreviewAndMultiPreviewTest {
+ @Rule
+ public MethodRule oseeHousekeepingRule = new OseeHousekeepingRule();
+
private static final IOseeBranch BRANCH = DemoSawBuilds.SAW_Bld_1;
+ private static SevereLoggingMonitor monitorLog;
+
+ private static List<Artifact> testArtifacts = new ArrayList<Artifact>();
+
@BeforeClass
- public static void testSetUp() throws OseeCoreException {
+ public static void setUpOnce() throws OseeCoreException {
Assert.assertFalse("Not to be run on production datbase.", TestUtil.isProductionDb());
RenderingUtil.setPopupsAllowed(false);
}
@Before
public void setUp() throws Exception {
- cleanup();
+ monitorLog = TestUtil.severeLoggingStart();
}
@After
public void tearDown() throws Exception {
- cleanup();
- }
-
- private void cleanup() throws Exception {
- SevereLoggingMonitor monitorLog = TestUtil.severeLoggingStart();
- FrameworkTestUtil.cleanupSimpleTest(BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
+ Assert.assertTrue(monitorLog.getLogsAtLevel(Level.WARNING).isEmpty());
+ Assert.assertTrue(monitorLog.getLogsAtLevel(Level.SEVERE).isEmpty());
TestUtil.severeLoggingEnd(monitorLog);
+ new PurgeArtifacts(testArtifacts).execute();
+ testArtifacts.clear();
}
private static Artifact createArtifact(IArtifactType type, IOseeBranch branch, String name) throws OseeCoreException {
Artifact artifact = ArtifactTypeManager.addArtifact(type, branch, name);
Assert.assertNotNull(artifact);
+ testArtifacts.add(artifact);
return artifact;
}
@@ -77,245 +85,135 @@ public class PreviewAndMultiPreviewTest {
* Preview Requirements Artifact (includes a child artifact == general document but should not invoke a warning since
* only previewing (no recurse)).
*/
- @org.junit.Test
+ @Test
public void testPreview() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
+ Artifact parentArtifact =
+ createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1a"));
- parentArtifact.addChild(childArt);
+ Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1a"));
+ parentArtifact.addChild(childArt);
- parentArtifact.persist(getClass().getSimpleName());
+ parentArtifact.persist(getClass().getSimpleName());
- WordTemplateRenderer renderer = new WordTemplateRenderer();
- renderer.open(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
- }
- };
- template.test();
+ WordTemplateRenderer renderer = new WordTemplateRenderer();
+ renderer.open(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
}
- @org.junit.Test
+ @Test
public void testPreviewUsingRendererManager() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
+ Artifact parentArtifact =
+ createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact childArt = createArtifact(CoreArtifactTypes.GeneralDocument, BRANCH, addPrefix("1b"));
- parentArtifact.addChild(childArt);
+ Artifact childArt = createArtifact(CoreArtifactTypes.GeneralDocument, BRANCH, addPrefix("1b"));
+ parentArtifact.addChild(childArt);
- parentArtifact.persist(getClass().getSimpleName());
+ parentArtifact.persist(getClass().getSimpleName());
- RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
- }
- };
- template.test();
+ RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
}
/*
* Preview Requirements Artifact with valid children.
*/
- @org.junit.Test
+ @Test
public void testPreviewWithChildren() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
+ Artifact parentArtifact =
+ createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1c"));
- parentArtifact.addChild(childArt);
+ Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1c"));
+ parentArtifact.addChild(childArt);
- parentArtifact.persist(getClass().getSimpleName());
+ parentArtifact.persist(getClass().getSimpleName());
- RendererManager.open(parentArtifact, PresentationType.PREVIEW,
- ITemplateRenderer.PREVIEW_WITH_RECURSE_OPTION_PAIR);
- }
- };
- template.test();
+ RendererManager.open(parentArtifact, PresentationType.PREVIEW, ITemplateRenderer.PREVIEW_WITH_RECURSE_OPTION_PAIR);
}
- @org.junit.Test
+ @Test
public void testPreviewWithChildrenUsingRendererManager() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
-
- Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1d"));
- parentArtifact.addChild(childArt);
-
- parentArtifact.persist(getClass().getSimpleName());
-
- RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
- }
- };
- template.test();
- }
-
- @org.junit.Test
- public void testPreviewWithChildrenFault() throws Exception {
- SevereLoggingMonitor monitorLog = TestUtil.severeLoggingStart();
-
Artifact parentArtifact =
createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact childArt =
- createArtifact(CoreArtifactTypes.GeneralDocument, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName() + ".1e");
+ Artifact childArt = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1d"));
parentArtifact.addChild(childArt);
parentArtifact.persist(getClass().getSimpleName());
- RendererManager.open(parentArtifact, PresentationType.PREVIEW, ITemplateRenderer.PREVIEW_WITH_RECURSE_OPTION_PAIR);
-
- // should get one warning since the child is a general document
- Collection<IHealthStatus> warnings = monitorLog.getLogsAtLevel(Level.WARNING);
- Assert.assertEquals(Collections.toString(", ", warnings), 1, warnings.size());
-
- IHealthStatus status = warnings.iterator().next();
- String warningMsg = status.getMessage();
- Assert.assertTrue(warningMsg.contains("You chose to preview/edit artifacts that could not be handled"));
- Assert.assertEquals(0, TestUtil.getNumberOfLogsAtLevel(monitorLog, Level.SEVERE));
+ RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
}
/*
* No warning expected in this fault case because the Renderer Manager resolves which render to use to preview.
*/
- @org.junit.Test
+ @Test
public void testPreviewWithChildrenUsingRendererManagerFault() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
+ Artifact parentArtifact =
+ createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact childArt = createArtifact(CoreArtifactTypes.GeneralDocument, BRANCH, addPrefix("1f"));
- parentArtifact.addChild(childArt);
+ Artifact childArt = createArtifact(CoreArtifactTypes.GeneralDocument, BRANCH, addPrefix("1f"));
+ parentArtifact.addChild(childArt);
- parentArtifact.persist(getClass().getSimpleName());
+ parentArtifact.persist(getClass().getSimpleName());
- RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
- }
- };
- template.test();
+ RendererManager.openInJob(Arrays.asList(parentArtifact), PresentationType.PREVIEW);
}
/*
* Preview multiple Requirement Artifacts
*/
- @org.junit.Test
+ @Test
public void testMultiPreview() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact multiArt1 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("3z"));
- multiArt1.persist(getClass().getSimpleName());
- Artifact multiArt2 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("2y"));
- multiArt2.persist(getClass().getSimpleName());
- Artifact multiArt3 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1x"));
- multiArt3.persist(getClass().getSimpleName());
-
- WordTemplateRenderer renderer = new WordTemplateRenderer();
- List<Artifact> newMultiArts = Arrays.asList(multiArt1, multiArt2, multiArt3);
- renderer.open(newMultiArts, PresentationType.PREVIEW);
- }
- };
- template.test();
+ Artifact multiArt1 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("3z"));
+ multiArt1.persist(getClass().getSimpleName());
+ Artifact multiArt2 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("2y"));
+ multiArt2.persist(getClass().getSimpleName());
+ Artifact multiArt3 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1x"));
+ multiArt3.persist(getClass().getSimpleName());
+
+ WordTemplateRenderer renderer = new WordTemplateRenderer();
+ List<Artifact> newMultiArts = Arrays.asList(multiArt1, multiArt2, multiArt3);
+ renderer.open(newMultiArts, PresentationType.PREVIEW);
}
- @org.junit.Test
+ @Test
public void testMultiPreviewUsingRendererManager() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact parentArtifact =
- createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH,
- PreviewAndMultiPreviewTest.class.getSimpleName());
+ Artifact parentArtifact =
+ createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, PreviewAndMultiPreviewTest.class.getSimpleName());
- Artifact multiArt1 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("3o"));
- parentArtifact.addChild(multiArt1);
+ Artifact multiArt1 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("3o"));
+ parentArtifact.addChild(multiArt1);
- Artifact multiArt2 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("2n"));
- parentArtifact.addChild(multiArt2);
+ Artifact multiArt2 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("2n"));
+ parentArtifact.addChild(multiArt2);
- Artifact multiArt3 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1m"));
- parentArtifact.addChild(multiArt3);
+ Artifact multiArt3 = createArtifact(CoreArtifactTypes.SoftwareRequirement, BRANCH, addPrefix("1m"));
+ parentArtifact.addChild(multiArt3);
- parentArtifact.persist(getClass().getSimpleName());
+ parentArtifact.persist(getClass().getSimpleName());
- RendererManager.open(parentArtifact, PresentationType.PREVIEW);
- }
- };
- template.test();
+ RendererManager.open(parentArtifact, PresentationType.PREVIEW);
}
- /*
+ /**
* Preview a whole word doc
*/
- @org.junit.Test
+ @Test
public void testWholeWordPreview() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact art = createArtifact(CoreArtifactTypes.TestProcedureWML, BRANCH, addPrefix("4g"));
- art.persist(getClass().getSimpleName());
- WholeWordRenderer renderer = new WholeWordRenderer();
- renderer.open(Arrays.asList(art), PresentationType.PREVIEW);
- }
-
- };
- template.test();
+ Artifact art = createArtifact(CoreArtifactTypes.TestProcedureWML, BRANCH, addPrefix("4g"));
+ art.persist(new SkynetTransaction(BRANCH, String.format("%s, persist on %s, guid: %s",
+ PreviewAndMultiPreviewTest.class.getSimpleName(), BRANCH.getName(), BRANCH.getGuid())));
+ WholeWordRenderer renderer = new WholeWordRenderer();
+ renderer.open(Arrays.asList(art), PresentationType.PREVIEW);
}
- @org.junit.Test
+ @Test
public void testWholeWordPreviewUsingRendererManager() throws Exception {
- Template template = new Template() {
-
- @Override
- protected void testBody() throws OseeCoreException {
- Artifact art = createArtifact(CoreArtifactTypes.TestProcedureWML, BRANCH, addPrefix("4h"));
- art.persist(getClass().getSimpleName());
-
- RendererManager.openInJob(Arrays.asList(art), PresentationType.PREVIEW);
- }
-
- };
- template.test();
+ Artifact art = createArtifact(CoreArtifactTypes.TestProcedureWML, BRANCH, addPrefix("4h"));
+ art.persist(new SkynetTransaction(BRANCH, String.format("%s, persist on %s, guid: %s",
+ PreviewAndMultiPreviewTest.class.getSimpleName(), BRANCH.getName(), BRANCH.getGuid())));
+ RendererManager.openInJob(Arrays.asList(art), PresentationType.PREVIEW);
}
- private static abstract class Template {
-
- public void test() throws Exception {
- SevereLoggingMonitor monitorLog = TestUtil.severeLoggingStart();
- testBody();
- Assert.assertTrue(monitorLog.getLogsAtLevel(Level.WARNING).isEmpty());
- Assert.assertTrue(monitorLog.getLogsAtLevel(Level.SEVERE).isEmpty());
- TestUtil.severeLoggingStop(monitorLog);
- }
-
- public String addPrefix(String name) {
- return String.format("%s.%s", Template.class.getName(), name);
- }
-
- protected abstract void testBody() throws OseeCoreException;
+ public String addPrefix(String name) {
+ return String.format("%s.%s", "Template", name);
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
index d45efe9..c14a0fc 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
@@ -124,7 +124,7 @@ public class WordEditTest {
OseeEventManager.setDisableEvents(eventBoolean);
OseeEventManager.removeListener(listener);
}
- Assert.assertTrue("Update Event was not received", listener.wasUpdateReceived());
+ Assert.assertTrue("Intermittent test failure, Update Event was not received", listener.wasUpdateReceived());
}
private static String getRenderedStoredContent(FileSystemRenderer renderer, Artifact artifact) throws CoreException, IOException {
@@ -156,13 +156,13 @@ public class WordEditTest {
private volatile boolean wasUpdateReceived;
public UpdateArtifactListener(EventModType modType, Artifact artifact) {
- super();
this.artToLookFor = new EventBasicGuidArtifact(modType, artifact);
}
@Override
public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) {
List<EventBasicGuidArtifact> changes = artifactEvent.getArtifacts();
+
if (changes.contains(artToLookFor)) {
synchronized (this) {
wasUpdateReceived = true;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/widgets/workflow/WorkPageAdapterTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/widgets/workflow/WorkPageAdapterTest.java
index 44fb956..cea89c2 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/widgets/workflow/WorkPageAdapterTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/widgets/workflow/WorkPageAdapterTest.java
@@ -1,19 +1,30 @@
-/*
- * Created on Nov 23, 2010
+/*******************************************************************************
+ * Copyright (c) 2011 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
*
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.test.widgets.workflow;
+import org.eclipse.osee.framework.skynet.core.rule.OseeHousekeepingRule;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.MethodRule;
/**
- * @Tests WorkPageAdapter
+ * @link WorkPageAdapter
* @author Donald G. Dunne
*/
public class WorkPageAdapterTest {
+ @Rule
+ public MethodRule oseeHousekeepingRule = new OseeHousekeepingRule();
+
@Test
public void ordered() {
Assert.assertEquals(5, OrderedStates.Five.ordinal());