Commit 73eca227 authored by amccaskey's avatar amccaskey
Browse files

Updating Moose-related tests to use Moose-test files instead of Bison.


Signed-off-by: default avataramccaskey <mccaskeyaj@ornl.gov>
parent 48faa763
......@@ -104,14 +104,14 @@ public class FileEntryTester {
FileEntry entry = new FileEntry();
entry.setProject(project);
// We have 13 files in itemData right now
// We have 7 files in itemData right now
// MAKE SURE WE UPDATE THIS IF IT CHANGES
assertEquals(13, entry.getAllowedValues().size());
assertEquals(7, entry.getAllowedValues().size());
// Now try it where we specify the file extension
FileEntry yamlFiles = new FileEntry("yaml");
yamlFiles.setProject(project);
assertEquals(3, yamlFiles.getAllowedValues().size());
assertEquals(1, yamlFiles.getAllowedValues().size());
// Check that if we add a file and update,
// the allowed values change to record that
......@@ -123,7 +123,7 @@ public class FileEntryTester {
fail();
}
assertEquals(14, entry.getAllowedValues().size());
assertEquals(8, entry.getAllowedValues().size());
try {
file.delete(true, null);
......@@ -143,7 +143,7 @@ public class FileEntryTester {
// so set the expected path.
String separator = System.getProperty("file.separator");
String actualPath = System.getProperty("user.home") + separator + "ICETests"
+ separator + "itemData" + separator + "bison.yaml";
+ separator + "itemData" + separator + "moose_test.yaml";
// Create a FileEntry over yaml files.
FileEntry entry = new FileEntry("yaml");
......@@ -153,7 +153,7 @@ public class FileEntryTester {
assertFalse(entry.setValue("hello.yaml"));
// Set the allowed value.
assertTrue(entry.setValue("bison.yaml"));
assertTrue(entry.setValue("moose_test.yaml"));
// Make sure the IFile was set correctly.
assertEquals(actualPath, entry.getAbsoluteFilePath());
......
......@@ -1111,15 +1111,13 @@ public class ItemTester implements ItemListener {
ArrayList<String> files = testItem
.getYAMLFiles(project.getLocation().toOSString());
assertNotNull(files);
assertEquals(3, files.size());
assertTrue(files.contains("bison.yaml"));
assertTrue(files.contains("bison_short.yaml"));
assertTrue(files.contains("bison_medium.yaml"));
assertEquals(1, files.size());
assertTrue(files.contains("moose_test.yaml"));
// Give it something that is not a directory and make sure we
// get no files
files = testItem.getYAMLFiles(
project.getLocation().toOSString() + separator + "bison.yaml");
project.getLocation().toOSString() + separator + "moose_test.yaml");
assertTrue(files.isEmpty());
// Create a new temp directory
......@@ -1136,36 +1134,22 @@ public class ItemTester implements ItemListener {
// The test here is that the move operation makes a new file in the
// target and deletes the file in the source
testItem.moveTestFile(project.getLocation().toOSString(),
tempDir.getLocation().toOSString(), "bison.yaml");
assertFalse(project.getFile("bison.yaml").exists());
assertTrue(tempDir.getFile("bison.yaml").exists());
tempDir.getLocation().toOSString(), "moose_test.yaml");
assertFalse(project.getFile("moose_test.yaml").exists());
assertTrue(tempDir.getFile("moose_test.yaml").exists());
// Move it back to keep our workspace pristine for other item tests
testItem.moveTestFile(tempDir.getLocation().toOSString(),
project.getLocation().toOSString(), "bison.yaml");
assertTrue(project.getFile("bison.yaml").exists());
assertFalse(tempDir.getFile("bison.yaml").exists());
project.getLocation().toOSString(), "moose_test.yaml");
assertTrue(project.getFile("moose_test.yaml").exists());
assertFalse(tempDir.getFile("moose_test.yaml").exists());
// Check that we can copy, that is a new copied file is created
// in the target and the source file is left intact
testItem.copyTestFile(project.getLocation().toOSString(),
tempDir.getLocation().toOSString(), "bison.yaml");
assertTrue(project.getFile("bison.yaml").exists());
assertTrue(tempDir.getFile("bison.yaml").exists());
// Make sure we can move multiple files at time
testItem.moveMultipleFiles(project.getLocation().toOSString(),
tempDir.getLocation().toOSString(), ".yaml");
assertTrue(tempDir.getFile("bison.yaml").exists());
assertTrue(tempDir.getFile("bison_short.yaml").exists());
assertTrue(tempDir.getFile("bison_medium.yaml").exists());
// Let's check copying multiple files
testItem.copyMultipleFiles(tempDir.getLocation().toOSString(),
project.getLocation().toOSString(), ".yaml");
assertTrue(project.getFile("bison.yaml").exists());
assertTrue(project.getFile("bison_short.yaml").exists());
assertTrue(project.getFile("bison_medium.yaml").exists());
tempDir.getLocation().toOSString(), "moose_test.yaml");
assertTrue(project.getFile("moose_test.yaml").exists());
assertTrue(tempDir.getFile("moose_test.yaml").exists());
// Check we can delete directories
testItem.deleteTestDirectory(tempDir.getLocation().toOSString());
......
......@@ -46,7 +46,7 @@ public class SuiteLauncherTester {
ArrayList<String> execs = new ArrayList<String>();
execs.add("conj_ht");
execs.add("conj_ht_moab");
execs.add("bison");
execs.add("testExec");
// Set the list
launcher.addExecutables(execs);
......@@ -74,7 +74,7 @@ public class SuiteLauncherTester {
ArrayList<String> execs = new ArrayList<String>();
execs.add("conj_ht");
execs.add("conj_ht_moab");
execs.add("bison");
execs.add("testExec");
// Set the launcher details
jobItem.setDescription("I am a job!");
......@@ -162,7 +162,7 @@ public class SuiteLauncherTester {
ArrayList<String> execs = new ArrayList<String>();
execs.add("conj_ht");
execs.add("conj_ht_moab");
execs.add("bison");
execs.add("testExec");
// Set ids
equalItem.setId(item.getId());
......
......@@ -55,24 +55,24 @@ public class YAMLTester {
}
/**
* This operation loads input from INL's BISON application, based on MOOSE,
* This operation loads input from INL's Moose framework
* to make sure that the file can be parsed. It is also based on an example
* from the SnakeYAML website.
*/
@Test
public void checkSnakeYAMLWithBison() {
public void checkSnakeYAMLWithMoose() {
// Local Declarations
String separator = System.getProperty("file.separator");
InputStream input = null;
File bisonFile = null;
File mooseFile = null;
String userDir = System.getProperty("user.home") + separator
+ "ICETests" + separator + "itemData";
// Load the bison file
// Load the moose file
try {
bisonFile = new File(userDir + separator + "bison.yaml");
input = new FileInputStream(bisonFile);
mooseFile = new File(userDir + separator + "moose_test.yaml");
input = new FileInputStream(mooseFile);
} catch (FileNotFoundException e) {
// Complain if the file is not found
e.printStackTrace();
......@@ -98,7 +98,7 @@ public class YAMLTester {
// Check the input. The short input file only has the /Adaptivity block
// from the input, so size = 1.
assertEquals(34, data.size());
assertEquals(42, data.size());
// Check the name, type and description of the /Adaptivity block
assertEquals("/Adaptivity", dataMap.get("name"));
assertEquals("", dataMap.get("description"));
......
......@@ -58,70 +58,32 @@ public class MOOSEFileHandlerTester {
String separator = System.getProperty("file.separator");
DataComponent parameters = null;
String userDir = System.getProperty("user.home") + separator + "ICETests" + separator + "itemData";
String shortFilePath = userDir + separator + "bison_short.yaml";
String mediumFilePath = userDir + separator + "bison_medium.yaml";
String largeFilePath = userDir + separator + "bison.yaml";
String filePath = userDir + separator + "moose_test.yaml";
MOOSEFileHandler handler = new MOOSEFileHandler();
System.out.println("MOOSEFileHandlerTester Message: " + "Checking small sized file.");
// Load the blocks for a file with only a single parent block
ArrayList<TreeComposite> blocks = null;
try {
blocks = handler.loadYAML(shortFilePath);
blocks = handler.loadYAML(filePath);
} catch (IOException e) {
e.printStackTrace();
}
// Check the blocks. This file should only have one block.
assertNotNull(blocks);
assertEquals(3, blocks.size());
assertEquals(42, blocks.size());
assertEquals("Adaptivity", blocks.get(0).getName());
// But that block should have several parameters
parameters = (DataComponent) blocks.get(0).getComponent(1);
assertNotNull(parameters);
assertEquals(3, parameters.retrieveAllEntries().size());
assertEquals(8, parameters.retrieveAllEntries().size());
// And it should also have a couple of exemplar children
assertTrue(blocks.get(0).hasChildExemplars());
assertEquals(2, blocks.get(0).getChildExemplars().size());
System.out.println("MOOSEFileHandlerTester Message: " + "Checking medium sized file.");
// Load the blocks for a file with multiple parent blocks
try {
blocks = handler.loadYAML(mediumFilePath);
} catch (IOException e) {
e.printStackTrace();
}
for (TreeComposite block : blocks) {
System.out.println("Block name = " + block.getName());
}
// Check the blocks
assertNotNull(blocks);
assertEquals(4, blocks.size());
System.out.println("MOOSEFileHandlerTester Message: " + "Checking large sized file.");
// Load the blocks for a file with multiple parent blocks
try {
blocks = handler.loadYAML(largeFilePath);
} catch (IOException e) {
e.printStackTrace();
}
for (TreeComposite block : blocks) {
// System.out.println("Block name = " + block.getName());
}
// Check the blocks
assertNotNull(blocks);
assertEquals(34, blocks.size());
// Verify blocks 17 and 23 are actually AdaptiveTreeComposites
assertTrue(blocks.get(17) instanceof AdaptiveTreeComposite);
assertTrue(blocks.get(23) instanceof AdaptiveTreeComposite);
assertTrue(blocks.get(16) instanceof AdaptiveTreeComposite);
assertTrue(blocks.get(24) instanceof AdaptiveTreeComposite);
return;
......@@ -139,7 +101,7 @@ public class MOOSEFileHandlerTester {
// Local declarations
String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator + "ICETests" + separator + "itemData";
String pathName = userDir + separator + "bison.syntax";
String pathName = userDir + separator + "moose_test.syntax";
// Create a new MOOSEFileHandler
MOOSEFileHandler handler = new MOOSEFileHandler();
......@@ -149,17 +111,17 @@ public class MOOSEFileHandlerTester {
// Verify it loaded an ArrayList correctly
assertNotNull(actionSyntax);
assertEquals(21, actionSyntax.size());
assertEquals(22, actionSyntax.size());
// Verify a couple of the entries
assertEquals("Adaptivity", actionSyntax.get(0));
assertEquals("AuxVariables/*/InitialCondition", actionSyntax.get(1));
assertEquals("BCs/PlenumPressure", actionSyntax.get(4));
assertEquals("Executioner/Adaptivity", actionSyntax.get(10));
assertEquals("ApplyInputParametersTest", actionSyntax.get(1));
assertEquals("Bounds", actionSyntax.get(4));
assertEquals("Executioner/Predictor", actionSyntax.get(10));
assertEquals("Executioner/TimeStepper", actionSyntax.get(13));
assertEquals("GlobalParams", actionSyntax.get(14));
assertEquals("Problem", actionSyntax.get(19));
assertEquals("Variables/*/InitialCondition", actionSyntax.get(20));
assertEquals("PrintMaterials", actionSyntax.get(19));
assertEquals("Problem", actionSyntax.get(20));
// Try loading with an invalid pathname
actionSyntax = handler.loadActionSyntax(null);
......@@ -170,6 +132,23 @@ public class MOOSEFileHandlerTester {
return;
}
/**
* This method finds the child TreeComposite of modelTree that has the given
* String name.
*
* @param name
* @return
*/
private TreeComposite getTreeByName(ArrayList<TreeComposite> blocks, String name) {
for (TreeComposite modelTree : blocks) {
if (modelTree.getName().equals(name)) {
return modelTree;
}
}
return null;
}
/**
* This operation ensures that the MOOSEFileHandler can create a MOOSE input
* file from a set of incoming TreeComposites.
......@@ -180,15 +159,14 @@ public class MOOSEFileHandlerTester {
// Local Declarations
String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator + "ICETests" + separator + "itemData";
String filePath = userDir + separator + "bison_short.yaml";
String inputFilePath = userDir + separator + "bison_short.input";
String outputFilePath = userDir + separator + "bison_short.output";
String refFilePath = userDir + separator + "bison_short.input.ref";
String filePath = userDir + separator + "moose_test.yaml";
String outputFilePath = userDir + separator + "moose_test.i";
String refFilePath = userDir + separator + "moose_test.i.ref";
File outputFile = null;
MOOSEFileHandler handler = new MOOSEFileHandler();
TreeComposite adaptivity = null, indicators = null;
TreeComposite analyticalIndicator = null, fluxJumpIndicator = null;
TreeComposite function = null, variable = null, dispX = null, powerHistory = null;
TreeComposite function = null, powerHistory = null;
// Load the blocks
ArrayList<TreeComposite> blocks = null;
......@@ -199,7 +177,7 @@ public class MOOSEFileHandlerTester {
}
// Create an analytical indicator
adaptivity = blocks.get(0);
adaptivity = getTreeByName(blocks, "Adaptivity");
indicators = (TreeComposite) adaptivity.getChildExemplars().get(0).clone();
analyticalIndicator = (TreeComposite) indicators.getChildExemplars().get(1).clone();
fluxJumpIndicator = (TreeComposite) indicators.getChildExemplars().get(2).clone();
......@@ -232,19 +210,9 @@ public class MOOSEFileHandlerTester {
fluxJumpIndicatorComponent.retrieveEntry("type").setTag("true");
// "property" and "variable" are marked required by the YAML file
// Create a variable. Variable does not have any exemplars in this
// example, so we can just create a tree for this test.
variable = (TreeComposite) blocks.get(2);
dispX = new TreeComposite();
dispX.setName("disp_x");
variable.setNextChild(dispX);
// Activate both nodes
dispX.setActive(true);
variable.setActive(true);
// Create a function
function = (TreeComposite) blocks.get(1);
powerHistory = (TreeComposite) function.getChildExemplars().get(0).clone();
function = (TreeComposite) getTreeByName(blocks, "Functions");
powerHistory = (TreeComposite) function.getChildExemplars().get(14).clone();
// Add the exemplar clone back into the function. Again it *MUST* be
// done this way.
function.setNextChild(powerHistory);
......@@ -276,7 +244,7 @@ public class MOOSEFileHandlerTester {
int firstHash, lastHash;
try {
// Load the input file into a byte array
RandomAccessFile inputFileRAF = new RandomAccessFile(inputFilePath, "r");
RandomAccessFile inputFileRAF = new RandomAccessFile(outputFilePath, "r");
byte[] inputBytes = new byte[(int) inputFileRAF.length()];
inputFileRAF.read(inputBytes);
// Convert to a string
......@@ -351,8 +319,8 @@ public class MOOSEFileHandlerTester {
// Local Declarations
String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator + "ICETests" + separator + "itemData";
String refFilePath = userDir + separator + "bison_short.input.ref";
String outFilePath = userDir + separator + "bison_short.input.out";
String refFilePath = userDir + separator + "moose_test.i.ref";
String outFilePath = userDir + separator + "moose_test.i.out";
// Turn debugging on
System.setProperty("DebugICE", "on");
......@@ -362,8 +330,6 @@ public class MOOSEFileHandlerTester {
// Load the file into a TreeComposite with the Handler
ArrayList<TreeComposite> potTree = handler.loadFromGetPot(refFilePath);
// Hehe... "potTree."
// Write an output file based on the tree that was loaded
handler.dumpInputFile(outFilePath, potTree);
......
......@@ -66,11 +66,6 @@ public class MOOSELauncherTester {
*/
private static MOOSELauncher launcher;
/**
* True if notified by File Entry
*/
private boolean notified = false;
/**
* This operation sets up the workspace. It copies the necessary MOOSE data
* files into ${workspace}/MOOSE.
......@@ -86,8 +81,8 @@ public class MOOSELauncherTester {
String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator
+ "ICETests" + separator + "itemData";
String filePath = userDir + separator + "input_coarse10.i";
String filePath2 = userDir + separator + "input_coarse10_filetest.i";
String filePath = userDir + separator + "mooseModel.i";
// Debug information
System.out.println("MOOSE Test Data File: " + filePath);
......@@ -114,26 +109,17 @@ public class MOOSELauncherTester {
project.open(null);
}
// Create the File handle and input stream for the Bison input
// Create the File handle and input stream for the Moose input
// file
IPath moosePath = new Path(filePath);
File mooseFile = moosePath.toFile();
FileInputStream mooseStream = new FileInputStream(mooseFile);
// Create the file in the workspace for the Bison input file
IFile bisonInputFile = project.getFile("input_coarse10.i");
if (!bisonInputFile.exists()) {
bisonInputFile.create(mooseStream, true, null);
// Create the file in the workspace for the Moose input file
IFile mooseInputFile = project.getFile("mooseModel.i");
if (!mooseInputFile.exists()) {
mooseInputFile.create(mooseStream, true, null);
}
IPath moosePath2 = new Path(filePath2);
File mooseFile2 = moosePath2.toFile();
FileInputStream mooseStream2 = new FileInputStream(mooseFile2);
// Create the file in the workspace for the Bison input file
IFile bisonInputFile2 = project
.getFile("input_coarse10_filetest.i");
if (!bisonInputFile2.exists()) {
bisonInputFile2.create(mooseStream2, true, null);
}
// Refresh the workspace
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
......@@ -182,9 +168,9 @@ public class MOOSELauncherTester {
transitiveItem.setIOService(service);
// Load the input
item.loadInput("input_coarse10.i");
equalItem.loadInput("input_coarse10.i");
transitiveItem.loadInput("input_coarse10.i");
item.loadInput("mooseModel.i");
equalItem.loadInput("mooseModel.i");
transitiveItem.loadInput("mooseModel.i");
// Set ICEObject data
equalItem.setId(item.getId());
......@@ -251,7 +237,7 @@ public class MOOSELauncherTester {
MOOSE mooseItem = new MOOSE(projectSpace);
mooseItem.setIOService(service);
mooseItem.loadInput("input_coarse10.i");
mooseItem.loadInput("mooseModel.i");
mooseItem.setDescription("I am a job!");
mooseItem.setProject(null);
......
......@@ -82,8 +82,8 @@ public class MOOSEModelTester {
String separator = System.getProperty("file.separator");
String userDir = System.getProperty("user.home") + separator
+ "ICETests" + separator + "itemData";
String yamlFile = userDir + separator + "bison.yaml";
String filePath = userDir + separator + "input_coarse10.i";
String yamlFileName = userDir + separator + "moose_test.yaml";
String filePath = userDir + separator + "mooseModel.i";
// Debug information
System.out.println("MOOSE Test Data File: " + filePath);
......@@ -111,26 +111,26 @@ public class MOOSEModelTester {
project.open(null);
}
// Create the File handle and input stream for the Bison YAML
// Create the File handle and input stream for the Moose YAML
// file
IPath bisonPath = new Path(yamlFile);
File bisonFile = bisonPath.toFile();
FileInputStream bisonStream = new FileInputStream(bisonFile);
// Create the file in the workspace for the Bison YAML file
IFile bisonYAMLFile = project.getFile("bison.yaml");
if (!bisonYAMLFile.exists()) {
bisonYAMLFile.create(bisonStream, true, null);
IPath yamlPath = new Path(yamlFileName);
File yamlFile = yamlPath.toFile();
FileInputStream yamlStream = new FileInputStream(yamlFile);
// Create the file in the workspace for the Moose YAML file
IFile yamlYAMLFile = project.getFile("moose_test.yaml");
if (!yamlYAMLFile.exists()) {
yamlYAMLFile.create(yamlStream, true, null);
}
// Create the File handle and input stream for the Bison input
// Create the File handle and input stream for the Moose input
// file
IPath moosePath = new Path(filePath);
File mooseFile = moosePath.toFile();
FileInputStream mooseStream = new FileInputStream(mooseFile);
// Create the file in the workspace for the Bison input file
IFile bisonInputFile = project.getFile("input_coarse10.i");
if (!bisonInputFile.exists()) {
bisonInputFile.create(mooseStream, true, null);
// Create the file in the workspace for the Moose input file
IFile mooseInputFile = project.getFile("mooseModel.i");
if (!mooseInputFile.exists()) {
mooseInputFile.create(mooseStream, true, null);
}
// Refresh the workspace
......@@ -208,7 +208,7 @@ public class MOOSEModelTester {
public void checkProcessing() {
// Local Declarations
String testFilename = "bison_test_file.inp";
String testFilename = "moose_test_file.i";
// Create a MOOSEModel to test
MOOSEModel model = new MOOSEModel(projectSpace);
......@@ -224,11 +224,6 @@ public class MOOSEModelTester {
assertEquals(2, form.getActionList().size());
assertTrue(form.getActionList().contains("Write MOOSE File"));
// FIXME REPLACE WITH PATH TO ICETESTS...
// Entry appName = ((DataComponent) form.getComponent(1))
// .retrieveEntry("MOOSE-Based Application");
// appName.setValue("file:/Users/aqw/ICEFiles_prebuiltMoose/moose/test/moose_test-opt");
// Change the output file name to make sure that it is possible
IEntry outputFileEntry = ((DataComponent) form.getComponent(1))
.retrieveEntry("Output File Name");
......@@ -248,13 +243,13 @@ public class MOOSEModelTester {
/**
* This operation is responsible for ensuring that the MOOSEModel can load
* input. This operation checks this by passing it an input file for Bison.
* input. This operation checks this by passing it an input file for Moose.
*/
@Test
public void checkLoadingInput() {
// Local Declarations
int numMooseBlocks = 20;
int numMooseBlocks = 7;
// Create a MOOSE Item
MOOSEModel mooseItem = new MOOSEModel(projectSpace);
......@@ -263,7 +258,7 @@ public class MOOSEModelTester {
mooseItem.setIOService(service);
// Load the input
mooseItem.loadInput("input_coarse10.i");
mooseItem.loadInput("mooseModel.i");
// Pull the Form
Form form = mooseItem.getForm();
......@@ -299,23 +294,10 @@ public class MOOSEModelTester {
}
// Check all of the block names. They should all be in the tree.
assertTrue(blockNames.contains("GlobalParams"));
assertTrue(blockNames.contains("Problem"));
assertTrue(blockNames.contains("Mesh"));
assertTrue(blockNames.contains("Variables"));
assertTrue(blockNames.contains("AuxVariables"));