Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-11-08 03:46:00 +0000
committerRoberto E. Escobar2012-11-08 03:46:00 +0000
commit967dc423c5f71b3137b2be27baf82cb51e6170b0 (patch)
treea23f18198ecf490bf8a591234541b670e31f6c29 /plugins/org.eclipse.osee.ats.test/src/org/eclipse
parent5b37e94d01622f3afbd339393aa78e0ae314ad6d (diff)
downloadorg.eclipse.osee-967dc423c5f71b3137b2be27baf82cb51e6170b0.tar.gz
org.eclipse.osee-967dc423c5f71b3137b2be27baf82cb51e6170b0.tar.xz
org.eclipse.osee-967dc423c5f71b3137b2be27baf82cb51e6170b0.zip
feature[ats_TL5SF]: Add skynet.ui junit tests to maven
Diffstat (limited to 'plugins/org.eclipse.osee.ats.test/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsImageTest.java1
-rw-r--r--plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/ImageManagerTest.java143
2 files changed, 143 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsImageTest.java b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsImageTest.java
index e20aaae51b2..4bf50ed11c6 100644
--- a/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsImageTest.java
+++ b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsImageTest.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.ats.util;
import org.eclipse.osee.ats.AtsImage;
-import org.eclipse.osee.framework.ui.skynet.test.cases.ImageManagerTest;
/**
* @author Donald G. Dunne
diff --git a/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/ImageManagerTest.java b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/ImageManagerTest.java
new file mode 100644
index 00000000000..44ce22174b1
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/ImageManagerTest.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * 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.ats.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.ats.internal.Activator;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.IHealthStatus;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
+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.ArtifactCacheQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
+import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.osee.framework.ui.swt.KeyedImage;
+
+/**
+ * @author Donald G. Dunne
+ */
+public abstract class ImageManagerTest {
+
+ private final KeyedImage[] oseeImages;
+ private final String imageClassName;
+ private static SevereLoggingMonitor monitorLog;
+
+ public ImageManagerTest(String imageClassName, KeyedImage[] oseeImages) {
+ this.imageClassName = imageClassName;
+ this.oseeImages = oseeImages;
+ }
+
+ @org.junit.BeforeClass
+ public static void testSetup() throws Exception {
+ monitorLog = new SevereLoggingMonitor();
+ OseeLog.registerLoggerListener(monitorLog);
+ }
+
+ @org.junit.AfterClass
+ public static void testCleanup() throws Exception {
+ List<IHealthStatus> stats = monitorLog.getAllLogs();
+ for (IHealthStatus stat : new CopyOnWriteArrayList<IHealthStatus>(stats)) {
+ if (stat.getException() != null) {
+ fail("Exception: " + Lib.exceptionToString(stat.getException()));
+ }
+ }
+ StringBuffer sb = new StringBuffer();
+ for (IHealthStatus stat : new CopyOnWriteArrayList<IHealthStatus>(stats)) {
+ if (stat.getMessage().contains("Unable to load the image for") && !stat.getMessage().contains("nothere")) {
+ sb.append(stat.getMessage() + "\n");
+ }
+ }
+ if (!sb.toString().equals("")) {
+ fail(sb.toString());
+ }
+ }
+
+ /**
+ * Test that all image enums have associated image files. (Non return missing image)
+ */
+ @org.junit.Test
+ public void testFrameworkImageEnums() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ for (KeyedImage oseeImage : oseeImages) {
+ if (oseeImage == ImageManager.MISSING) {
+ continue;
+ }
+ assertNotNull(String.format("[%s] Image not defined for [%s]", imageClassName, oseeImage),
+ ImageManager.getImage(oseeImage));
+ if (ImageManager.getImage(oseeImage).equals(ImageManager.getImage(ImageManager.MISSING))) {
+ sb.append(String.format("\n[%s] Image not defined for [%s]", imageClassName, oseeImage));
+ }
+ }
+ assertEquals("", sb.toString());
+ }
+
+ @org.junit.Test
+ public void testGetImageByType() throws Exception {
+ assertTrue("Image returned not a folder image.",
+ ArtifactImageManager.getImage(CoreArtifactTypes.Folder).equals(ImageManager.getImage(PluginUiImage.FOLDER)));
+
+ }
+
+ @org.junit.Test
+ public void testGetImageByArtifact() throws Exception {
+ Artifact folder =
+ ArtifactCacheQuery.getOrCreateSingletonArtifactByText(CoreArtifactTypes.Folder, CoreAttributeTypes.StaticId,
+ "user.groups", BranchManager.getCommonBranch());
+ assertTrue("Image returned not a folder image.",
+ ArtifactImageManager.getImage(folder).equals(ImageManager.getImage(PluginUiImage.FOLDER)));
+ ArtifactCache.deCache(folder);
+ }
+
+ public static ByteArrayInputStream getByteArrayInputStream(String imageFilename) throws Exception {
+ URL imageFile = Platform.getBundle(Activator.PLUGIN_ID).getResource("images/" + imageFilename);
+ if (imageFile == null) {
+ throw new OseeArgumentException("Invalid image filename.");
+ }
+ return new ByteArrayInputStream(Lib.inputStreamToBytes(imageFile.openStream()));
+ }
+
+ public enum MissingImage implements KeyedImage {
+ NOT_HERE("nothere.gif");
+
+ private final String fileName;
+
+ private MissingImage(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public ImageDescriptor createImageDescriptor() {
+ return ImageManager.createImageDescriptor(Activator.PLUGIN_ID, "images", fileName);
+ }
+
+ @Override
+ public String getImageKey() {
+ return Activator.PLUGIN_ID + "." + fileName;
+ }
+ }
+
+}

Back to the top