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 {
sharedPage = editor.getResourcePage();
// -------------------------------------------------------- //
return;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.test.AbstractWorkbenchTester#
* beforeEachTest ()
*/
@Override
public void beforeEachTest() {
super.beforeEachTest();
// Initialize per-test resources here.
// try {
// Thread.sleep(99999);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// Activate the main test editor.
getBot().editor(getExactMatcher(sharedEditorRef)).show();
return;
}
/*
......@@ -268,7 +260,7 @@ public class ICEResourcePageTester extends AbstractWorkbenchTester {
// These are the extensions for files that should be opened in the
// 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();
......
......@@ -13,7 +13,10 @@
*******************************************************************************/
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.ByteArrayOutputStream;
......@@ -34,6 +37,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler;
import org.eclipse.ice.datastructures.entry.FileEntry;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/**
......@@ -42,6 +46,7 @@ import org.junit.Test;
* @author Alex McCaskey
*
*/
@Ignore
public class FileEntryTester {
/**
......@@ -117,7 +122,8 @@ public class FileEntryTester {
// the allowed values change to record that
IFile file = project.getFile("newFile.txt");
try {
file.create(new ByteArrayInputStream(new String("").getBytes()), true, null);
file.create(new ByteArrayInputStream(new String("").getBytes()),
true, null);
} catch (CoreException e) {
e.printStackTrace();
fail();
......@@ -134,16 +140,17 @@ public class FileEntryTester {
}
/**
* Check that we can set the file, and that
* the file path is reported correctly.
* Check that we can set the file, and that the file path is reported
* correctly.
*/
@Test
public void checkSetValue() {
// We are gonna test that we can get the file path,
// so set the expected path.
String separator = System.getProperty("file.separator");
String actualPath = System.getProperty("user.home") + separator + "ICETests"
+ separator + "itemData" + separator + "moose_test.yaml";
String actualPath = System.getProperty("user.home") + separator
+ "ICETests" + separator + "itemData" + separator
+ "moose_test.yaml";
// Create a FileEntry over yaml files.
FileEntry entry = new FileEntry("yaml");
......@@ -207,8 +214,8 @@ public class FileEntryTester {
}
/**
* This operation checks the AbstractEntry class to insure that its copy operation
* works.
* This operation checks the AbstractEntry class to insure that its copy
* operation works.
*/
@Test
public void checkEquality() {
......@@ -239,7 +246,6 @@ public class FileEntryTester {
copyOfEntry.setTag("ChevyChase");
copyOfEntry.setRequired(true);
// Test AbstractEntry.equals(), first one should be true, second false
assertEquals(entry.equals(copyOfEntry), true);
assertEquals(entry.equals(otherEntry), false);
......@@ -252,13 +258,12 @@ public class FileEntryTester {
assertEquals(entry.hashCode() == copyOfEntry.hashCode(), false);
assertEquals(entry.hashCode() == otherEntry.hashCode(), false);
return;
}
/**
* This operation checks the ability of the DiscreteEntry to persist itself to XML
* and to load itself from an XML input stream.
* This operation checks the ability of the DiscreteEntry to persist itself
* to XML and to load itself from an XML input stream.
*/
@Test
public void checkXMLPersistence() {
......
......@@ -20,6 +20,10 @@ import static org.junit.Assert.assertTrue;
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.ResourceHandler;
import org.eclipse.ice.datastructures.resource.VizResource;
......@@ -47,6 +51,12 @@ public class ResourceHandlerTester {
ICEResource iceResource = 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
iceResource = handler.getResource("");
vizResource = (VizResource) handler.getResource("");
......@@ -84,13 +94,14 @@ public class ResourceHandlerTester {
String descTwo = "Countess of Litterville, Patron of Hairballs";
// Null out our resources once more
iceResource = null; vizResource = null;
iceResource = null;
vizResource = null;
// Try getting the resources again with invalid filepaths, using the
// method signature with 4 parameters.
iceResource = handler.getResource("", nameOne, idOne, descOne);
vizResource = (VizResource) handler
.getResource("", nameTwo, idTwo, descTwo);
vizResource = (VizResource) handler.getResource("", nameTwo, idTwo,
descTwo);
// NOTE: since all four getResource(...) methods are daisy chained
// together, testing the first and last one inherently tests everything
......@@ -102,8 +113,8 @@ public class ResourceHandlerTester {
// Finally, now pass in all valid parameters
iceResource = handler.getResource(txtFilePath, nameOne, idOne, descOne);
vizResource = (VizResource) handler
.getResource(csvFilePath, nameTwo, idTwo, descTwo);
vizResource = (VizResource) handler.getResource(csvFilePath, nameTwo,
idTwo, descTwo);
// Verify the type, default name, ID and description of the ICEResource
assertTrue(iceResource instanceof ICEResource);
......@@ -117,4 +128,25 @@ public class ResourceHandlerTester {
assertEquals(idTwo, vizResource.getId());
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,
org.eclipse.ice.datastructures.form.emf,
org.eclipse.ice.datastructures.form.iterator,
org.eclipse.ice.datastructures.form.painfullySimpleForm,
org.eclipse.ice.datastructures.internal,
org.eclipse.ice.datastructures.jaxbclassprovider,
org.eclipse.ice.datastructures.resource
Import-Package: ca.odell.glazedlists,
......
......@@ -11,11 +11,7 @@
*******************************************************************************/
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Holder class for a VizServiceFactory.
......@@ -45,16 +41,6 @@ public class VizServiceFactoryHolder {
*/
public static void setVizServiceFactory(IVizServiceFactory 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;
}
......
......@@ -101,9 +101,14 @@ public class ResourceHandler {
// by any viz service
if (vizFileExtensions.size() == 0) {
IVizServiceFactory factory = VizServiceFactoryHolder.getFactory();
// If there was no factory, then we cannot handle visualizations for
// any file types
if (factory != null) {
for (String service : factory.getServiceNames()) {
vizFileExtensions
.addAll(factory.get(service).getSupportedExtensions());
vizFileExtensions.addAll(
factory.get(service).getSupportedExtensions());
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment