Commit ef7915da authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

Fixed the tests on the core to handle the updates.


Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent 6b97b392
......@@ -69,7 +69,8 @@ public class CoreTester {
/**
* This operation configures the core.
* @throws CoreException
*
* @throws CoreException
*/
@Before
public void BeforeClass() throws CoreException {
......@@ -114,7 +115,8 @@ public class CoreTester {
// Make sure the list of available builders contains the 2 fake items.
List<String> availableBuilders = fakeItemManager.getAvailableBuilders();
assertNotNull(availableBuilders);
assertEquals(2, availableBuilders.size());
assertTrue(availableBuilders.contains(fakeModuleBuilder.getItemName()));
assertTrue(availableBuilders.contains(fakeGeometryBuilder.getItemName()));
// NOTE: The below code has to loop over the list of available builders
// because the underlying list is NOT ordered.
......@@ -125,8 +127,10 @@ public class CoreTester {
for (int i = 0; !found && i < availableBuilders.size(); i++) {
found = testItemName.equals(availableBuilders.get(i));
}
assertTrue("ItemManagerTester: " + "FakeModuleBuilder with name "
+ testItemName + " not found in available builders!", found);
assertTrue(
"ItemManagerTester: " + "FakeModuleBuilder with name "
+ testItemName + " not found in available builders!",
found);
// Make sure the available builders includes the fake geometry builder.
found = false;
......@@ -134,8 +138,10 @@ public class CoreTester {
for (int i = 0; !found && i < availableBuilders.size(); i++) {
found = testItemName.equals(availableBuilders.get(i));
}
assertTrue("ItemManagerTester: " + "FakeGeometryBuilder with name "
+ testItemName + " not found in available builders!", found);
assertTrue(
"ItemManagerTester: " + "FakeGeometryBuilder with name "
+ testItemName + " not found in available builders!",
found);
// Register the CompositeItemBuilder
iCECore.registerCompositeItem(fakeCompositeBuilder);
......@@ -169,10 +175,6 @@ public class CoreTester {
String name = fakeModuleBuilder.getItemName();
ArrayList<String> types = new ArrayList<String>();
// Check the available Item types before registration to make sure that
// the list is empty
assertTrue(iCECore.getAvailableItemTypes().getList() == null);
// Register the ItemBuilders
iCECore.registerItem(fakeModuleBuilder);
iCECore.registerItem(fakeGeometryBuilder);
......@@ -220,8 +222,8 @@ public class CoreTester {
}
// Make sure that there are no items
assertEquals(0, iCECore.getItemList().size());
System.out.println("Num ITEMS after delete = "
+ iCECore.getItemList().size());
System.out.println(
"Num ITEMS after delete = " + iCECore.getItemList().size());
return;
}
......@@ -253,8 +255,8 @@ public class CoreTester {
// This class has a special implementation of reviewEntries that
// makes testing easier. Adding two data components will make it pass
// its review, but adding any more will cause it to fail.
testItemId = Integer.parseInt(iCECore.createItem(fakeGeometryBuilder
.getItemName()));
testItemId = Integer.parseInt(
iCECore.createItem(fakeGeometryBuilder.getItemName()));
assertTrue(testItemId > 0);
// Get the Form and make sure it is not null
......@@ -326,8 +328,8 @@ public class CoreTester {
// This class has a special implementation of reviewEntries that
// makes testing easier. Adding two data components will make it pass
// its review, but adding any more will cause it to fail.
testItemId = Integer.parseInt(iCECore.createItem(fakeGeometryBuilder
.getItemName()));
testItemId = Integer.parseInt(
iCECore.createItem(fakeGeometryBuilder.getItemName()));
assertTrue(testItemId > 0);
// Direct the Core to process the Item
......@@ -343,10 +345,10 @@ public class CoreTester {
// Setup the name of the output file. According to the documentation it
// should be at <itemName>_<itemId>_processOutput.txt.
String outputFilename = fakeItem.getName().replaceAll("\\s+", "_")
+ "_" + fakeItem.getId() + "_processOutput.txt";
System.out
.println("CoreTester message: Looking for (shortened) output file name \""
String outputFilename = fakeItem.getName().replaceAll("\\s+", "_") + "_"
+ fakeItem.getId() + "_processOutput.txt";
System.out.println(
"CoreTester message: Looking for (shortened) output file name \""
+ outputFilename + "\"");
// Get the output file handle
File outputFile = iCECore.getItemOutputFile(testItemId);
......@@ -407,8 +409,8 @@ public class CoreTester {
assertNotNull(types);
// Create an Item
testItemId = Integer.parseInt(iCECore.createItem(fakeGeometryBuilder
.getItemName()));
testItemId = Integer.parseInt(
iCECore.createItem(fakeGeometryBuilder.getItemName()));
// Create a test file
File testFile = new File("testFile.test");
......@@ -477,21 +479,15 @@ public class CoreTester {
// Local Declarations
FakeGeometryBuilder fakeGeometryBuilder = new FakeGeometryBuilder();
// Check the available Item types before registration to make sure that
// the list is empty
assertTrue(iCECore.getAvailableItemTypes().getList() == null);
// Register the ItemBuilders
iCECore.registerItem(fakeGeometryBuilder);
// Create an Item
int id = Integer.parseInt(iCECore.createItem(fakeGeometryBuilder
.getItemName()));
int id = Integer.parseInt(
iCECore.createItem(fakeGeometryBuilder.getItemName()));
// A message from some of the Updater tests
String msg = "post={\"item_id\":\""
+ id
+ "\", "
String msg = "post={\"item_id\":\"" + id + "\", "
+ "\"client_key\":\"1234567890ABCDEFGHIJ1234567890ABCDEFGHIJ\", "
+ "\"posts\":[{\"type\":\"UPDATER_STARTED\",\"message\":\"\"},"
+ "{\"type\":\"FILE_MODIFIED\","
......@@ -609,8 +605,8 @@ public class CoreTester {
String separator = System.getProperty("file.separator");
// Setup the project space so that the output file can be checked.
System.out.println("CoreTester Workspace Root = "
+ workspaceRoot.getLocation());
System.out.println(
"CoreTester Workspace Root = " + workspaceRoot.getLocation());
System.out.println("Constructing project " + name);
try {
// Get the project handle
......@@ -619,7 +615,7 @@ public class CoreTester {
if (!project.exists()) {
defaultProjectLocation = (new File(
System.getProperty("user.dir") + separator + name))
.toURI();
.toURI();
// Create the project description
IProjectDescription desc = ResourcesPlugin.getWorkspace()
.newProjectDescription(name);
......
......@@ -192,6 +192,7 @@ public class Core extends Application implements ICore {
return;
}
/**
* This operation is responsible for creating the project space used by the
* IPersistenceProvider.
......@@ -225,8 +226,7 @@ public class Core extends Application implements ICore {
logger.error(getClass().getName() + " Exception!", e);
}
}
/**
* This operation starts the Core, sets the component context and starts the
* web client if the HTTP service is available.
......@@ -244,13 +244,14 @@ public class Core extends Application implements ICore {
// Get the persistence provider from the extension registry.
IExtensionPoint point = Platform.getExtensionRegistry()
.getExtensionPoint(providerID);
if (point != null) {
// Retrieve the provider from the registry and set it if one has not
// already been set.
if (point != null && provider == null) {
// We only need one persistence provider, so just pull the
// configuration element for the first one available.
IConfigurationElement element = point.getConfigurationElements()[0];
provider = (IPersistenceProvider) element
.createExecutableExtension("class");
System.out.println("Success!");
setPersistenceProvider((IPersistenceProvider) element
.createExecutableExtension("class"));
} else {
logger.error("Extension Point " + providerID + "does not exist");
}
......@@ -270,8 +271,8 @@ public class Core extends Application implements ICore {
for (int i = 0; i < elements.length; i++) {
builder = (ItemBuilder) elements[i]
.createExecutableExtension("class");
// Register with the ItemManager
itemManager.registerBuilder(builder);
// Register the builder
registerItem(builder);
}
} else {
logger.error("Extension Point " + id + "does not exist");
......
......@@ -337,8 +337,8 @@ public class ItemManager implements ItemListener {
// Make sure the builder is not null and add it to the list, if it's not
// there already.
if (builder != null
&& !this.itemBuilderList.containsKey(builder.getItemName())) {
this.itemBuilderList.put(builder.getItemName(), builder);
&& !itemBuilderList.containsKey(builder.getItemName())) {
itemBuilderList.put(builder.getItemName(), builder);
// Notify the composite Items of the updated builder list
for (ICompositeItemBuilder compositeBuilder : compositeBuilders) {
compositeBuilder.addBuilders(new ArrayList<ItemBuilder>(
......
......@@ -42,6 +42,7 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
......@@ -1458,7 +1459,8 @@ public class Item
if (project != null) {
// Get the file
IFile outputFileHandle = project.getFile(outputFilename);
outputFile = outputFileHandle.getLocation().toFile();
IPath location = outputFileHandle.getLocation();
outputFile = location.toFile();
// Create a new file if it does not already exist
try {
outputFile.createNewFile();
......
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