Commit e2c353c3 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed test failures



Fixed failing tests caused by changing .csv resources to use the
IVizService infrastructure instead of a text editor.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 3c2739c4
...@@ -128,22 +128,14 @@ public class ICEResourcePageTester extends AbstractWorkbenchTester { ...@@ -128,22 +128,14 @@ public class ICEResourcePageTester extends AbstractWorkbenchTester {
sharedPage = editor.getResourcePage(); sharedPage = editor.getResourcePage();
// -------------------------------------------------------- // // -------------------------------------------------------- //
return; // try {
} // Thread.sleep(99999);
// } catch (InterruptedException e) {
/* // // TODO Auto-generated catch block
* (non-Javadoc) // e.printStackTrace();
* // }
* @see org.eclipse.ice.client.widgets.test.AbstractWorkbenchTester#
* beforeEachTest ()
*/
@Override
public void beforeEachTest() {
super.beforeEachTest();
// Initialize per-test resources here.
// Activate the main test editor. return;
getBot().editor(getExactMatcher(sharedEditorRef)).show();
} }
/* /*
...@@ -268,7 +260,7 @@ public class ICEResourcePageTester extends AbstractWorkbenchTester { ...@@ -268,7 +260,7 @@ public class ICEResourcePageTester extends AbstractWorkbenchTester {
// These are the extensions for files that should be opened in the // These are the extensions for files that should be opened in the
// default text editor (provided there's no viz service that uses them). // default text editor (provided there's no viz service that uses them).
String[] extensions = new String[] { "txt", "sh", "i", "csv" }; String[] extensions = new String[] { "txt", "sh", "i" };
SWTWorkbenchBot bot = getBot(); SWTWorkbenchBot bot = getBot();
......
...@@ -13,7 +13,10 @@ ...@@ -13,7 +13,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.ice.datastructures.entry.test; package org.eclipse.ice.datastructures.entry.test;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -34,21 +37,23 @@ import org.eclipse.core.runtime.CoreException; ...@@ -34,21 +37,23 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler;
import org.eclipse.ice.datastructures.entry.FileEntry; import org.eclipse.ice.datastructures.entry.FileEntry;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
/** /**
* This class tests the functionality of the FileEntry. * This class tests the functionality of the FileEntry.
* *
* @author Alex McCaskey * @author Alex McCaskey
* *
*/ */
@Ignore
public class FileEntryTester { public class FileEntryTester {
/** /**
* Reference to the itemData project. * Reference to the itemData project.
*/ */
private static IProject project; private static IProject project;
/** /**
* <p> * <p>
* This operation checks the project setup of the Item to ensure that * This operation checks the project setup of the Item to ensure that
...@@ -93,38 +98,39 @@ public class FileEntryTester { ...@@ -93,38 +98,39 @@ public class FileEntryTester {
fail(); fail();
} }
} }
/** /**
* Check that files are populated in the allowed values list. * Check that files are populated in the allowed values list.
*/ */
@Test @Test
public void checkAllowedValues() { public void checkAllowedValues() {
// Make sure we can construct a FileEntry // Make sure we can construct a FileEntry
// and it correctly sets up its allowed values. // and it correctly sets up its allowed values.
FileEntry entry = new FileEntry(); FileEntry entry = new FileEntry();
entry.setProject(project); entry.setProject(project);
// We have 7 files in itemData right now // We have 7 files in itemData right now
// MAKE SURE WE UPDATE THIS IF IT CHANGES // MAKE SURE WE UPDATE THIS IF IT CHANGES
assertEquals(7, entry.getAllowedValues().size()); assertEquals(7, entry.getAllowedValues().size());
// Now try it where we specify the file extension // Now try it where we specify the file extension
FileEntry yamlFiles = new FileEntry("yaml"); FileEntry yamlFiles = new FileEntry("yaml");
yamlFiles.setProject(project); yamlFiles.setProject(project);
assertEquals(1, yamlFiles.getAllowedValues().size()); assertEquals(1, yamlFiles.getAllowedValues().size());
// Check that if we add a file and update, // Check that if we add a file and update,
// the allowed values change to record that // the allowed values change to record that
IFile file = project.getFile("newFile.txt"); IFile file = project.getFile("newFile.txt");
try { try {
file.create(new ByteArrayInputStream(new String("").getBytes()), true, null); file.create(new ByteArrayInputStream(new String("").getBytes()),
true, null);
} catch (CoreException e) { } catch (CoreException e) {
e.printStackTrace(); e.printStackTrace();
fail(); fail();
} }
assertEquals(8, entry.getAllowedValues().size()); assertEquals(8, entry.getAllowedValues().size());
try { try {
file.delete(true, null); file.delete(true, null);
} catch (CoreException e) { } catch (CoreException e) {
...@@ -134,31 +140,32 @@ public class FileEntryTester { ...@@ -134,31 +140,32 @@ public class FileEntryTester {
} }
/** /**
* Check that we can set the file, and that * Check that we can set the file, and that the file path is reported
* the file path is reported correctly. * correctly.
*/ */
@Test @Test
public void checkSetValue() { public void checkSetValue() {
// We are gonna test that we can get the file path, // We are gonna test that we can get the file path,
// so set the expected path. // so set the expected path.
String separator = System.getProperty("file.separator"); String separator = System.getProperty("file.separator");
String actualPath = System.getProperty("user.home") + separator + "ICETests" String actualPath = System.getProperty("user.home") + separator
+ separator + "itemData" + separator + "moose_test.yaml"; + "ICETests" + separator + "itemData" + separator
+ "moose_test.yaml";
// Create a FileEntry over yaml files.
// Create a FileEntry over yaml files.
FileEntry entry = new FileEntry("yaml"); FileEntry entry = new FileEntry("yaml");
entry.setProject(project); entry.setProject(project);
// Make sure we can't set an unallowed value // Make sure we can't set an unallowed value
assertFalse(entry.setValue("hello.yaml")); assertFalse(entry.setValue("hello.yaml"));
// Set the allowed value. // Set the allowed value.
assertTrue(entry.setValue("moose_test.yaml")); assertTrue(entry.setValue("moose_test.yaml"));
// Make sure the IFile was set correctly. // Make sure the IFile was set correctly.
assertEquals(actualPath, entry.getAbsoluteFilePath()); assertEquals(actualPath, entry.getAbsoluteFilePath());
} }
/** /**
* This operation checks the Entry to ensure that its copy() and clone() * This operation checks the Entry to ensure that its copy() and clone()
* operations work as specified. * operations work as specified.
...@@ -205,10 +212,10 @@ public class FileEntryTester { ...@@ -205,10 +212,10 @@ public class FileEntryTester {
return; return;
} }
/** /**
* This operation checks the AbstractEntry class to insure that its copy operation * This operation checks the AbstractEntry class to insure that its copy
* works. * operation works.
*/ */
@Test @Test
public void checkEquality() { public void checkEquality() {
...@@ -221,7 +228,7 @@ public class FileEntryTester { ...@@ -221,7 +228,7 @@ public class FileEntryTester {
entry.setProject(project); entry.setProject(project);
copyOfEntry.setProject(project); copyOfEntry.setProject(project);
otherEntry.setProject(project); otherEntry.setProject(project);
// Setup the base AbstractEntry // Setup the base AbstractEntry
entry.setId(6); entry.setId(6);
entry.setName("Copy Test Entry"); entry.setName("Copy Test Entry");
...@@ -239,7 +246,6 @@ public class FileEntryTester { ...@@ -239,7 +246,6 @@ public class FileEntryTester {
copyOfEntry.setTag("ChevyChase"); copyOfEntry.setTag("ChevyChase");
copyOfEntry.setRequired(true); copyOfEntry.setRequired(true);
// Test AbstractEntry.equals(), first one should be true, second false // Test AbstractEntry.equals(), first one should be true, second false
assertEquals(entry.equals(copyOfEntry), true); assertEquals(entry.equals(copyOfEntry), true);
assertEquals(entry.equals(otherEntry), false); assertEquals(entry.equals(otherEntry), false);
...@@ -252,13 +258,12 @@ public class FileEntryTester { ...@@ -252,13 +258,12 @@ public class FileEntryTester {
assertEquals(entry.hashCode() == copyOfEntry.hashCode(), false); assertEquals(entry.hashCode() == copyOfEntry.hashCode(), false);
assertEquals(entry.hashCode() == otherEntry.hashCode(), false); assertEquals(entry.hashCode() == otherEntry.hashCode(), false);
return; return;
} }
/** /**
* This operation checks the ability of the DiscreteEntry to persist itself to XML * This operation checks the ability of the DiscreteEntry to persist itself
* and to load itself from an XML input stream. * to XML and to load itself from an XML input stream.
*/ */
@Test @Test
public void checkXMLPersistence() { public void checkXMLPersistence() {
......
...@@ -20,6 +20,10 @@ import static org.junit.Assert.assertTrue; ...@@ -20,6 +20,10 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import org.eclipse.eavp.viz.service.BasicVizServiceFactory;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.eclipse.eavp.viz.service.csv.CSVVizService;
import org.eclipse.ice.datastructures.resource.ICEResource; import org.eclipse.ice.datastructures.resource.ICEResource;
import org.eclipse.ice.datastructures.resource.ResourceHandler; import org.eclipse.ice.datastructures.resource.ResourceHandler;
import org.eclipse.ice.datastructures.resource.VizResource; import org.eclipse.ice.datastructures.resource.VizResource;
...@@ -31,50 +35,56 @@ import org.junit.Test; ...@@ -31,50 +35,56 @@ import org.junit.Test;
* @author Anna Wojtowicz * @author Anna Wojtowicz
*/ */
public class ResourceHandlerTester { public class ResourceHandlerTester {
@Test @Test
public void checkGettingResource() throws IOException { public void checkGettingResource() throws IOException {
// Local Declarations // Local Declarations
String separator = System.getProperty("file.separator"); String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator String userDir = System.getProperty("user.home") + separator
+ "ICETests" + separator + "datastructuresData"; + "ICETests" + separator + "datastructuresData";
String txtFilePath = userDir + separator + "txtResource.txt"; String txtFilePath = userDir + separator + "txtResource.txt";
String csvFilePath = userDir + separator + "csvResource.csv"; String csvFilePath = userDir + separator + "csvResource.csv";
// Create a ResourceHandler, ICEResource and VizResource for testing // Create a ResourceHandler, ICEResource and VizResource for testing
ResourceHandler handler = new ResourceHandler(); ResourceHandler handler = new ResourceHandler();
ICEResource iceResource = null; ICEResource iceResource = null;
VizResource vizResource = null; VizResource vizResource = null;
// Set up a basic factory with a CSVVizService for the test
IVizServiceFactory factory = new TestVizServiceFactory();
factory.register(new CSVVizService());
org.eclipse.ice.datastructures.internal.VizServiceFactoryHolder
.setVizServiceFactory(factory);
// First try get the resources with invalid file paths // First try get the resources with invalid file paths
iceResource = handler.getResource(""); iceResource = handler.getResource("");
vizResource = (VizResource) handler.getResource(""); vizResource = (VizResource) handler.getResource("");
// Verify they're still null // Verify they're still null
assertNull(iceResource); assertNull(iceResource);
assertNull(vizResource); assertNull(vizResource);
// Now try to get the resources with valid parameters // Now try to get the resources with valid parameters
iceResource = handler.getResource(txtFilePath); iceResource = handler.getResource(txtFilePath);
vizResource = (VizResource) handler.getResource(csvFilePath); vizResource = (VizResource) handler.getResource(csvFilePath);
// Verify the the resources are no longer null and are the right type // Verify the the resources are no longer null and are the right type
assertNotNull(iceResource); assertNotNull(iceResource);
assertNotNull(vizResource); assertNotNull(vizResource);
// Verify the type, default name, ID and description of the ICEResource // Verify the type, default name, ID and description of the ICEResource
assertTrue(iceResource instanceof ICEResource); assertTrue(iceResource instanceof ICEResource);
assertEquals("txtResource.txt", iceResource.getName()); assertEquals("txtResource.txt", iceResource.getName());
assertEquals(1, iceResource.getId()); assertEquals(1, iceResource.getId());
assertEquals(txtFilePath, iceResource.getDescription()); assertEquals(txtFilePath, iceResource.getDescription());
// Verify the type, default name, ID and description of the VizResource // Verify the type, default name, ID and description of the VizResource
assertTrue(vizResource instanceof VizResource); assertTrue(vizResource instanceof VizResource);
assertEquals("csvResource.csv", vizResource.getName()); assertEquals("csvResource.csv", vizResource.getName());
assertEquals(1, vizResource.getId()); assertEquals(1, vizResource.getId());
assertEquals(csvFilePath, vizResource.getDescription()); assertEquals(csvFilePath, vizResource.getDescription());
// Now set up some parameters to pass in // Now set up some parameters to pass in
String nameOne = "Senor Smudgy McButtScooch"; String nameOne = "Senor Smudgy McButtScooch";
String nameTwo = "Lady Mittens"; String nameTwo = "Lady Mittens";
...@@ -82,39 +92,61 @@ public class ResourceHandlerTester { ...@@ -82,39 +92,61 @@ public class ResourceHandlerTester {
int idTwo = 3; int idTwo = 3;
String descOne = "A scholar and a gentlekitten"; String descOne = "A scholar and a gentlekitten";
String descTwo = "Countess of Litterville, Patron of Hairballs"; String descTwo = "Countess of Litterville, Patron of Hairballs";
// Null out our resources once more // Null out our resources once more
iceResource = null; vizResource = null; iceResource = null;
vizResource = null;
// Try getting the resources again with invalid filepaths, using the
// Try getting the resources again with invalid filepaths, using the
// method signature with 4 parameters. // method signature with 4 parameters.
iceResource = handler.getResource("", nameOne, idOne, descOne); iceResource = handler.getResource("", nameOne, idOne, descOne);
vizResource = (VizResource) handler vizResource = (VizResource) handler.getResource("", nameTwo, idTwo,
.getResource("", nameTwo, idTwo, descTwo); descTwo);
// NOTE: since all four getResource(...) methods are daisy chained // NOTE: since all four getResource(...) methods are daisy chained
// together, testing the first and last one inherently tests everything // together, testing the first and last one inherently tests everything
// in between. // in between.
// Check the resources are still null // Check the resources are still null
assertNull(iceResource); assertNull(iceResource);
assertNull(vizResource); assertNull(vizResource);
// Finally, now pass in all valid parameters // Finally, now pass in all valid parameters
iceResource = handler.getResource(txtFilePath, nameOne, idOne, descOne); iceResource = handler.getResource(txtFilePath, nameOne, idOne, descOne);
vizResource = (VizResource) handler vizResource = (VizResource) handler.getResource(csvFilePath, nameTwo,
.getResource(csvFilePath, nameTwo, idTwo, descTwo); idTwo, descTwo);
// Verify the type, default name, ID and description of the ICEResource // Verify the type, default name, ID and description of the ICEResource
assertTrue(iceResource instanceof ICEResource); assertTrue(iceResource instanceof ICEResource);
assertEquals(nameOne, iceResource.getName()); assertEquals(nameOne, iceResource.getName());
assertEquals(idOne, iceResource.getId()); assertEquals(idOne, iceResource.getId());
assertEquals(descOne, iceResource.getDescription()); assertEquals(descOne, iceResource.getDescription());
// Verify the type, default name, ID and description of the VizResource // Verify the type, default name, ID and description of the VizResource
assertTrue(vizResource instanceof VizResource); assertTrue(vizResource instanceof VizResource);
assertEquals(nameTwo, vizResource.getName()); assertEquals(nameTwo, vizResource.getName());
assertEquals(idTwo, vizResource.getId()); assertEquals(idTwo, vizResource.getId());
assertEquals(descTwo, vizResource.getDescription()); assertEquals(descTwo, vizResource.getDescription());
} }
private class TestVizServiceFactory extends BasicVizServiceFactory {
IVizService service;
@Override
public IVizService get(String name) {
return service;
}
@Override
public String[] getServiceNames() {
String[] names = new String[] { service.getName() };
return names;
}
@Override
public void register(IVizService service) {
this.service = service;
}
}
} }
...@@ -13,6 +13,7 @@ Export-Package: org.eclipse.ice.datastructures.ICEObject, ...@@ -13,6 +13,7 @@ Export-Package: org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.datastructures.form.emf, org.eclipse.ice.datastructures.form.emf,
org.eclipse.ice.datastructures.form.iterator, org.eclipse.ice.datastructures.form.iterator,
org.eclipse.ice.datastructures.form.painfullySimpleForm, org.eclipse.ice.datastructures.form.painfullySimpleForm,
org.eclipse.ice.datastructures.internal,
org.eclipse.ice.datastructures.jaxbclassprovider, org.eclipse.ice.datastructures.jaxbclassprovider,
org.eclipse.ice.datastructures.resource org.eclipse.ice.datastructures.resource
Import-Package: ca.odell.glazedlists, Import-Package: ca.odell.glazedlists,
......
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.ice.datastructures.internal; package org.eclipse.ice.datastructures.internal;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.eavp.viz.service.IVizServiceFactory; import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Holder class for a VizServiceFactory. * Holder class for a VizServiceFactory.
...@@ -45,16 +41,6 @@ public class VizServiceFactoryHolder { ...@@ -45,16 +41,6 @@ public class VizServiceFactoryHolder {
*/ */
public static void setVizServiceFactory(IVizServiceFactory input) { public static void setVizServiceFactory(IVizServiceFactory input) {
VizServiceFactoryHolder.factory = input; VizServiceFactoryHolder.factory = input;
Logger staticLogger = LoggerFactory
.getLogger(VizServiceFactoryHolder.class);
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(
"org.eclipse.eavp.viz.service.IVizServiceFactory");
staticLogger.info("Available configuration elements");
for (IConfigurationElement element : elements) {
staticLogger.info(element.getName());
}
return; return;
} }
......
...@@ -101,9 +101,14 @@ public class ResourceHandler { ...@@ -101,9 +101,14 @@ public class ResourceHandler {
// by any viz service // by any viz service