diff --git a/org.eclipse.ice.build/pom.xml b/org.eclipse.ice.build/pom.xml index af658bd96d1617fe897a02dafe08016f1cff0615..e0088158ee225bb5413fc4f1cd0a6b04e8fa87e6 100644 --- a/org.eclipse.ice.build/pom.xml +++ b/org.eclipse.ice.build/pom.xml @@ -333,7 +333,7 @@ ../src/org.eclipse.ice.core ../tests/org.eclipse.ice.core.test ../src/org.eclipse.ice.item - ../tests/org.eclipse.ice.item.test + ../src/org.eclipse.ice.persistence.xml ../tests/org.eclipse.ice.persistence.xml.test ../src/org.eclipse.ice.io @@ -362,7 +362,7 @@ ../src/org.eclipse.ice.viz ../tests/org.eclipse.ice.viz.test ../src/org.eclipse.ice.viz.service - ../tests/org.eclipse.ice.viz.service.test + ../src/org.eclipse.ice.viz.service.visit ../tests/org.eclipse.ice.viz.service.visit.test ../src/org.eclipse.ice.xolotl diff --git a/org.eclipse.ice.item.test/.classpath b/org.eclipse.ice.item.test/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..b1dabee38291b97f08cc3a18bee4e65b1e550530 --- /dev/null +++ b/org.eclipse.ice.item.test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.ice.item.test/.gitignore b/org.eclipse.ice.item.test/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d090fe659376464bb51fb85afe6d3db66f09a26e --- /dev/null +++ b/org.eclipse.ice.item.test/.gitignore @@ -0,0 +1,3 @@ +/bin +/target +/itemTesterWorkspace diff --git a/org.eclipse.ice.item.test/.project b/org.eclipse.ice.item.test/.project new file mode 100644 index 0000000000000000000000000000000000000000..cf2cfa7563a3ccc72ca58ddc1c245f2686cb7052 --- /dev/null +++ b/org.eclipse.ice.item.test/.project @@ -0,0 +1,34 @@ + + + org.eclipse.ice.item.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + net.sourceforge.metrics.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + net.sourceforge.metrics.nature + + diff --git a/org.eclipse.ice.item.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.item.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..838bd9d69424290f7e947b867a3b4381e756dad8 --- /dev/null +++ b/org.eclipse.ice.item.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.eclipse.ice.item.test/META-INF/MANIFEST.MF b/org.eclipse.ice.item.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..e918758880f85b634d4ad585e62aa9d5d241b158 --- /dev/null +++ b/org.eclipse.ice.item.test/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ICEItemTest +Bundle-SymbolicName: org.eclipse.ice.item.test +Bundle-Version: 2.0.0 +Fragment-Host: org.eclipse.ice.item;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Import-Package: org.eclipse.ice.core.iCore, + org.eclipse.ice.io.serializable, + org.eclipse.ice.item, + org.eclipse.ice.persistence.xml, + org.osgi.framework;version="1.6.0" +Require-Bundle: org.junit;bundle-version="4.8.1" + diff --git a/org.eclipse.ice.item.test/about.html b/org.eclipse.ice.item.test/about.html new file mode 100644 index 0000000000000000000000000000000000000000..b47b184064814dbe17e056e1e5f5e5dab8a44358 --- /dev/null +++ b/org.eclipse.ice.item.test/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

July 1, 2014

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/org.eclipse.ice.item.test/build.properties b/org.eclipse.ice.item.test/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..cefaa927f34035e6652a46a0291621e83add5488 --- /dev/null +++ b/org.eclipse.ice.item.test/build.properties @@ -0,0 +1,6 @@ + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.junit diff --git a/org.eclipse.ice.item.test/ls_stdout_1.txt b/org.eclipse.ice.item.test/ls_stdout_1.txt new file mode 100644 index 0000000000000000000000000000000000000000..38fc4b543902b9c00a6636b151c081d9aad2a94f --- /dev/null +++ b/org.eclipse.ice.item.test/ls_stdout_1.txt @@ -0,0 +1 @@ +classesdev.propertiesorg.eclipse.ice.item.test-2.0.0.jarlocal-artifacts.propertiesMANIFEST.MFmaven-archiverp2artifacts.xmlp2content.xmlsurefire.propertiessurefire-reportswork \ No newline at end of file diff --git a/org.eclipse.ice.item.test/pom.xml b/org.eclipse.ice.item.test/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..aced53cd375fc29c6a07d9a4fcb9ef82327026b7 --- /dev/null +++ b/org.eclipse.ice.item.test/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + ICE + org.eclipse.ice.build + 2.0.0 + ${pom-filename} + + ICE + org.eclipse.ice.item.test + 2.0.0 + eclipse-test-plugin + \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..5afbc97f283bbefaa4a0dbacf579d1aea7cfd03b --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import org.eclipse.ice.item.AbstractItemBuilder; +import org.eclipse.ice.item.IActionFactory; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.junit.Test; + +/** + * This class is responsible for testing the AbstractItemBuilder. + * + * It use a simple subclass of AbstractItemBuilder that provides the internal + * state and makes sure 1.) that the base class can return it correctly and 2.) + * that the base class can construct an Item correctly. + * + * @author Jay Jay Billings + * + */ +public class AbstractItemBuilderTester { + + /** + * Test method for + * {@link org.eclipse.ice.item.AbstractItemBuilder#getItemName()}. + */ + @Test + public void testGetItemName() { + + // Local Declarations + String name = "test name"; + ItemType type = ItemType.AnalysisSession; + + // Create a FakeItemBuilder + FakeItemBuilder builder = new FakeItemBuilder(); + builder.setNameForTest(name); + builder.setTypeForTest(type); + + // Check them. Again, this is to make sure that the *getters* and the + // (internal) setters work, not that FakeItemBuilder behaves. + assertEquals(name, builder.getItemName()); + assertEquals(type, builder.getItemType()); + + return; + } + + /** + * Test method for + * {@link org.eclipse.ice.item.AbstractItemBuilder#build(org.eclipse.core.resources.IProject)} + * . + */ + @Test + public void testBuild() { + + // Local Declarations + String name = "test name"; + ItemType type = ItemType.AnalysisSession; + IActionFactory fakeFactory = new FakeActionFactory(); + + // Create a FakeItemBuilder + FakeItemBuilder builder = new FakeItemBuilder(); + builder.setNameForTest(name); + builder.setTypeForTest(type); + + // Set the Fake Action Factory Service + builder.setActionFactory(fakeFactory); + + // Do the build + Item item = builder.build(null); + + // Check the fake + IActionFactory returnedFactory = ((TestJobLauncher) item).getActionFactoryForTest(); + assertNotNull(returnedFactory); + + // Check that setupFormWithServices was called + assertTrue(((TestJobLauncher) item).setupFormWithServicesWasCalled()); + + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..5272c10d4c8a22f541e224169ff8c1c9631a9ca2 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import org.eclipse.ice.item.IActionFactory; +import org.eclipse.ice.item.ItemBuilder; +import org.eclipse.ice.item.model.AbstractModelBuilder; +import org.eclipse.ice.materials.IMaterialsDatabase; +import org.junit.Test; + +/** + * This class tests the Model class. Its only test is that the + * IMaterialsDatabase is set as a service, which it checks using a + * FakeModelBuilder that overrides setInstance to create a FakeModel that + * returns the database. The IMaterialsDatabase is implemented by a fake as + * well. + * + * This strategy is OK because the only thing that needs to be tested is that + * the AbstractModel.setServices() operation is correctly implemented, which is + * not affected by overriding AbstractModelBuilder.getInstance(). + * + * @author Jay Jay Billings + * + */ +public class AbstractModelBuilderTester { + + /** + * Test method for + * {@link org.eclipse.ice.item.model.AbstractModelBuilder#setMaterialsDatabase(org.eclipse.ice.materials.IMaterialsDatabase)} + * . + */ + @Test + public void testSetMaterialsDatabase() { + // Create a fake database service and a fake action factory + IMaterialsDatabase fakeService = new FakeMaterialsDatabase(); + IActionFactory factory = new FakeActionFactory(); + + // Create a fake model and set the service + AbstractModelBuilder builder = new FakeModelBuilder(); + builder.setActionFactory(factory); + builder.setMaterialsDatabase(fakeService); + FakeModel model = ((FakeModel) builder.build(null)); + + // Make sure the database service was set + assertNotNull(model.getMaterialsDatabaseForTest()); + assertNotNull(model.getActionFactoryForTest()); + + return; + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ActionTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ActionTester.java new file mode 100644 index 0000000000000000000000000000000000000000..99af28a91de7ef8a3ca68cd4e1396df7a5416ae4 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ActionTester.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import org.eclipse.ice.datastructures.form.Form; + +/** + *

+ * The ActionTester is responsible for testing Actions. + *

+ * + * @author Jay Jay Billings + */ +public class ActionTester { + /** + * + */ + private TestAction testAction; + + /** + *

+ * This operation checks the Action accessors for Forms using a FakeAction. + * It only tests the getForm and submitForm() operations, which are + * implemented by Action, not FakeAction. + *

+ * + */ + @Test + public void checkFormAccessors() { + + // Local Declarations + Form returnedForm = null, updatedForm = new Form(), secondReturnedForm = null; + + // Initialize the action + testAction = new TestAction(); + + // Retrieve the Form and make sure it is not null + returnedForm = testAction.getForm(); + assertNotNull(returnedForm); + + // Add something to the Form and re-submit it + updatedForm.setName("Nurse Chapel"); + testAction.submitForm(updatedForm); + + // Retrieve the Form again and make sure it is correct + secondReturnedForm = testAction.getForm(); + assertNotNull(secondReturnedForm); + assertEquals(updatedForm.getName(), secondReturnedForm.getName()); + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeActionFactory.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeActionFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..90de959c41bcf6d08a1c611b39aeaa4c75c12aff --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeActionFactory.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.ice.item.IActionFactory; + +/** + * This is a fake implementation of the IActionFactory used for testing. + * + * @author Jay Jay Billings + * + */ +public class FakeActionFactory implements IActionFactory { + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeDataComponent.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeDataComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..66ea0131da713fc559bdb4805f162014055f5e75 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeDataComponent.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2011, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.ice.datastructures.form.DataComponent; + +/** + *

+ * The FakeDataComponent class is a subclass of DataComponent that is used for + * testing. + *

+ * + * @author Jay Jay Billings + */ +public class FakeDataComponent extends DataComponent { + + // Updated value + String value; + + @Override + public void update(String key, String newValue) { + this.value = newValue; + } + + /** + *

+ * This operation returns the value that was passed to the update operation + * inherited from DataComponent. + *

+ * + * @return

+ * The value submitted to the update operation. + *

+ */ + public String getUpdatedValue() { + return value; + } + +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeItemBuilder.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeItemBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..65bb47e4e18e05a4f32d1eac100d0f34e7f65b3b --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeItemBuilder.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.item.AbstractItemBuilder; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemBuilder; +import org.eclipse.ice.item.ItemType; + +/** + * This class is used to build TestJobLaunchers for the MultiLauncherTester. + * Calling the build() operation returns an instance of TestJobLauncher + * regardless of the current type retrieved from getItemType(). The ability to + * change the ItemType is only available to make sure the MultiLauncherBuilder + * does not include things other than JobLaunchers. + * + * @author Jay Jay Billings + */ +public class FakeItemBuilder extends AbstractItemBuilder { + + /** + * The constructor + */ + public FakeItemBuilder() { + setName("Selina Kyle"); + setType(ItemType.Simulation); + } + + /** + * This operation sets the name that the builder should return from + * getItemName(); + * + * @param itemName + * The name + */ + public void setNameForTest(String itemName) { + setName(itemName); + } + + /** + * This operation sets the type of the FakeItemBuilder. This does not change + * what the build() operation returns - a TestJobLauncher - but it does + * change the output of getItemType(). + * + * @param itemType + * The ItemType that this builder will report. + */ + public void setTypeForTest(ItemType itemType) { + setType(itemType); + } + + + @Override + protected Item getInstance(IProject projectSpace) { + + Item item = new TestJobLauncher(projectSpace); + item.setName(getItemName()); + + return item; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java new file mode 100644 index 0000000000000000000000000000000000000000..2deeb1d6ac06ece5925fc6bfc225e65e7d00b110 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import java.util.List; + +import org.eclipse.ice.datastructures.form.Material; +import org.eclipse.ice.materials.IMaterialsDatabase; + +import ca.odell.glazedlists.EventList; +import ca.odell.glazedlists.gui.TableFormat; + +/** + * A fake implementation of the IMaterialsDatabase used for testing. + * + * @author Jay Jay Billings + * + */ +public class FakeMaterialsDatabase implements IMaterialsDatabase { + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.materials.IMaterialsDatabase#getMaterials() + */ + @Override + public List getMaterials() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ice.materials.IMaterialsDatabase#addMaterial(org.eclipse. + * ice.datastructures.form.Material) + */ + @Override + public void addMaterial(Material material) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ice.materials.IMaterialsDatabase#deleteMaterial(java.lang + * .String) + */ + @Override + public void deleteMaterial(String name) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ice.materials.IMaterialsDatabase#deleteMaterial(org.eclipse + * .ice.datastructures.form.Material) + */ + @Override + public void deleteMaterial(Material material) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ice.materials.IMaterialsDatabase#updateMaterial(org.eclipse + * .ice.datastructures.form.Material) + */ + @Override + public void updateMaterial(Material material) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.materials.IMaterialsDatabase#restoreDefaults() + */ + @Override + public void restoreDefaults() { + // TODO Auto-generated method stub + + } + + @Override + public EventList getElements() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TableFormat getTableFormat() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java new file mode 100644 index 0000000000000000000000000000000000000000..821128c010079744a1726e08d0a38a5ea68c5d40 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.item.IActionFactory; +import org.eclipse.ice.item.model.Model; +import org.eclipse.ice.materials.IMaterialsDatabase; + +/** + * This is a fake subclass of Model that returns the IMaterialsDatabase so it + * can be used to verify that the AbstractModelBuilder set the service + * correctly. + * + * @author Jay Jay Billings + * + */ +public class FakeModel extends Model { + + /** + * The Constructor + * @param projectSpace + */ + public FakeModel(IProject projectSpace) { + super(projectSpace); + } + + /** + * This operation returns the materials database + * @return the materials database + */ + public IMaterialsDatabase getMaterialsDatabaseForTest() { + return getMaterialsDatabase(); + } + + /** + * This operation returns the action factory + * @return the action factory + */ + public IActionFactory getActionFactoryForTest() { + return getActionFactory(); + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..c7b6612b61b50f69e10b22c99ad73b546685e993 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.model.AbstractModelBuilder; + +/** + * This is a fake model builder that provides a fake model class that will + * return the service reference to the materials database and the action factory + * to make sure the overridden AbstractModelBuilder.setServices works. + * + * @author Jay Jay Billings + * + */ +public class FakeModelBuilder extends AbstractModelBuilder { + + /** + * The constructor + */ + public FakeModelBuilder() { + setName("Eyes on Fire"); + setType(ItemType.AnalysisSession); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject) + */ + @Override + protected Item getInstance(IProject projectSpace) { + return new FakeModel(projectSpace); + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..4fd659adfda3988854c8adf0079fb684ce471366 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorBuilderTester.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.net.URI; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.geometry.GeometryEditor; +import org.eclipse.ice.item.geometry.GeometryEditorBuilder; +import org.junit.Test; + +/** + *

+ * This class is responsible for testing the GeometryEditorBuilder. + *

+ * + * @author Jay Jay Billings + */ +public class GeometryEditorBuilderTester { + /** + *

+ * The instance of the GeometryEditorBuilder under test. + *

+ * + */ + private GeometryEditorBuilder geometryEditorBuilder; + + /** + *

+ * This operations checks the GeometryEditorBuilder to make sure that it + * properly creates GeometryEditors. It also checks the name and the type of + * the GeometryEditorBuilder and the GeometryEditor. + *

+ * + */ + @Test + public void checkConstruction() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + String filename = null; + + // Setup the project workspace + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Instantiate the builder + geometryEditorBuilder = new GeometryEditorBuilder(); + + // Check the name - the static value, the getter and the comparison of + // the two + assertEquals("Geometry Editor", geometryEditorBuilder.name); + assertEquals("Geometry Editor", geometryEditorBuilder.getItemName()); + assertEquals(geometryEditorBuilder.name, + geometryEditorBuilder.getItemName()); + + // Check the type - the static value, the getter and the comparison of + // the two + assertEquals(ItemType.Geometry, geometryEditorBuilder.type); + assertEquals(ItemType.Geometry, geometryEditorBuilder.getItemType()); + assertEquals(geometryEditorBuilder.type, + geometryEditorBuilder.getItemType()); + + // Make sure construction works properly + Item editor = geometryEditorBuilder.build(project); + assertNotNull(editor); + assertTrue(editor instanceof GeometryEditor); + assertEquals("Geometry Editor", editor.getName()); + assertEquals(ItemType.Geometry, editor.getItemType()); + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorTester.java new file mode 100644 index 0000000000000000000000000000000000000000..fa2eeb6dda6728cc18e2012e4edfa124578c501b --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/GeometryEditorTester.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.net.URI; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.junit.Test; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.geometry.GeometryComponent; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.geometry.GeometryEditor; +import org.eclipse.ice.item.geometry.GeometryEditorBuilder; + +/** + *

+ * This class is responsible for testing the GeometryEditor. + *

+ * + * @author Jay Jay Billings + */ +public class GeometryEditorTester { + /** + *

+ * The instance of the GeometryEditor under test. + *

+ * + */ + private GeometryEditor geometryEditor; + + /** + *

+ * This operations checks the GeometryEditor to make sure that it properly + * creates its Form. + *

+ * + */ + @Test + public void checkConstruction() { + + // Local Declarations + GeometryEditor editor = new GeometryEditor(); + Form form = null; + GeometryComponent geomComp = null; + + // Check the Editor's name and type + assertEquals(GeometryEditorBuilder.name, editor.getName()); + assertEquals(GeometryEditorBuilder.type, editor.getItemType()); + + // Check the Form + form = editor.getForm(); + assertNotNull(form); + assertEquals(GeometryEditorBuilder.name, form.getName()); + assertEquals(1, form.getActionList().size()); + assertEquals("Export to ICE Native Format", form.getActionList().get(0)); + + // Get the GeometryComponent and check it + geomComp = (GeometryComponent) form.getComponent(1); + assertNotNull(geomComp); + assertEquals(1, geomComp.getId()); + assertEquals("Geometry Data", geomComp.getName()); + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidator.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..95aab3f0b036093951ca0cb644c6ce4ff21cb8ae --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidator.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +/** + * + * @author Jay Jay Billings + */ +public class ICEDatabaseValidator { +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidatorTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidatorTester.java new file mode 100644 index 0000000000000000000000000000000000000000..da3ebefa69727bafcb07dd37309e76fd11ebea06 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEDatabaseValidatorTester.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.junit.Ignore; + +/** + * + * @author Jay Jay Billings + */ +@Ignore +public class ICEDatabaseValidatorTester { + /** + * + */ + private ICEDatabaseValidator iCEDatabaseValidator; +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEJschUIInfoTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEJschUIInfoTester.java new file mode 100644 index 0000000000000000000000000000000000000000..034029a6101c9f4be0efc8dfd734521b321cfa01 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ICEJschUIInfoTester.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.item.action.LoginInfoForm; +import org.eclipse.ice.item.action.ICEJschUIInfo; + +/** + *

+ * This class is responsible for testing the ICEJschUIInfo class. + *

+ * + * @author Jay Jay Billings + */ +public class ICEJschUIInfoTester { + /** + * + */ + private ICEJschUIInfo iCEJschUIInfo; + + /** + *

+ * This operation ensures that the ICEJschUIInfo class can retrieve a + * password from the LoginInfoForm. + *

+ * + */ + @Test + public void checkPassword() { + + // Local Declarations + LoginInfoForm testForm = new LoginInfoForm(); + DataComponent comp = null; + Entry passwordEntry = null; + String password = null; + String[] keyboardInteractiveArray = null, inputArray = { "D", "E", "F" }; + + // Initialize the UIInfo class + iCEJschUIInfo = new ICEJschUIInfo(); + + // Check the promptPassword() operation before setting the password + assertTrue(!iCEJschUIInfo.promptPassword("Let me just be...")); + + // Make sure the ui info is not ready as well + assertTrue(!iCEJschUIInfo.isReady()); + + // Set the password + comp = (DataComponent) testForm.getComponent(1); + passwordEntry = comp.retrieveEntry("Password"); + passwordEntry.setValue("Georgia"); + iCEJschUIInfo.setForm(testForm); + + // The ui info should now be ready + assertTrue(iCEJschUIInfo.isReady()); + + // Check the promptPassword() operation after setting the password + assertTrue(iCEJschUIInfo.promptPassword("Over cigarettes")); + + // Get the password + assertNotNull(iCEJschUIInfo.getPassword()); + assertEquals("Georgia", iCEJschUIInfo.getPassword()); + + // Some of the return values are not used and should be null or true + assertNull(iCEJschUIInfo.getPassphrase()); + assertTrue(iCEJschUIInfo.promptPassphrase("Early in the morning.")); + assertTrue(!iCEJschUIInfo.promptYesNo("Help me to enjoy...")); + + // Get the password through the keyboard interactive operation + keyboardInteractiveArray = iCEJschUIInfo.promptKeyboardInteractive("A", + "B", "C", inputArray, null); + assertNotNull(keyboardInteractiveArray); + // There should only be on entry in the array + assertEquals(1, keyboardInteractiveArray.length); + assertEquals("Georgia", keyboardInteractiveArray[0]); + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java new file mode 100644 index 0000000000000000000000000000000000000000..d3437cd2fdecbe7ad85c0d5235a880443803cfc0 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java @@ -0,0 +1,1313 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Properties; + +import javax.xml.bind.JAXBException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider; +import org.eclipse.ice.datastructures.resource.ICEResource; +import org.eclipse.ice.datastructures.resource.VizResource; +import org.eclipse.ice.io.serializable.IOService; +import org.eclipse.ice.io.serializable.IReader; +import org.eclipse.ice.io.serializable.IWriter; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemListener; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.messaging.Message; +import org.eclipse.ice.persistence.xml.XMLPersistenceProvider; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + *

+ * The ItemTester is responsible for testing the Item class. + *

+ * + * @author Jay Jay Billings, Anna Wojtowicz + */ +public class ItemTester implements ItemListener { + /** + * An Item used for testing. + */ + private static Item item; + + /** + * This field is used to check the Item's ability to update its listeners. + * It is part of the checkUpdates() test. + */ + private boolean updated = false; + + /** + *

+ * A string initialized to hold the entire contents of an Item in the + * Painfully Simple Form format. It is used for testing across multiple + * tests and is first converted to an InputStream. It contains two Entries + * who have a third Entry as a parent. + *

+ * + */ + private static String psfItemString; + + /** + * Sets up the psfItemString. + */ + @BeforeClass + public static void beforeClass() { + + ArrayList PSFForm = new ArrayList(); + + /** + * Setup the string containing the Form in PSF format. This was taken + * from the Painfully Simple Form article at + * + * https://wiki.eclipse.org/Painfully_Simple_Form + * + * and is a good example because it is complete, contains lots of + * whitespace and comments and, of course, interesting! I have added + * whitespaces and comments in some places to make the test more + * rigorous and changed some of the comment statements from "//" to "#" + * to cover all the possibilities. + */ + PSFForm.add("\t \n"); + PSFForm.add("#Form name and type\n"); + PSFForm.add("formName=PSF Wiki Article Form\n"); + PSFForm.add("formDescription=A PSF Wiki Article Sample\n"); + PSFForm.add("formType=Model\n"); + PSFForm.add(" \n"); + PSFForm.add("#The DataComponents block - it must come first!\n"); + PSFForm.add("group=Assembly\n"); + PSFForm.add("groupDescription=Relevant quantities for modeling a full assembly\n"); + PSFForm.add("\n"); + PSFForm.add("#The Entry blocks will appear below this line"); + PSFForm.add("\n"); + PSFForm.add("\t \n"); + PSFForm.add("#Some comments to ignore at the top\n"); + PSFForm.add("//More comments to ignore at the top\n"); + PSFForm.add("name=Coolant Temperature " + + " #The name that a user " + + "will see\n"); + PSFForm.add("description=The temperature of the coolant that surrounds " + + "the assembly and pins //A description that will help the user\n"); + PSFForm.add("defaultValue=550 " + + " //The default value\n"); + PSFForm.add("allowedValueType=Continuous " + + " //Indicates that the value can be " + + "anything between 550 and 650 K.\n"); + PSFForm.add("allowedValue=550 " + + " //The lower bound of the range\n"); + PSFForm.add("allowedValue=650 " + + " //The upper bound of the range\n"); + PSFForm.add("tag=coolantTemperature " + + " //A tag to mark it\n"); + PSFForm.add("parent=Full Assembly Flag " + + " //The parent\n"); + PSFForm.add("group=Assembly " + + " //The group\n"); + PSFForm.add(" \t \n"); + PSFForm.add("name=Number of Pins\n"); + PSFForm.add("description=The number of pins in an assembly\n"); + PSFForm.add("defaultValue=289\n"); + PSFForm.add("allowedValueType=Discrete\n"); + PSFForm.add("allowedValue=196\n"); + PSFForm.add("allowedValue=289\n"); + PSFForm.add("tag=numberOfPins\n"); + PSFForm.add("parent=Full Assembly Flag\n"); + PSFForm.add("group=Assembly\n"); + PSFForm.add(" \t \n"); + PSFForm.add("name=Full Assembly Flag\n"); + PSFForm.add("description=True if a full assembly should be modeled, false if not\n"); + PSFForm.add("defaultValue=false\n"); + PSFForm.add("allowedValueType=Discrete\n"); + PSFForm.add("allowedValue=true\n"); + PSFForm.add("allowedValue=false\n"); + PSFForm.add("tag=fullAssemblyFlag\n"); + PSFForm.add("group=Assembly\n"); + + // Convert the ArrayList to a string + psfItemString = ""; + for (String i : PSFForm) { + psfItemString += i; + } + + return; + } + + /** + *

+ * This operation sets up test Items for the Item tester. + *

+ * + */ + @Before + public void Before() { + + // Create the Item. We actually need to test a real Item, so implement + // the abstract operations below for a simple test. + item = new TestItem(null); + + return; + } + + /** + *

+ * This operation tests the Item class by creating an Item and checking that + * all of the attributes are either set to the proper default values or to + * the values specified in the constructor. + *

+ */ + @Test + public void createItem() { + + // Check the ID + assertEquals(15, item.getId()); + // Check the type + assertEquals(ItemType.Basic, item.getItemType()); + + // check nullary constructor + Item loadedItem = new Item(); + loadedItem = new Item(); + + // Check the ID + assertEquals(1, loadedItem.getId()); + // Check the type + assertEquals(ItemType.Basic, loadedItem.getItemType()); + + // Set the Item ID and make sure that it updates the Form id + loadedItem.setId(5); + assertEquals(loadedItem.getId(), loadedItem.getForm().getId()); + + // Check default of item's builder. This should be the empty string! + assertEquals("", loadedItem.getItemBuilderName()); + // Check null and empty string + loadedItem.setItemBuilderName(null); + loadedItem.setItemBuilderName(""); + + // Although we check empty string, empty string should not allowed to be + // set on it. Should be null for now. + // But it can still be set again! + assertEquals("", loadedItem.getItemBuilderName()); + + // Set it once + loadedItem.setItemBuilderName("Item's Builder"); + // Check that it is that name + assertEquals("Item's Builder", loadedItem.getItemBuilderName()); + // Try to set again, notice how it does not change + loadedItem.setItemBuilderName("Item's Builder2"); + // Check that it is the name from before + assertEquals("Item's Builder", loadedItem.getItemBuilderName()); + + } + + /** + *

+ * This operation tests the Item to see if its name can be changed properly. + * It first sets the name and then checks the value returned by + * Item.getName(). + *

+ */ + @Test + public void checkName() { + + // Set the name + item.setName("Ozzy"); + // Check the name + assertEquals("Ozzy", item.getName()); + + } + + /** + *

+ * This operation checks the ability of Item to return a Form that is well + * formed for a particular set of Entries. It creates an Item with an + * overloaded Item.fillEntryList() method and checks the Form for these + * Entries. + *

+ */ + @Test + public void checkForm() { + + // Local Declarations + int i = 0; + ArrayList components = new ArrayList(); + Form testForm = item.getForm(); + + // Make sure the form is not null + assertNotNull(testForm); + + // Grab the DataComponents + for (i = 0; i < testForm.getNumberOfComponents(); i++) { + components.add((DataComponent) testForm.getComponent(i + 1)); + } + + // Check the DataComponent names to make sure the Form is real + assertEquals(components.get(0).getName(), "Jay"); + assertEquals(components.get(1).getName(), "David"); + assertEquals(components.get(2).getName(), "Alex"); + assertEquals(components.get(3).getName(), "Bobo the Drunken Clown"); + + // FIXME - It would be preferable to have something like this: + // assertTrue(testForm.contains("Jay")); + // assertTrue(testForm.contains("David")); + // assertTrue(testForm.contains("Alex")); + // assertTrue(testForm.contains("Bobo the Drunken Clown")); + // assertFalse(testForm.contains("Kurt Russell")); + + } + + /** + *

+ * This operation tests the Item class by insuring that Forms can be + * properly submitted. It also checks that the status of the Item after the + * Form is submitted is appropriate. + *

+ */ + @Test + public void checkSubmission() { + + // Local Declarations + Form testForm = null; + DataComponent dc1 = null; + Entry dc1Entry = null; + + // Get the Form and make sure it isn't null + testForm = item.getForm(); + assertNotNull(testForm); + + // Grab the DataComponent + dc1 = (DataComponent) testForm.getComponent(2); + assertNotNull(dc1); + + // Get the Entry + dc1Entry = dc1.retrieveEntry("David's Entry"); + assertNotNull(dc1Entry); + + // Set the value on the Entry + dc1Entry.setValue("ORNL Employee"); + + // Disable the Item + item.disable(true); + assertFalse(item.isEnabled()); + // Make sure that the Form can not be submitted + assertEquals(FormStatus.Unacceptable, item.submitForm(testForm)); + assertEquals(FormStatus.Unacceptable, item.getStatus()); + // Re-enable the Item + item.disable(false); + assertTrue(item.isEnabled()); + + // Submit the updated Form and check its status in two ways + assertEquals(FormStatus.ReadyToProcess, item.submitForm(testForm)); + assertEquals(FormStatus.ReadyToProcess, item.getStatus()); + + // Get the Form and check first DataComponent + dc1 = (DataComponent) testForm.getComponent(1); + assertEquals(((FakeDataComponent) dc1).getUpdatedValue(), + "ORNL Employee"); + + // FIXME - Need to make Action Form submission testable! + + return; + + } + + /** + *

+ * This operation checks the Item to insure that its equals() operation + * works. + *

+ * + */ + @Test + public void checkEquality() { + + // Create DataComponents to test + Item item = new Item(null); + Item equalItem = new Item(null); + Item unEqualItem = new Item(null); + Item transitiveItem = new Item(null); + item.setItemBuilderName("Builder"); + + // Set ICEObject data + equalItem.setId(item.getId()); + transitiveItem.setId(item.getId()); + unEqualItem.setId(2); + + // Set builders + equalItem.setItemBuilderName("Builder"); + unEqualItem.setItemBuilderName("Builder"); + transitiveItem.setItemBuilderName("Builder"); + + // Set names + equalItem.setName(item.getName()); + transitiveItem.setName(item.getName()); + unEqualItem.setName("DC UnEqual"); + + // Assert two equal Items return true + assertTrue(item.equals(equalItem)); + + // Assert two unequal Items return false + assertFalse(item.equals(unEqualItem)); + + // Assert equals() is reflexive + assertTrue(item.equals(item)); + + // Assert the equals() is Symmetric + assertTrue(item.equals(equalItem) && equalItem.equals(item)); + + // Assert equals() is transitive + if (item.equals(equalItem) && equalItem.equals(transitiveItem)) { + assertTrue(item.equals(transitiveItem)); + } else { + fail(); + } + + // Assert equals is consistent + assertTrue(item.equals(equalItem) && item.equals(equalItem) + && item.equals(equalItem)); + assertTrue(!item.equals(unEqualItem) && !item.equals(unEqualItem) + && !item.equals(unEqualItem)); + + // Assert checking equality with null is false + assertFalse(item == null); + + // Assert that two equal objects return same hashcode + assertTrue(item.hashCode() == equalItem.hashCode()); + + // Assert that hashcode is consistent + assertTrue(item.hashCode() == item.hashCode()); + + // Assert that hashcodes from unequal objects are different + assertTrue(item.hashCode() != unEqualItem.hashCode()); + + } + + /** + *

+ * This operation checks the Item to ensure that its copy() and clone() + * operations work as specified. + *

+ * + */ + @Test + public void checkCopying() { + + /* + * The following sets of operations will be used to test the + * "clone and copy" portion of Item. + */ + // Local Declarations + Item cloneItem = new Item(null), copyItem = new Item(null); + + // run clone operations + cloneItem = (Item) item.clone(); + + // check contents + assertEquals(item.getAvailableActions(), + cloneItem.getAvailableActions()); + assertEquals(item.getDescription(), cloneItem.getDescription()); + assertTrue(item.getForm().equals(cloneItem.getForm())); + assertEquals(item.getId(), cloneItem.getId()); + assertEquals(item.getItemType(), cloneItem.getItemType()); + assertEquals(item.getName(), cloneItem.getName()); + assertEquals(item.getStatus(), cloneItem.getStatus()); + + // run copy operation + copyItem.copy(item); + + // check contents + assertEquals(item.getAvailableActions(), copyItem.getAvailableActions()); + assertEquals(item.getDescription(), copyItem.getDescription()); + assertTrue(item.getForm().equals(copyItem.getForm())); + assertEquals(item.getId(), copyItem.getId()); + assertEquals(item.getItemType(), copyItem.getItemType()); + assertEquals(item.getName(), copyItem.getName()); + assertEquals(item.getStatus(), copyItem.getStatus()); + + // run copy operation by passing null + copyItem.copy(null); + + // check contents - nothing has changed + assertEquals(item.getAvailableActions(), copyItem.getAvailableActions()); + assertEquals(item.getDescription(), copyItem.getDescription()); + assertTrue(item.getForm().equals(copyItem.getForm())); + assertEquals(item.getId(), copyItem.getId()); + assertEquals(item.getItemType(), copyItem.getItemType()); + assertEquals(item.getName(), copyItem.getName()); + assertEquals(item.getStatus(), copyItem.getStatus()); + + } + + /** + * This operation checks the ability of the Item to persist itself to XML + * and to load itself from an XML input stream. + * + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + */ + @Test + public void checkXMLPersistence() throws NullPointerException, + JAXBException, IOException { + /* + * The following sets of operations will be used to test the + * "read and write" portion of the Item. It will demonstrate the + * behavior of reading and writing from an + * "XML (inputStream and outputStream)" file. It will use an annotated + * Item to demonstrate basic behavior. + */ + + // Local declarations + Item loadedItem = new Item(); + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(Item.class); + + // Set up item + Item persistedItem = new Item(); + persistedItem.setDescription("I am an item description"); + persistedItem.setId(5); + persistedItem.setName("I am a name!"); + persistedItem.getForm().setItemID(5); + + // persist to an output stream + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + xmlHandler.write(persistedItem, classList, outputStream); + + // Load an Item from the first + loadedItem = (Item) xmlHandler.read(classList, + new ByteArrayInputStream(outputStream.toByteArray())); + // Make sure they match + assertEquals(persistedItem, loadedItem); + + // Check the contents more closely to make sure that Item. + assertEquals(persistedItem.getAvailableActions(), + loadedItem.getAvailableActions()); + assertEquals(persistedItem.getDescription(), + loadedItem.getDescription()); + assertEquals(persistedItem.getForm(), loadedItem.getForm()); + assertEquals(persistedItem.getId(), loadedItem.getId()); + assertEquals(persistedItem.getItemType(), loadedItem.getItemType()); + assertEquals(persistedItem.getName(), loadedItem.getName()); + assertEquals(persistedItem.getStatus(), loadedItem.getStatus()); + + } + + /** + *

+ * This operation checks the SerializedItem using a Painfully Simple Form + * (PSF) file. It checks the name and type of the Item and tries to create + * and check a SerializedItem initialized from the PSF. + *

+ * + */ + @Test + public void checkLoadingFromPSF() { + + // Local Declarations + ByteArrayInputStream stream = null; + Form form = null; + DataComponent dataComp1 = null, dataComp2 = null; + Entry entry = null; + + // Create the InputStream + stream = new ByteArrayInputStream(psfItemString.getBytes()); + + // Load the Item + Item testItem = new Item(null); + try { + testItem.loadFromPSF(stream); + } catch (IOException e) { + e.printStackTrace(); + fail(); + } + + // Check the Item's name and description + assertEquals("PSF Wiki Article Form", testItem.getName()); + assertEquals("A PSF Wiki Article Sample", testItem.getDescription()); + + // Get the Form + form = testItem.getForm(); + assertNotNull(form); + // Check the Form in some random spots - FIXME: Use Form.equals() once + // AJM implements it! + assertEquals("PSF Wiki Article Form", form.getName()); + assertEquals("A PSF Wiki Article Sample", form.getDescription()); + assertEquals(1, form.getNumberOfComponents()); + dataComp1 = (DataComponent) form.getComponent(1); + dataComp2 = (DataComponent) form.getComponent(2); + assertNotNull(dataComp1); + assertEquals("Assembly", dataComp1.getName()); + assertEquals(null, dataComp2);// There should only be one component! + entry = dataComp1.retrieveEntry("Number of Pins"); + assertNotNull(entry); + assertEquals("289", entry.getDefaultValue()); + assertEquals("numberOfPins", entry.getTag()); + + // Try loading the Item from a null stream, which should result in an + // exception + testItem = new Item(null); + try { + testItem.loadFromPSF(null); + } catch (IOException e) { + // Don't do anything because it was supposed to fail! + } + + return; + + } + + /** + *

+ * This operation checks the SerializedItem to make sure that it properly + * reviews the Entries. It uses the psfItemString to create a SerializedItem + * with two Entries who have a third as a parent. It makes sure that + * updating the SerializedItem results in the child Entries being marked as + * ready. + *

+ * + */ + @Test + public void checkEntryReviews() { + + Form form = null; + DataComponent dataComp1 = null, dataComp2 = null; + Entry entry = null; + + System.out.println("PSFItemString = " + psfItemString); + + // Load the SerializedItem from the PSF string + Item testItem = new Item(null); + try { + testItem.loadFromPSF(new ByteArrayInputStream(psfItemString + .getBytes())); + } catch (IOException e) { + // Fail if it can't load + fail(); + } + + // Get the Form + form = testItem.getForm(); + assertNotNull(form); + assertEquals(1, form.getNumberOfComponents()); + + // Get the parent + dataComp1 = (DataComponent) form.getComponent(1); + assertNotNull(dataComp1); + assertEquals("Assembly", dataComp1.getName()); + entry = dataComp1.retrieveEntry("Full Assembly Flag"); + assertNotNull(entry); + assertEquals("Full Assembly Flag", entry.getName()); + assertEquals(null, entry.getParent()); + + // Change its value. By default it is false. + entry.setValue("true"); + + // Submit the Form back to the Item for review + assertEquals(FormStatus.ReadyToProcess, testItem.submitForm(form)); + + // Get the parent + dataComp1 = (DataComponent) form.getComponent(1); + assertNotNull(dataComp1); + assertEquals("Assembly", dataComp1.getName()); + entry = dataComp1.retrieveEntry("Full Assembly Flag"); + assertNotNull(entry); + assertEquals("true", entry.getValue()); + + // Make sure that the children are now marked as ready + assertEquals(3, dataComp1.retrieveReadyEntries().size()); + + return; + + } + + /** + * This operation checks the Item to make sure that by default it offers two + * actions, one for writing the Form to XML and another for writing the + * Entries in the Form as a set of key-value pairs. It also makes sure that + * the Form is written to these two file types if the Item is so directed. + * It also makes sure that processing a disabled Item fails. Finally, it + * pulls the output file handle from the Item and makes sure that the + * default name of the file is set according to the default in the class + * documentation. + * + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + * @throws CoreException + */ + @Test + public void checkProcessing() throws NullPointerException, JAXBException, + IOException, CoreException { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + String filename = null; + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(Item.class); + classList.addAll(new ICEJAXBClassProvider().getClasses()); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Create the Item + item = new TestItem(project); + // Configure the IOService for the Item + IOService ioService = new IOService(); + XMLPersistenceProvider xmlpp = new XMLPersistenceProvider(project); + xmlpp.addBuilder(new TestItemBuilder()); + xmlpp.registerClassProvider(new ICEJAXBClassProvider()); + xmlpp.start(); + ioService.addWriter(xmlpp); + item.setIOService(ioService); + + // Get the available actions. They should be + // "Export to ICE Native Format" and "Export to key-value pair output" + // according to the API. + Form form = item.getForm(); + ArrayList actions = form.getActionList(); + assertNotNull(actions); + assertEquals(2, actions.size()); + assertTrue(actions.contains("Export to ICE Native Format")); + assertTrue(actions.contains("Export to key-value pair output")); + + // Try writing to an action not in the list and make sure it fails + assertEquals( + FormStatus.InfoError, + item.process("Go to the gym because " + + "you've been working too long and you need to exercise " + + "your shoulder.")); + + // Disable the Item + item.disable(true); + // Make sure that the Form can not be submitted + assertEquals(FormStatus.Unacceptable, + item.process("Export to ICE Native Format")); + // Re-enable the Item + item.disable(false); + + // Direct the Item to write the Form to XML + assertEquals(FormStatus.Processed, + item.process("Export to ICE Native Format")); + // Pause the thread so it can have some time to write the file + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + // Get the file that was written when the Item was processed, make sure + // it exists, load it and compare to the original form. + filename = (form.getName() + "_" + form.getId() + ".xml").replaceAll( + "\\s+", "_"); + IFile formXMLFile = project.getFile(filename); + assertTrue(formXMLFile.exists()); + Form loadedForm = (Form) xmlHandler.read(classList, + formXMLFile.getContents()); + assertEquals(form, loadedForm); + + // Delete the file + try { + formXMLFile.delete(true, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(); + } + + // Direct the Item to write the Form to a key-value pair output + assertEquals(FormStatus.Processed, + item.process("Export to key-value pair output")); + + // Get the file, make sure it exists, load it and check it out + filename = (form.getName() + "_" + form.getId() + ".dat").replaceAll( + "\\s+", "_"); + IFile formDatFile = project.getFile(filename); + assertTrue(formDatFile.exists()); + Properties formDatProps = new Properties(); + try { + formDatProps.load(formDatFile.getContents()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + fail(); + } + assertEquals("Awesome", formDatProps.get("jayjaybillings")); + assertEquals("The boss", formDatProps.get("David'sEntry")); + + // Delete the file + try { + formXMLFile.delete(true, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(); + } + + // Setup the name of the output file. According to the documentation it + // should be at + // __processOutput.txt. + String outputFilename = item.getName().replaceAll("\\s+", "_") + "_" + + item.getId() + "_processOutput.txt"; + System.out + .println("ItemTester message: Looking for (shortened) output file name \"" + + outputFilename + "\""); + // Get the output file handle + File outputFile = item.getOutputFile(); + // Make sure it is not null + assertNotNull(outputFile); + // Make sure it contains our short name. It doesn't exactly matter where + // the file is stored, as long as the name is properly set for now. That + // means that the Item has created the file handle per the spec. + String retOutputName = outputFile.getAbsolutePath(); + System.out.println("ItemTester message: Returned Output File Name = " + + retOutputName); + assertTrue(outputFile.getAbsolutePath().contains(outputFilename)); + + // Shut down the project resource + project.close(null); + project.delete(true, null); + + return; + + } + + /** + *

+ * This operation checks the project setup of the Item to ensure that + * calling the constructor with an IProject and Item.setProject() setup the + * project reference such that Item.hasProject() returns true. + *

+ * + */ + @Test + public void checkProjectSetup() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace").toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Setup a project using the constructor + item = new TestItem(project); + assertTrue(item.hasProject()); + + // Make sure that the Item created a preferences directory. The + // setPreferences() operation is a fake that forces the Item to create + // the directory. + ((TestItem) item).setPreferences(); + IFolder preferencesFolder = project.getFolder("Test_Item"); + assertTrue(preferencesFolder.exists()); + + // Setup a project using the setter + item = new TestItem(); + // Check that the output file is not configured yet. + assertNull(item.getOutputFile()); + item.setProject(project); + assertTrue(item.hasProject()); + + // Make sure that calling the setter with null does not re-set or + // overwrite the project (Item.hasProject() should still return true) + item.setProject(null); + assertTrue(item.hasProject()); + + // Make sure that calling the constructor with null does not set the + // project + item = new TestItem(null); + assertEquals(item.hasProject(), false); + + // Make sure that calling the setter with null does not set the project + item = new TestItem(); + item.setProject(null); + assertEquals(item.hasProject(), false); + + // Shut down the project resource + try { + project.close(null); + project.delete(true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + + return; + } + + /** + *

+ * This operation checks the ability of the Item to accept subscribers and + * notify them of changes by forcing an update using the TestItem. It also + * checks the ability of the Item to receive updates from ICE subsystems, + * remote ICE subsystems and external third-party processes. + *

+ * + */ + @Test + public void checkUpdates() { + + // Local Declarations + int id = 1, itemId = 2; + String type = "FILE_UPDATED", content = "Starfleet Academy"; + + // Create the Item + TestItem fakeItem = new TestItem(); + fakeItem.addListener(this); + + // Force the notification + fakeItem.notifyListeners(); + + // Make sure the message was heard + assertTrue(updated); + + // Create a message to test external updates (posts) + Message msg = new Message(); + msg.setId(id); + msg.setItemId(itemId); + msg.setMessage(content); + msg.setType(type); + + // Push the update and check the response + assertTrue(fakeItem.update(msg)); + assertTrue(fakeItem.wasUpdated()); + + return; + } + + /** + * This method tests the {@link Item#getResource(String)} and + * {@link Item#getResource(Entry)} methods. + */ + @Test + public void checkGettingResources() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String projectName = "itemTesterWorkspace"; + String separator = System.getProperty("file.separator"); + String userDir = System.getProperty("user.home") + separator + + "ICETests" + separator + "itemData"; + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject(projectName); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/itemTesterWorkspace + defaultProjectLocation = (new File(userDir + separator + + projectName)).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription(projectName); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + + // Refresh the workspace + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // Catch exception for creating the project + e.printStackTrace(); + fail(); + } + + // Local Declarations + Item item = new Item(project); + ICEResource iceResource = null; + VizResource vizResource = null; + String txtFilePath = project.getLocation().toOSString() + separator + + "txtResource.txt"; + String csvFilePath = project.getLocation().toOSString() + separator + + "csvResource.csv"; + + // Try getting an ICEResource based on a String file path + try { + iceResource = item.getResource(txtFilePath); + } catch (IOException e) { + fail(); + e.printStackTrace(); + } + + // Verify all is well + assertNotNull(iceResource); + assertTrue(iceResource instanceof ICEResource); + + // Try getting a VizResource based on a String file path + try { + vizResource = (VizResource) item.getResource(csvFilePath); + } catch (IOException e) { + fail(); + e.printStackTrace(); + } + + // Verify all is well + assertNotNull(vizResource); + assertTrue(vizResource instanceof VizResource); + + // Now construct a file Entry based on a .e file + Entry entry = new Entry(); + entry.setValue("mesh.e"); + vizResource = null; + + // Try getting a VizResource based on the Entry + try { + vizResource = (VizResource) item.getResource(entry); + } catch (IOException e) { + fail(); + e.printStackTrace(); + } + + // Check the VizResource + assertNotNull(vizResource); + assertTrue(vizResource instanceof VizResource); + + // Shut down the project resource + try { + project.close(null); + project.delete(true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + /** + * This method tests the file copy/move methods on the Item. + */ + @Test + public void checkFileCapabilities() { + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemData"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = new File( + System.getProperty("user.home") + separator + + "ICETests" + separator + "itemData").toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemData"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Setup a project using the constructor + TestItem testItem = new TestItem(project); + assertTrue(testItem.hasProject()); + + // Verify that Item.getFiles() works as expected + ArrayList 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")); + + // Give it something that is not a directory and make sure we + // get no files + files = testItem.getYAMLFiles(project.getLocation().toOSString() + + separator + "bison.yaml"); + assertTrue(files.isEmpty()); + + // Create a new temp directory + IFolder tempDir = project.getFolder("tempDir"); + if (!tempDir.exists()) { + try { + tempDir.create(true, true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + // Now let's check that we can move files from one place to another + // 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()); + + // 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()); + + // 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()); + + // Check we can delete directories + testItem.deleteTestDirectory(tempDir.getLocation().toOSString()); + assertFalse(project.getFolder("tempDir").exists()); + + // Test the directory copy + IFolder limbo = project.getFolder("Directory"); + IFolder newLimbo = project.getFolder("newDirectory"); + if (!newLimbo.exists()) { + try { + newLimbo.create(true, true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + String srcPath = project.getLocation().toOSString() + separator + + project.getFolder("Directory").getName(); + String destPath = project.getLocation().toOSString() + separator + + project.getFolder("newDirectory").getName(); + testItem. copyTestDirectory(srcPath, destPath); + + // Make sure all of the files were copied, then delete them all + ArrayList copiedFiles = new ArrayList(); + copiedFiles.add(new File(destPath + separator + "DeepDirectory" + + separator + "DeeperThanDeep" + separator + "file")); + copiedFiles.add(new File(destPath + separator + "DeepDirectory" + + separator + "DeeperThanDeep")); + copiedFiles.add(new File(destPath + separator + "DeepDirectory" + + separator + "deepFile")); + copiedFiles.add(new File(destPath + separator + "DeepDirectory")); + copiedFiles.add(new File(destPath + separator + "shallowFile")); + copiedFiles.add(new File(destPath)); + + for (File f : copiedFiles) { + assertTrue(f.exists()); + f.delete(); + } + + // Shut down the project resource + try { + project.close(null); + project.delete(true, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return; + } + + /** + * This method checks the Item's ability to get and use an IOService. + */ + @Test + public void checkIOService() { + TestItem testItem = new TestItem(null); + IOService service = new IOService(); + + // Create a fake IReader realization + IReader fakeReader = new IReader() { + + @Override + public Form read(IFile file) { + return new Form(); + } + + @Override + public ArrayList findAll(IFile file, String regex) { + ArrayList fakeEntry = new ArrayList(); + return fakeEntry; + } + + @Override + public String getReaderType() { + return "fake"; + } + + }; + + // Create a fake IWriter realization + IWriter fakeWriter = new IWriter() { + + @Override + public void write(Form formToWrite, IFile file) { + return; + } + + @Override + public void replace(IFile file, String regex, String value) { + return; + } + + @Override + public String getWriterType() { + return "fake"; + } + + }; + + // Test the case that the Item is given a bad IOService + testItem.setIOService(null); + assertNull(testItem.getTestReader()); + assertNull(testItem.getTestWriter()); + + // Add the fakes + service.addReader(fakeReader); + service.addWriter(fakeWriter); + + // Set the service on the Item + testItem.setIOService(service); + + // Test that if the Item specifies the IO type correctly + // they should get valid reader and writer. + assertNotNull(testItem.getTestReader()); + assertNotNull(testItem.getTestWriter()); + assertTrue(fakeReader == testItem.getTestReader()); + assertTrue(fakeWriter == testItem.getTestWriter()); + + return; + } + + /** + * (non-Javadoc) + * + * @see ItemListener#reloadProjectData() + */ + public void reloadProjectData() { + + updated = true; + + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherFormTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherFormTester.java new file mode 100644 index 0000000000000000000000000000000000000000..671f469c60c7999156d349846b165cf797fe0ee0 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherFormTester.java @@ -0,0 +1,776 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.ice.datastructures.ICEObject.Component; +import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; +import org.eclipse.ice.datastructures.ICEObject.ListComponent; +import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +import javax.xml.bind.JAXBException; + +import org.junit.Test; +import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.ResourceComponent; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.TableComponent; +import org.eclipse.ice.datastructures.form.TimeDataComponent; +import org.eclipse.ice.datastructures.form.emf.EMFComponent; +import org.eclipse.ice.datastructures.form.geometry.GeometryComponent; +import org.eclipse.ice.datastructures.form.MasterDetailsComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; +import org.eclipse.ice.datastructures.form.MatrixComponent; +import org.eclipse.ice.datastructures.form.geometry.IShape; +import org.eclipse.ice.datastructures.form.mesh.MeshComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.jobLauncher.JobLauncherForm; + +/** + *

+ * The JobLauncherFormTester is responsible for testing the JobLauncherForm. It + * is primarily focused on testing the number and composition of the Components + * in the JobLauncherForm. It realizes the IComponentVisitor interface to find + * the Parallel Execution Data Component from the JobLauncherForm. + *

+ * + * @author Jay Jay Billings + */ +public class JobLauncherFormTester implements IComponentVisitor { + /** + *

+ * The JobLauncherForm that is under test. + *

+ * + */ + private JobLauncherForm jobLauncherForm; + + /** + *

+ * A reference to store the threadingComponent used in the checkParallelism + * test. + *

+ * + */ + private DataComponent threadingComponent = null; + + /** + *

+ * This operation checks the Components of the JobLauncherForm to make sure + * that they are correct in their number and configuration. It also checks + * the list of input files and makes sure that it can be changed properly. + *

+ * + */ + @Test + public void checkJobLauncherFormComponents() { + + // Local Declarations + ArrayList files = new ArrayList(); + ArrayList retFiles = new ArrayList(); + + // Setup some files for the Form + files.add("testFile1"); + files.add("testFile2"); + files.add("testFile3"); + files.add("testFile4"); + files.add("testFile5"); + + // Create the JobLauncherForm + jobLauncherForm = new JobLauncherForm(); + jobLauncherForm.setInputFiles("Input file", "The input file", files); + + // Check the number of Components in the JobLauncherForm. It should have + // two, a DataComponent and an OutputComponent. + assertEquals(2, jobLauncherForm.getNumberOfComponents()); + + // Get the Entries in the input files component + ArrayList entries = ((DataComponent) jobLauncherForm + .getComponent(1)).retrieveAllEntries(); + // Check the number of Entries in the input files component + assertEquals(1, entries.size()); + // Check the Entries. The Input File Entry should have files.size() + // allowed values. + assertEquals("Input file", entries.get(0).getName()); + retFiles = entries.get(0).getAllowedValues(); + // Check the list of files + assertNotNull(retFiles); + assertEquals(files, retFiles); + + return; + } + + /** + *

+ * This operation makes sure that it is possible to enable and disable + * support for OpenMP, TBB, and MPI in the JobLauncherForm. + *

+ * + */ + @Test + public void checkParallelism() { + + // Local Declarations + Entry openMPEntry = null; + Entry mpiEntry = null; + Entry tBBEntry = null; + + // Create the JobLauncherForm + jobLauncherForm = new JobLauncherForm(); + + // Make sure there is no threading component in the Form + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable OpenMP + jobLauncherForm.enableOpenMP(1, 5, 2); + + // Get the parallel component + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Get the OpenMP Entry and check it + openMPEntry = threadingComponent + .retrieveEntry("Number of OpenMP Threads"); + assertNotNull(openMPEntry); + assertEquals("2", openMPEntry.getDefaultValue()); + assertTrue(openMPEntry.getAllowedValues().contains("1")); + assertTrue(openMPEntry.getAllowedValues().contains("5")); + + // Enable MPI + jobLauncherForm.enableMPI(1, 1024, 512); + + // Check the account code + Entry accountEntry = threadingComponent.retrieveEntry("Account Code/Project Code"); + assertNotNull(accountEntry); + assertEquals("none",accountEntry.getValue()); + assertEquals(accountEntry.getValueType(),AllowedValueType.Undefined); + + // Get the MPI Entry and check it + mpiEntry = threadingComponent.retrieveEntry("Number of MPI Processes"); + assertNotNull(mpiEntry); + assertEquals("512", mpiEntry.getDefaultValue()); + assertTrue(mpiEntry.getAllowedValues().contains("1")); + assertTrue(mpiEntry.getAllowedValues().contains("1024")); + + // Enable TBB + jobLauncherForm.enableTBB(1, 5, 3); + System.err.println(threadingComponent.retrieveAllEntries().size()); + // Get the TBB Entry and check it + tBBEntry = threadingComponent.retrieveEntry("Number of TBB Threads"); + assertNotNull(tBBEntry); + assertEquals("3", tBBEntry.getDefaultValue()); + assertTrue(tBBEntry.getAllowedValues().contains("1")); + assertTrue(tBBEntry.getAllowedValues().contains("5")); + + // Disable TBB, OpenMP and MPI + threadingComponent = null; + jobLauncherForm.disableMPI(); + jobLauncherForm.disableOpenMP(); + jobLauncherForm.disableTBB(); + + // Make sure the "Parallel Execution" component is disabled + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Re-enable the parallelism + jobLauncherForm.enableOpenMP(1, 5, 2); + jobLauncherForm.enableMPI(1, 1024, 512); + jobLauncherForm.enableTBB(1, 5, 3); + + // Disable OpenMP and make sure the component is still available + jobLauncherForm.disableOpenMP(); + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + threadingComponent = null; + + // Re-enable OpenMP and TBB, disable MPI + jobLauncherForm.enableOpenMP(1, 5, 2); + jobLauncherForm.enableTBB(1, 5, 3); + jobLauncherForm.disableMPI(); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + threadingComponent = null; + + // Re-enable MPI and TBB, disable OpenMP + jobLauncherForm.enableMPI(1, 1024, 512); + jobLauncherForm.enableTBB(1, 5, 3); + jobLauncherForm.disableOpenMP(); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Re-enable MPI and OpenMP, disable TBB + jobLauncherForm.enableMPI(1, 1024, 512); + jobLauncherForm.enableOpenMP(1, 5, 3); + jobLauncherForm.disableTBB(); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Re-enable MPI , disable TBB, OpenMP + jobLauncherForm.enableMPI(1, 1024, 512); + jobLauncherForm.disableOpenMP(); + jobLauncherForm.disableTBB(); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Re-enable OpenMP , disable TBB, MPI + jobLauncherForm.disableMPI(); + jobLauncherForm.enableOpenMP(1, 5, 3); + jobLauncherForm.disableTBB(); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Re-enable TBB , disable OpenMP, MPI + jobLauncherForm.disableMPI(); + jobLauncherForm.disableOpenMP(); + jobLauncherForm.enableTBB(1, 5, 2); + + // Make sure the component is still available + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Disable OpenMP and MPI and TBB + jobLauncherForm.disableMPI(); + jobLauncherForm.disableOpenMP(); + jobLauncherForm.disableTBB(); + threadingComponent = null; + + // Make sure the "Parallel Execution" component is disabled + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable OpenMP with bunk values + jobLauncherForm.enableOpenMP(-1, -2, -3); + + // Retrieve the Component + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Get the OpenMP Entry and check it - Everything should be equal to 1 + // since the values were negative + openMPEntry = threadingComponent + .retrieveEntry("Number of OpenMP Threads"); + assertNotNull(openMPEntry); + assertEquals("1", openMPEntry.getDefaultValue()); + assertEquals(1, openMPEntry.getAllowedValues().size()); + assertEquals("1", openMPEntry.getAllowedValues().get(0)); + + // Enable MPI with bunk values + jobLauncherForm.enableMPI(-1, -2, -3); + + // Get the MPI Entry and check it - Everything should be equal to 1 + // since the values were negative + mpiEntry = threadingComponent.retrieveEntry("Number of MPI Processes"); + assertNotNull(mpiEntry); + assertEquals("1", mpiEntry.getDefaultValue()); + assertEquals(1, mpiEntry.getAllowedValues().size()); + assertEquals("1", mpiEntry.getAllowedValues().get(0)); + + // Enable TBB with bunk values + jobLauncherForm.enableTBB(-1, -2, -3); + + // Retrieve the Component + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNotNull(threadingComponent); + + // Get the TBBEntry and check it - Everything should be equal to 1 + // since the values were negative + tBBEntry = threadingComponent.retrieveEntry("Number of TBB Threads"); + assertNotNull(tBBEntry); + assertEquals("1", tBBEntry.getDefaultValue()); + assertEquals(1, tBBEntry.getAllowedValues().size()); + assertEquals("1", tBBEntry.getAllowedValues().get(0)); + + // Disable TBB, OpenMP and MPI + threadingComponent = null; + jobLauncherForm.disableTBB(); + jobLauncherForm.disableMPI(); + jobLauncherForm.disableOpenMP(); + + // Enable OpenMP with more bunk values - Out of order + jobLauncherForm.enableOpenMP(54, 2, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable OpenMP with more bunk values - Bad default + jobLauncherForm.enableOpenMP(54, 56, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable MPI with more bunk values - Bad default + jobLauncherForm.enableMPI(54, 56, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable TBB with more bunk values - Bad default + jobLauncherForm.enableTBB(54, 56, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable TBB with more bunk values - Out of Order + jobLauncherForm.enableTBB(58, 56, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + // Enable MPI with more bunk values - Out of order + jobLauncherForm.enableOpenMP(54, 2, 1); + + // The parallel component should not be enabled because those values are + // bad in some way + for (Component i : jobLauncherForm.getComponents()) { + i.accept(this); + } + assertNull(threadingComponent); + + return; + + } + + /** + *

+ * An operation that checks the equals and hashCode operations. + *

+ * + */ + @Test + public void checkEquality() { + // Create JobLauncherForms to test + JobLauncherForm form = new JobLauncherForm(); + JobLauncherForm equalForm = new JobLauncherForm(); + JobLauncherForm unEqualForm = new JobLauncherForm(); + JobLauncherForm transitiveForm = new JobLauncherForm(); + + // Set ICEObject data + equalForm.setId(form.getId()); + transitiveForm.setId(form.getId()); + unEqualForm.setId(2); + + // Set names + equalForm.setName(form.getName()); + transitiveForm.setName(form.getName()); + unEqualForm.setName("DC UnEqual"); + + // Assert two equal Forms return true + assertTrue(form.equals(equalForm)); + + // Assert two unequal Forms return false + assertFalse(form.equals(unEqualForm)); + + // Assert equals() is reflexive + assertTrue(form.equals(form)); + + // Assert the equals() is Symmetric + assertTrue(form.equals(equalForm) && equalForm.equals(form)); + + // Assert equals() is transitive + if (form.equals(equalForm) && equalForm.equals(transitiveForm)) { + assertTrue(form.equals(transitiveForm)); + } else { + fail(); + } + + // Assert equals is consistent + assertTrue(form.equals(equalForm) && form.equals(equalForm) + && form.equals(equalForm)); + assertTrue(!form.equals(unEqualForm) && !form.equals(unEqualForm) + && !form.equals(unEqualForm)); + + // Assert checking equality with null is false + assertFalse(form==null); + + // Assert that two equal objects return same hashcode + assertTrue(form.equals(equalForm) + && form.hashCode() == equalForm.hashCode()); + + // Assert that hashcode is consistent + assertTrue(form.hashCode() == form.hashCode()); + + // Assert that hashcodes from unequal objects are different + assertTrue(form.hashCode() != unEqualForm.hashCode()); + + } + + /** + * An operation that tests xml persistence on JobLauncherForm. + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + */ + @Test + public void checkXMLPersistence() throws NullPointerException, JAXBException, IOException { + + /* + * The following sets of operations will be used to test the + * "read and write" portion of the JobLauncherForm Form. It will + * demonstrate the behavior of reading and writing from an + * "XML (inputStream and outputStream)" file. It will use an annotated + * Form to demonstrate basic behavior. + */ + + // Local Declarations + JobLauncherForm jobForm = new JobLauncherForm(); + JobLauncherForm loadedForm = new JobLauncherForm(); + ArrayList actions = new ArrayList(); + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(JobLauncherForm.class); + classList.addAll(new ICEJAXBClassProvider().getClasses()); + + // Setup a JobLauncherForm + jobForm.setName("I AM NEW!"); + jobForm.setDescription("Oh Somewhat NEW?!"); + jobForm.setId(3); + jobForm.enableMPI(2, 4, 2); + jobForm.enableOpenMP(2, 4, 3); + + // Add an action to the Form + actions.add("I am an action!"); + jobForm.setActionList(actions); + jobForm.setInputFiles("Input file", "The input file", + new ArrayList()); + + // persist to an output stream + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + xmlHandler.write(jobForm, classList, outputStream); + + // Load an Item from the first + loadedForm = (JobLauncherForm) xmlHandler.read(classList, new ByteArrayInputStream(outputStream + .toByteArray())); + // Make sure they match + assertTrue(jobForm.equals(loadedForm)); + + } + + /** + *

+ * Checks the copy and clone routines on JobLauncherForm. + *

+ * + */ + @Test + public void checkCopying() { + /* + * The following sets of operations will be used to test the + * "clone and copy" portion of JobLauncherForm. + */ + // Local Declarations + Form cloneForm = null, copyForm = new JobLauncherForm(); + JobLauncherForm jobForm = new JobLauncherForm(); + ArrayList actions = new ArrayList(); + + jobForm.setName("I AM NEW!"); + jobForm.setDescription("Oh Somewhat NEW?!"); + jobForm.setId(3); + + actions.add("I am an action!"); + jobForm.setActionList(actions); + jobForm.setInputFiles("Input file", "The input file", + new ArrayList()); + jobForm.enableMPI(2, 4, 2); + jobForm.enableOpenMP(2, 4, 3); + + // Copy contents + copyForm.copy(jobForm); + + // Check that it is equal + assertTrue(jobForm.equals(copyForm)); + + // Clone it + cloneForm = (Form) jobForm.clone(); + + // check that it is equal + assertTrue(jobForm.equals(cloneForm)); + + // pass null - Does not effect copy + copyForm.copy(null); + + // Nothing has changed + assertTrue(jobForm.equals(copyForm)); + + } + + /** + *

+ * This operation checks the JobLauncherForm to ensure that it can manage + * multiple input files. + *

+ * + */ + @Test + public void checkMultipleInputFiles() { + + // Local Declarations + ArrayList files1 = new ArrayList(), files2 = null, files3 = null; + ArrayList retFiles = new ArrayList(); + String filename1 = "Input file", filename2 = "Other input file", filename3 = "Final input file"; + String desc1 = filename1 + "description", desc2 = filename2 + + "description", desc3 = filename3 + "description"; + + // Setup some files for the Form + files1.add("testFile1"); + files1.add("testFile2"); + files1.add("testFile3"); + files1.add("testFile4"); + files1.add("testFile5"); + files2 = new ArrayList(files1.subList(0, 3)); + files3 = new ArrayList(files1.subList(0, 2)); + + // Create the JobLauncherForm + jobLauncherForm = new JobLauncherForm(); + jobLauncherForm.setInputFiles(filename1, desc1, files1); + jobLauncherForm.setInputFiles(filename2, desc2, files2); + jobLauncherForm.setInputFiles(filename3, desc3, files3); + + // Check the number of Components in the JobLauncherForm. It should have + // two, a DataComponent and an OutputComponent. + assertEquals(2, jobLauncherForm.getNumberOfComponents()); + + // Get the Entries + ArrayList entries = ((DataComponent) jobLauncherForm + .getComponent(1)).retrieveAllEntries(); + + // Check the number of Entries in the Platform component. There should + // be one entry each for the three input files. + assertEquals(3, entries.size()); + + // Check the first file set. The Input File Entry should have + // files.size() + // allowed values. + assertEquals(filename1, entries.get(0).getName()); + retFiles = entries.get(0).getAllowedValues(); + assertNotNull(retFiles); + assertEquals(files1.size(), retFiles.size()); + assertEquals(files1, retFiles); + + // Check the second file set + assertEquals(filename2, entries.get(1).getName()); + retFiles = entries.get(1).getAllowedValues(); + assertNotNull(retFiles); + assertEquals(files2.size(), retFiles.size()); + assertEquals(files2, retFiles); + + // Check the third file set + assertEquals(filename3, entries.get(2).getName()); + retFiles = entries.get(2).getAllowedValues(); + assertNotNull(retFiles); + assertEquals(files3.size(), retFiles.size()); + assertEquals(files3, retFiles); + + // Check the fourth file set + assertEquals(filename3, entries.get(2).getName()); + retFiles = entries.get(2).getAllowedValues(); + assertNotNull(retFiles); + assertEquals(files3.size(), retFiles.size()); + assertEquals(files3, retFiles); + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(DataComponent component) + */ + + public void visit(DataComponent component) { + + // We only care about the "Parallel Exectuion" Data component in this + // test + if ("Parallel Execution".equals(((DataComponent) component).getName())) { + threadingComponent = (DataComponent) component; + } + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(ResourceComponent component) + */ + public void visit(ResourceComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(TableComponent component) + */ + public void visit(TableComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(MatrixComponent component) + */ + public void visit(MatrixComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(IShape component) + */ + public void visit(IShape component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(GeometryComponent component) + */ + public void visit(GeometryComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(MasterDetailsComponent component) + */ + public void visit(MasterDetailsComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(TreeComposite component) + */ + public void visit(TreeComposite component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(IReactorComponent component) + */ + public void visit(IReactorComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(TimeDataComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(MeshComponent component) { + // TODO Auto-generated method stub + + } + + + @Override + public void visit(AdaptiveTreeComposite component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(EMFComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(ListComponent component) { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherTester.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f4ea39740ec4eae7b3d500ca593749469ed88f --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherTester.java @@ -0,0 +1,962 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URI; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.junit.Test; +import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.form.TableComponent; +import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider; +import org.eclipse.ice.item.action.LoginInfoForm; +import org.eclipse.ice.item.jobLauncher.JobLauncher; +import org.eclipse.ice.item.jobLauncher.JobLauncherForm; + +import java.util.ArrayList; +import java.util.Random; + +import javax.xml.bind.JAXBException; + +/** + * This class is responsible for testing the JobLauncher class. + * @author Jay Jay Billings + */ +public class JobLauncherTester { + + /** + * A fake JobLauncher to use for testing. + */ + private TestJobLauncher jobLauncher; + + /** + *

+ * This operations attempts to put the JobLauncher in the + * FormStatus.NeedsInfo state by setting the hostname to something other + * than localhost. It retrieves the Form from the Item after than and makes + * sure that it is actually a LoginInfoForm and not a JobLauncherForm. + *

+ * + */ + @Test + public void checkLoginInfoForm() { + + // Local declarations + Form form = null; + TableComponent hostsTable = null; + FormStatus status = FormStatus.InfoError; + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + // Enable debugging + System.setProperty("DebugICE", ""); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Instantiate the JobLauncher + jobLauncher = new TestJobLauncher(project); + + // Get the Form + form = jobLauncher.getForm(); + assertNotNull(form); + + // Get the hosts table + hostsTable = (TableComponent) form + .getComponent(JobLauncherForm.parallelId + 1); + assertNotNull(hostsTable); + // Select the first row in the table to denote the selected host + ArrayList selectedRowList = new ArrayList(); + selectedRowList.add(0); + hostsTable.setSelectedRows(selectedRowList); + + // Submit the Form + status = jobLauncher.submitForm(form); + assertEquals(FormStatus.ReadyToProcess, status); + + // Process the Item + status = jobLauncher.process("Launch the Job"); + + // Check the status + assertEquals(FormStatus.NeedsInfo, status); + + // Get the Form and check it + form = jobLauncher.getForm(); + assertNotNull(form); + assertTrue(form instanceof LoginInfoForm); + + return; + + } + + /** + *

+ * This operations makes sure that it is possible to add and remove hosts + * from the JobLauncher. + *

+ * + */ + @Test + public void checkHosts() { + // Local Declarations + ArrayList list = new ArrayList(); + + // Setup Conditions + jobLauncher = new TestJobLauncher(null); + + // Test getHost to make sure it is initialized when constructor is used + assertNotNull(jobLauncher.getAllHosts()); + // It should have one host in there at the moment (notlocalhost) + assertEquals(1, jobLauncher.getAllHosts().size()); + + // Try to add hosts + jobLauncher.addHost("blah.blah.gov", "Windows 7 x64", "C:\\myProgram"); + jobLauncher.addHost("one.two.com", "Linux x86_x64", "home\\usr"); + jobLauncher.addHost("Hay.org", "MacOSX 10.4", "SomeDirectory"); + jobLauncher.addHost("tokyo.jp", "Playstation 3 OS", "home\\usr"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertEquals(5, list.size()); + assertEquals("notlocalhost", list.get(0)); + assertEquals("blah.blah.gov", list.get(1)); + assertEquals("one.two.com", list.get(2)); + assertEquals("Hay.org", list.get(3)); + assertEquals("tokyo.jp", list.get(4)); + + // add a duplicate host - check contents + jobLauncher.addHost("blah.blah.gov", "Windows 7 x64", "C:\\myProgram"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 5); + + // Add for null - hostname + jobLauncher.addHost(null, "Windows 7 x64", "C:\\myProgram"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 5); + + // Add for null - os + jobLauncher.addHost("blah.blah.gov", null, "C:\\myProgram"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 5); + + // Add for null - path + jobLauncher.addHost("blah.blah.gov", "Windows 7 x64", null); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 5); + + // Delete items with hostname + jobLauncher.deleteHost("blah.blah.gov"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 4); + + // Delete something that does not exist + jobLauncher.deleteHost("blah.blah.gov"); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 4); + + // Delete null + jobLauncher.deleteHost(null); + + // Get the hosts - check + list = jobLauncher.getAllHosts(); + assertFalse(list.isEmpty()); + assertEquals(list.size(), 4); + + return; + } + + /** + *

+ * This operation makes sure that it is possible to enable and disable + * support for TBB, OpenMP and MPI in the JobLauncher. + *

+ * + */ + @Test + public void checkEnablingParallelism() { + // Local Declarations: + JobLauncherForm form; + DataComponent dataC; + Entry entry; + + // check MPI + jobLauncher = new TestJobLauncher(null); + jobLauncher.setupForm(); + + // Legit use of enable + jobLauncher.enableMPI(1, 5, 2); + + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // 0 - set to 1 + jobLauncher.enableMPI(0, 5, 2); + + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // negative minimum + jobLauncher.enableMPI(-1, 5, 2); + + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Max less than minimum + jobLauncher.enableMPI(5, 2, 1); + + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // disable + jobLauncher.disableMPI(); + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + + // Should not have MPI - total number of components should be 3 + assertEquals(form.getComponents().size(), 3); + + // disable again, see if it breaks + jobLauncher.disableMPI(); + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + + // Should not have MPI - total number of components should be 3 + assertEquals(form.getComponents().size(), 3); + + // check OpenMP + // Just see if it crashes or not + // Legit use of enable + jobLauncher.enableOpenMP(1, 5, 2); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // 0 - set to 1 + jobLauncher.enableOpenMP(0, 5, 2); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals("2",entry.getValue()); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // negative minimum + jobLauncher.enableOpenMP(-1, 5, 2); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Max less than minimum + jobLauncher.enableOpenMP(5, 2, 1); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // disable + jobLauncher.disableOpenMP(); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + + entry = (Entry) dataC.retrieveAllEntries().get(0); + // Should not have MPI - total number of components should be 3 + assertEquals(form.getComponents().size(), 3); + + // disable again, see if it breaks + jobLauncher.disableOpenMP(); + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + + // Should not have MPI - total number of components should be 3 + assertEquals(form.getComponents().size(), 3); + + jobLauncher = new TestJobLauncher(null); + jobLauncher.setupForm(); + + // Enable them both + jobLauncher.enableMPI(1, 5, 2); + jobLauncher.enableOpenMP(1, 5, 2); + + // Check the dataComponent, see if they are both there + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + assertNotNull(entry); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Get the MPI data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values - nothing changed + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + jobLauncher = new TestJobLauncher(null); + jobLauncher.setupForm(); + + // Try to enable when the MPI or openMP is not created + jobLauncher.enableMPI(-1, 2, 3); + jobLauncher.enableOpenMP(-1, 2, 3); + + // Get the OpenMP data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + + // Should not have MPI - total number of components should be 3 + assertEquals(form.getComponents().size(), 3); + + // Tests for TBB + jobLauncher.enableTBB(1, 5, 3); + + // Get the data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveAllEntries().get(1); + + // Check values + assertEquals(entry.getValue(), "3"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Enable TBB with OpenMP and MPI + jobLauncher.enableTBB(1, 5, 3); + jobLauncher.enableMPI(1, 5, 4); + jobLauncher.enableOpenMP(1, 5, 2); + + // Get the data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveEntry("Number of TBB Threads"); + + // Check values - TBB + assertEquals(entry.getValue(), "3"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + entry = (Entry) dataC.retrieveEntry("Number of MPI Processes"); + // Check values - MPI + assertEquals(entry.getValue(), "4"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + entry = (Entry) dataC.retrieveEntry("Number of OpenMP Threads"); + // Check values - OpenMP + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Disable TBB + jobLauncher.disableTBB(); + + // Get the data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveEntry("Number of TBB Threads"); + + // Check values - TBB + assertNull(entry); + + // Check values - MPI + entry = (Entry) dataC.retrieveEntry("Number of MPI Processes"); + assertEquals(entry.getValue(), "4"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Check values - OpenMP + entry = (Entry) dataC.retrieveEntry("Number of OpenMP Threads"); + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Try to enable a bad TBB - out of order + jobLauncher.enableTBB(20, 10, 5); + // Get the data component and the respective values + form = (JobLauncherForm) jobLauncher.getForm(); + dataC = (DataComponent) form.getComponents().get(3); + entry = (Entry) dataC.retrieveEntry("Number of TBB Threads"); + + // Check values - TBB + assertNull(entry); + + // Check values - MPI + entry = (Entry) dataC.retrieveEntry("Number of MPI Processes"); + assertEquals(entry.getValue(), "4"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Check values - OpenMP + entry = (Entry) dataC.retrieveEntry("Number of OpenMP Threads"); + assertEquals(entry.getValue(), "2"); + assertEquals(entry.getAllowedValues().get(0), "1"); + assertEquals(entry.getAllowedValues().get(1), "5"); + + // Enable TBB, disable the rest, show that only TBB exists + jobLauncher.enableTBB(3, 20, 5); + jobLauncher.disableMPI(); + jobLauncher.disableOpenMP(); + + // Check values - TBB + entry = (Entry) dataC.retrieveEntry("Number of TBB Threads"); + assertEquals(entry.getValue(), "5"); + assertEquals(entry.getAllowedValues().get(0), "3"); + assertEquals(entry.getAllowedValues().get(1), "20"); + + // Check values - MPI + entry = (Entry) dataC.retrieveEntry("Number of MPI Processes"); + assertNull(entry); + + // Check values - OpenMP + entry = (Entry) dataC.retrieveEntry("Number of OpenMP Threads"); + assertNull(entry); + + // Disable TBB thread, show that component disappears + jobLauncher.disableTBB(); + assertNull(form.getComponent(dataC.getId())); + + } + + /** + *

+ * This operation checks the JobLauncher to ensure that its equals() + * operation works. + *

+ * + */ + @Test + public void checkEquality() { + + // Create JobLauncherItems to test + JobLauncher item = new JobLauncher(); + JobLauncher equalItem = new JobLauncher(); + JobLauncher unEqualItem = new JobLauncher(); + JobLauncher transitiveItem = new JobLauncher(); + + // Set ICEObject data + equalItem.setId(item.getId()); + transitiveItem.setId(item.getId()); + unEqualItem.setId(2); + + // Set names + equalItem.setName(item.getName()); + transitiveItem.setName(item.getName()); + unEqualItem.setName("DC UnEqual"); + + // Assert two equal Items return true + assertTrue(item.equals(equalItem)); + + // Assert two unequal Items return false + assertFalse(item.equals(unEqualItem)); + + // Assert equals() is reflexive + assertTrue(item.equals(item)); + + // Assert the equals() is Symmetric + assertTrue(item.equals(equalItem) && equalItem.equals(item)); + + // Assert equals() is transitive + if (item.equals(equalItem) && equalItem.equals(transitiveItem)) { + assertTrue(item.equals(transitiveItem)); + } else { + fail(); + } + + // Assert equals is consistent + assertTrue(item.equals(equalItem) && item.equals(equalItem) + && item.equals(equalItem)); + assertTrue(!item.equals(unEqualItem) && !item.equals(unEqualItem) + && !item.equals(unEqualItem)); + + // Assert checking equality with null is false + assertFalse(item==null); + + // Assert that two equal objects return same hashcode + assertTrue(item.equals(equalItem) + && item.hashCode() == equalItem.hashCode()); + + // Assert that hashcode is consistent + assertTrue(item.hashCode() == item.hashCode()); + + // Assert that hashcodes from unequal objects are different + assertTrue(item.hashCode() != unEqualItem.hashCode()); + + } + + /** + *

+ * This operation checks the JobLauncher to ensure that its copy() and + * clone() operations work as specified. + *

+ * + */ + @Test + public void checkCopying() { + + // Local Declarations + JobLauncher cloneItem = new JobLauncher(null), copyItem = new JobLauncher( + null); + JobLauncher jobItem = new JobLauncher(); + + jobItem.setDescription("I am a job!"); + jobItem.setExecutable("LS", "/opt/bin", "DOIT!!!!"); + jobItem.setProject(null); + + // run clone operations + cloneItem = (JobLauncher) jobItem.clone(); + + // check contents + assertEquals(jobItem.getAvailableActions(), + cloneItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), cloneItem.getDescription()); + assertTrue(jobItem.getForm().equals(cloneItem.getForm())); + assertEquals(jobItem.getId(), cloneItem.getId()); + assertEquals(jobItem.getItemType(), cloneItem.getItemType()); + assertEquals(jobItem.getName(), cloneItem.getName()); + assertEquals(jobItem.getStatus(), cloneItem.getStatus()); + assertEquals(jobItem.getAllHosts(), cloneItem.getAllHosts()); + + // run copy operation + copyItem.copy(jobItem); + + // check contents + assertEquals(jobItem.getAvailableActions(), + copyItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), copyItem.getDescription()); + assertTrue(jobItem.getForm().equals(copyItem.getForm())); + assertEquals(jobItem.getId(), copyItem.getId()); + assertEquals(jobItem.getItemType(), copyItem.getItemType()); + assertEquals(jobItem.getName(), copyItem.getName()); + assertEquals(jobItem.getStatus(), copyItem.getStatus()); + assertEquals(jobItem.getAllHosts(), copyItem.getAllHosts()); + + // run copy operation by passing null + copyItem.copy(null); + + // check contents - nothing has changed + assertEquals(jobItem.getAvailableActions(), + copyItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), copyItem.getDescription()); + assertTrue(jobItem.getForm().equals(copyItem.getForm())); + assertEquals(jobItem.getId(), copyItem.getId()); + assertEquals(jobItem.getItemType(), copyItem.getItemType()); + assertEquals(jobItem.getName(), copyItem.getName()); + assertEquals(jobItem.getStatus(), copyItem.getStatus()); + assertEquals(jobItem.getAllHosts(), copyItem.getAllHosts()); + + return; + } + + /** + * This operation checks the ability of the JobLauncher to persist itself to + * XML and to load itself from an XML input stream. + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + */ + @Test + public void checkXMLPersistence() throws NullPointerException, JAXBException, IOException { + /* + * The following sets of operations will be used to test the + * "read and write" portion of the JobLauncher Item. It will demonstrate + * the behavior of reading and writing from an + * "XML (inputStream and outputStream)" file. It will use an annotated + * Item to demonstrate basic behavior. + */ + + // Local declarations + JobLauncher loadedItem = new JobLauncher(); + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(JobLauncher.class); + classList.addAll(new ICEJAXBClassProvider().getClasses()); + + // Set up item + JobLauncher persistedItem = new JobLauncher(); + persistedItem.setDescription("JobLauncher item description"); + persistedItem.setId(5); + persistedItem.setName("Name!"); + persistedItem.getForm().setItemID(6); + + // persist to an output stream + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + xmlHandler.write(persistedItem, classList, outputStream); + + // Load an Item from the first + loadedItem = (JobLauncher) xmlHandler.read(classList,new ByteArrayInputStream(outputStream + .toByteArray())); + // Make sure they match + assertEquals(persistedItem, loadedItem); + + // Check the contents more closely to make sure that JobLauncher Item. + assertEquals(persistedItem.getAvailableActions(), + loadedItem.getAvailableActions()); + assertEquals(persistedItem.getDescription(), + loadedItem.getDescription()); + assertEquals(persistedItem.getForm(), loadedItem.getForm()); + assertEquals(persistedItem.getId(), loadedItem.getId()); + assertEquals(persistedItem.getItemType(), loadedItem.getItemType()); + assertEquals(persistedItem.getName(), loadedItem.getName()); + assertEquals(persistedItem.getStatus(), loadedItem.getStatus()); + assertTrue(persistedItem.getAllHosts().equals(loadedItem.getAllHosts())); + + return; + } + + /** + *

+ * This operation checks the JobLauncher to ensure that it can manage + * multiple input files. + *

+ * + */ + @Test + public void checkMultipleInputFiles() { + + // Local Declarations + String name = "JLwMF"; // JobLauncher with Multiple Files + String desc = "Duritanium Alloy"; + int numFiles = 0, numExtraFiles = 0, totalFiles = 0; + Form jobForm = null; + DataComponent fileComponent = null; + ArrayList fileEntries = null; + Random rng = new Random(2013052111); + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription projectDesc = ResourcesPlugin + .getWorkspace().newProjectDescription( + "itemTesterWorkspace"); + // Set the location of the project + projectDesc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(projectDesc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Set up the launcher + JobLauncher launcher = new JobLauncher(project); + launcher.setDescription("JobLauncher with multiple files"); + launcher.setId(5); + launcher.setName(name); + + // Get the form and make sure that there is only one file to start + jobForm = launcher.getForm(); + assertNotNull(jobForm); + fileComponent = (DataComponent) jobForm.getComponent(1); + assertNotNull(fileComponent); + fileEntries = fileComponent.retrieveAllEntries(); + numFiles = fileEntries.size(); + assertEquals(1, numFiles); + + // Add a few files + numExtraFiles = rng.nextInt(50) + 1; // +1 such that at least one added + totalFiles = 1 + numExtraFiles; // 1 by default + the extras + for (int i = 0; i < numExtraFiles; i++) { + launcher.addInputType(name + " " + i, name + i + "File", desc + " " + + i, null); + } + + // Check that the files were added + numFiles = fileEntries.size(); + assertEquals(totalFiles, numFiles); + + // Check the names and descriptions + for (int i = 1; i < totalFiles; i++) { + assertEquals(name + " " + (i - 1), fileEntries.get(i).getName()); + assertEquals(desc + " " + (i - 1), fileEntries.get(i) + .getDescription()); + } + + return; + } + + /** + *

+ * This operation insures that the JobLauncher properly refreshes after + * being issued a reload command. + *

+ * + */ +// @Test + public void checkDataReload() { + + // Local Declarations + String name = "JLwMF&R.test"; // JobLauncher with Multiple Files + String desc = "Duritanium Alloy"; + int numFileTypes = 0, numFiles = 0; + Form jobForm = null; + DataComponent fileComponent = null; + ArrayList fileEntries = null; + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription projectDesc = ResourcesPlugin + .getWorkspace().newProjectDescription( + "itemTesterWorkspace"); + // Set the location of the project + projectDesc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(projectDesc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + try { + // Remove any old test files + for (IResource resource : project.members()) { + if (resource.getType() == IResource.FILE + && !(".project").equals(resource.getName())) { + + resource.delete(true, null); + } + } + // Refresh the project space + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e1) { + // Complain + e1.printStackTrace(); + fail(); + } + + // Get the file handle + IFile file = project.getFile(name); + + // Set up the launcher. The launcher uses both the full list of files + // for the input files (fileEntries[0]) and a filtered list of input + // files for the test (fileEntries[1]). + JobLauncher launcher = new JobLauncher(project); + launcher.setDescription("JobLauncher with multiple files"); + launcher.setId(5); + launcher.setName(name); + // Add a second input file that only works with test files so that we + // can test updating filtered input files. + launcher.addInputType(name, name + "File", desc + " ", ".test"); + + // Get the form and get the current number of input files. + jobForm = launcher.getForm(); + assertNotNull(jobForm); + fileComponent = (DataComponent) jobForm.getComponent(1); + assertNotNull(fileComponent); + fileEntries = fileComponent.retrieveAllEntries(); + numFileTypes = fileEntries.size(); + assertEquals(2, numFileTypes); + numFiles = fileEntries.get(0).getAllowedValues().size(); + // Also get the number of test files and make sure it is 0. + assertEquals(0, fileEntries.get(1).getAllowedValues().size()); + + // Create the test file in the workspace + String contents = "contents"; + ByteArrayInputStream testStream = new ByteArrayInputStream( + contents.getBytes()); + try { + file.create(testStream, true, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // Complain + e.printStackTrace(); + fail(); + } + + // Refresh the launcher + launcher.reloadProjectData(); + + // Check the number of input files and test files. Make sure the number + // of types didn't change! + assertEquals(numFileTypes, fileEntries.size()); + // The number of files should now be 1 (.project) + 1 (Process output) + + // 1 (the test file) + numFiles = 3; + // Make sure that the number of input files is correct + System.out.println("JobLauncherTester Message: " + "NumFiles = " + + (numFiles + 1)); + System.out.println("JobLauncherTester Message: " + "File Entries = " + + fileEntries.get(0).getAllowedValues().size()); + for (String value : fileEntries.get(0).getAllowedValues()) { + System.out.println(value); + } + assertEquals(numFiles, fileEntries.get(0).getAllowedValues().size()); + // Also get the number of test files and make sure it is 0. + assertEquals(1, fileEntries.get(1).getAllowedValues().size()); + + // Delete the test file + try { + file.delete(true, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // Complain + e.printStackTrace(); + fail(); + } + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..7f3fbf08484490ae6146c0c9378beba7028a1e74 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileBuilderTester.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.jobprofile.JobProfile; +import org.eclipse.ice.item.jobprofile.JobProfileBuilder; +import org.junit.Ignore; +import org.junit.Test; + +/** + *

+ * This class is responsible for testing the JobProfileBuilder. It checks to + * make sure that JobProfileBuilder returns the correct Item name and Item type. + * In also tries to build a new JobProfile and check it. + *

+ * + * @author Jay Jay Billings + */ + +public class JobProfileBuilderTester { + /** + * + */ + private JobProfileBuilder jobProfileBuilder; + + /** + *

+ * This operation checks the Item type and Item name of the + * JobProfileBuilder. + *

+ * + */ + @Test + public void checkJobProfileInformation() { + + // create a JobProfileBuilder + jobProfileBuilder = new JobProfileBuilder(); + + // Check the Item type and name. The JobProfile is a Model. + assertEquals(ItemType.Model, jobProfileBuilder.getItemType()); + assertEquals("Job Profile", jobProfileBuilder.getItemName()); + + } + + /** + *

+ * This operation creates a JobProfile and checks it to make sure it was + * actually built properly. + *

+ * + */ + @Test + public void checkJobProfile() { + + // create a JobProfileBuilder + jobProfileBuilder = new JobProfileBuilder(); + + // build + JobProfile jobProfile = (JobProfile) jobProfileBuilder.build(null); + + // Check item builder name + assertEquals(jobProfileBuilder.getItemName(), + jobProfile.getItemBuilderName()); + + // check to make sure it was build properly. + assertNotNull(jobProfile.getForm()); + assertEquals("Create a Job Launcher", jobProfile.getForm() + .getActionList().get(0)); + + // Check the actions + assertEquals(1, jobProfile.getAvailableActions().size()); + assertEquals("Create A JobLauncher", jobProfile.getAvailableActions() + .get(0)); + // Make sure the JobProfile is returning the correct type. + assertEquals(ItemType.Model, jobProfile.getItemType()); + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileFormTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileFormTester.java new file mode 100644 index 0000000000000000000000000000000000000000..7b7cfc2823c43dac4f49515a6a3ef7b1abac3b44 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileFormTester.java @@ -0,0 +1,401 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.TableComponent; +import org.eclipse.ice.item.jobprofile.JobProfileForm; +import org.junit.Ignore; +import org.junit.Test; + +/** + *

+ * This class checks the JobProfileForm. + *

+ * + * @author Jay Jay Billings + */ + +public class JobProfileFormTester { + /** + * + */ + private JobProfileForm jobProfileForm; + + /** + *

+ * This operation checks the contents of the JobProfileForm to make sure + * that they are consistent with the specification. + *

+ * + */ + @Test + public void checkFormContents() { + + // Local Declarations + DataComponent exeInfo = null; + DataComponent threadOps = null; + TableComponent hostnames = null; + TableComponent dataFiles = null; + int entryId = 1; + + Entry entry = null; + + // Create a new JobProfileForm + jobProfileForm = new JobProfileForm(); + + // Check jobProfile + assertEquals("Job Profile Editor", jobProfileForm.getName()); + assertEquals( + "Create or edit a Job Profile that will be used by ICE to launch jobs.", + jobProfileForm.getDescription()); + + // Check contents. Make sure labels are set correctly, default values, + // etc. + + // Check that there are 4 components + // 2 data components and 2 table components. + + assertEquals(4, jobProfileForm.getComponents().size()); + assertEquals(DataComponent.class, jobProfileForm.getComponents().get(0) + .getClass()); + assertEquals(DataComponent.class, jobProfileForm.getComponents().get(1) + .getClass()); + assertEquals(TableComponent.class, jobProfileForm.getComponents() + .get(2).getClass()); + assertEquals(TableComponent.class, jobProfileForm.getComponents() + .get(3).getClass()); + + // Check first Component - Execution Information + // get the first dataComponent + exeInfo = (DataComponent) jobProfileForm.getComponents().get(0); + // check name and description for section + assertEquals("Execution Information", exeInfo.getName()); + assertEquals( + "This block contains information pertaining to the execution of the program. This includes the name of the job, input file and output types, the executable, and parameters.", + exeInfo.getDescription()); + + // check entries of component name, description, and default values; + // Job Name + entry = (Entry) exeInfo.retrieveAllEntries().get(0); + // check name, description, and values + assertEquals("Job Name", entry.getName()); + assertEquals("This is a name for the job profile.", + entry.getDescription()); + assertEquals("JobProfile", entry.getDefaultValue()); + assertEquals("JobProfile", entry.getValue()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("jobName", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Executable Name + entry = (Entry) exeInfo.retrieveAllEntries().get(1); + // check name, description, and values + assertEquals("Executable Name", entry.getName()); + assertEquals("ls", entry.getDefaultValue()); + assertEquals("ls", entry.getValue()); + assertEquals("Specifies the command line argument to " + + "execute the job (excludes parameters for the job). " + + "If the executable is not installed on the path, you " + + "should include the ${installDir} variable in the " + + "appropriate place.", entry.getDescription()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("executableName", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Commented out due to it will not show on the profile at this time + /* + * //Input File entry = (Entry) exeInfo.retrieveAllEntries().get(2); + * //check name, description, and values assertEquals("Input File", + * entry.getName()); assertEquals("inputFile.txt", + * entry.getDefaultValue()); assertEquals("inputFile.txt", + * entry.getValue()); + * assertEquals("Specifies the input file for the simulator.", + * entry.getDescription()); assertEquals(AllowedValueType.Undefined, + * entry.getValueType()); assertEquals("inputFile", entry.getTag()); + */ + + // Parameters + // Input File + entry = (Entry) exeInfo.retrieveAllEntries().get(2); + // check name, description, and values + assertEquals("Parameters", entry.getName()); + assertEquals("Specifies the parameters for a job.", + entry.getDescription()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("parameters", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Commented out due to it will not show on the profile at this time + /* + * //Output File Type entry = (Entry) + * exeInfo.retrieveAllEntries().get(4); //check name, description, and + * values assertEquals("Output File Type", entry.getName()); + * assertEquals("*.type", entry.getDefaultValue()); + * assertEquals("*.type", entry.getValue()); + * assertEquals("Specifies the output file type for a simulator.", + * entry.getDescription()); assertEquals(AllowedValueType.Undefined, + * entry.getValueType()); assertEquals("outputFileType", + * entry.getTag()); + */ + + // Check second Component - Threading Options + // get the second dataComponent + threadOps = (DataComponent) jobProfileForm.getComponents().get(1); + // check name and description for section + assertEquals("Threading Options", threadOps.getName()); + assertEquals( + "This section contains tools to enable certain threading or processes options for MPI and OpenMP.", + threadOps.getDescription()); + + // check entries of component name, description, and default values; + // Enable OpenMP + entry = (Entry) threadOps.retrieveAllEntries().get(0); + // check name, description, and values + assertEquals("Enable OpenMP", entry.getName()); + assertEquals("Specifies if the program utilizes OpenMP library.", + entry.getDescription()); + assertEquals("No", entry.getDefaultValue()); + assertEquals("No", entry.getValue()); + assertEquals("Yes", entry.getAllowedValues().get(0)); + assertEquals("No", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Discrete, entry.getValueType()); + assertEquals("enableOpenMP", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Number of Threads + entry = (Entry) threadOps.retrieveAllEntries().get(1); + // check name, description, and values + assertEquals("Default Number of Threads", entry.getName()); + assertEquals("Specifies the default number of threads for OpenMP.", + entry.getDescription()); + assertEquals("1", entry.getDefaultValue()); + assertEquals("1", entry.getValue()); + assertEquals("1", entry.getAllowedValues().get(0)); + assertEquals("128", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Continuous, entry.getValueType()); + assertEquals("numOfThreads", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Enable MPI + entry = (Entry) threadOps.retrieveAllEntries().get(2); + // check name, description, and values + assertEquals("Enable MPI", entry.getName()); + assertEquals("Specifies if the program utilizes MPI library.", + entry.getDescription()); + assertEquals("No", entry.getDefaultValue()); + assertEquals("No", entry.getValue()); + assertEquals("Yes", entry.getAllowedValues().get(0)); + assertEquals("No", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Discrete, entry.getValueType()); + assertEquals("enableMPI", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Number of Processes + entry = (Entry) threadOps.retrieveAllEntries().get(3); + // check name, description, and values + assertEquals("Default Number of Processes", entry.getName()); + assertEquals("Specifies the default number of processes for MPI.", + entry.getDescription()); + assertEquals("1", entry.getDefaultValue()); + assertEquals("1", entry.getValue()); + assertEquals("1", entry.getAllowedValues().get(0)); + assertEquals("512000", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Continuous, entry.getValueType()); + assertEquals("numOfProcesses", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Enable TBB + entry = (Entry) threadOps.retrieveAllEntries().get(4); + // check name, description, and values + assertEquals("Enable TBB", entry.getName()); + assertEquals( + "Specifies if the program utilizes Thread Building Blocks.", + entry.getDescription()); + assertEquals("No", entry.getDefaultValue()); + assertEquals("No", entry.getValue()); + assertEquals("Yes", entry.getAllowedValues().get(0)); + assertEquals("No", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Discrete, entry.getValueType()); + assertEquals("enableTBB", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Number of TBBs + entry = (Entry) threadOps.retrieveAllEntries().get(5); + // check name, description, and values + assertEquals("Default Number of TBBs", entry.getName()); + assertEquals("Specifies the default number of Thread Blocks.", + entry.getDescription()); + assertEquals("1", entry.getDefaultValue()); + assertEquals("1", entry.getValue()); + assertEquals("1", entry.getAllowedValues().get(0)); + assertEquals("128", entry.getAllowedValues().get(1)); + assertEquals(AllowedValueType.Continuous, entry.getValueType()); + assertEquals("numOfTBBs", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Check third Component - Hostnames + // get the second dataComponent + hostnames = (TableComponent) jobProfileForm.getComponents().get(2); + // check name and description for section + assertEquals("Hostnames", hostnames.getName()); + assertEquals( + "This section contains information pertaining to the hostname, operating system, and installed directories for the executables.", + hostnames.getDescription()); + + // Check the tableComponent's properties - initialized correctly + assertEquals(3, hostnames.numberOfColumns()); + // It will have a row pre-initialized + assertEquals(1, hostnames.numberOfRows()); + + // check column names + assertEquals(3, hostnames.getColumnNames().size()); + assertEquals("Hostname", hostnames.getColumnNames().get(0)); + assertEquals("Operating System", hostnames.getColumnNames().get(1)); + assertEquals("Install Directory", hostnames.getColumnNames().get(2)); + + // check entries of component name, description, and default values; + // Hostname + entry = (Entry) hostnames.getRowTemplate().get(0); + // check name, description, and values + assertEquals("Hostname", entry.getName()); + assertEquals( + "Specifies the location of the executable. Use localhost for executables stored locally.", + entry.getDescription()); + assertEquals("localhost", entry.getDefaultValue()); + assertEquals("localhost", entry.getValue()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("hostname", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Operating System + entry = (Entry) hostnames.getRowTemplate().get(1); + // check name, description, and values + assertEquals("Operating System", entry.getName()); + assertEquals( + "Specifies the operating system installed for the hostname.", + entry.getDescription()); + assertEquals("Linux x86_x64", entry.getDefaultValue()); + assertEquals("Linux x86_x64", entry.getValue()); + assertEquals("Linux x86_x64", entry.getAllowedValues().get(0)); + assertEquals("Linux x86", entry.getAllowedValues().get(1)); + assertEquals("Windows x86", entry.getAllowedValues().get(2)); + assertEquals("Windows x64", entry.getAllowedValues().get(3)); + assertEquals("Mac OSX", entry.getAllowedValues().get(4)); + assertEquals(AllowedValueType.Discrete, entry.getValueType()); + assertEquals("operatingSystem", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // Install Directory + entry = (Entry) hostnames.getRowTemplate().get(2); + // check name, description, and values + assertEquals("Install Directory", entry.getName()); + assertEquals("Specifies the install directory for a hostname.", + entry.getDescription()); + assertEquals("/bin", entry.getDefaultValue()); + assertEquals("/bin", entry.getValue()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("installDirectory", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // check the first row's values + Entry entry1 = null; + Entry entry2 = null; + Entry entry3 = null; + entry1 = (Entry) hostnames.getRow(0).get(0); + entry2 = (Entry) hostnames.getRow(0).get(1); + entry3 = (Entry) hostnames.getRow(0).get(2); + + assertEquals("localhost", entry1.getValue()); + assertEquals("Linux x86_x64", entry2.getValue()); + assertEquals("/bin", entry3.getValue()); + + // Check forth Component - Data Files + // get the second dataComponent + dataFiles = (TableComponent) jobProfileForm.getComponents().get(3); + // check name and description for section + assertEquals("Data Files", dataFiles.getName()); + assertEquals( + "This section contains information pertaining to required files for the program to function nominally.", + dataFiles.getDescription()); + + // Check the tableComponent's properties - initialized correctly + assertEquals(2, dataFiles.numberOfColumns()); + assertEquals(0, dataFiles.numberOfRows()); + + // check column names + assertEquals(2, dataFiles.getColumnNames().size()); + assertEquals("Data File", dataFiles.getColumnNames().get(0)); + assertEquals("File Path", dataFiles.getColumnNames().get(1)); + + // check entries of component name, description, and default values; + // Data File + entry = (Entry) dataFiles.getRowTemplate().get(0); + // check name, description, and values + assertEquals("Data File", entry.getName()); + assertEquals("Specifies a data file required to run an executable.", + entry.getDescription()); + assertEquals("text.txt", entry.getDefaultValue()); + assertEquals("text.txt", entry.getValue()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("dataFile", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + // File Path + entry = (Entry) dataFiles.getRowTemplate().get(1); + // check name, description, and values + assertEquals("File Path", entry.getName()); + assertEquals("Specifies the install directory for a data file.", + entry.getDescription()); + assertEquals("/opt/bin", entry.getDefaultValue()); + assertEquals("/opt/bin", entry.getValue()); + assertEquals(AllowedValueType.Undefined, entry.getValueType()); + assertEquals("filePath", entry.getTag()); + // Check the Entry's id and increment the counter. + assertEquals(entryId, entry.getId()); + entryId++; + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileTester.java new file mode 100644 index 0000000000000000000000000000000000000000..aab5f811bd195c967b3d51cbf24f206e58aaadeb --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileTester.java @@ -0,0 +1,217 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014- UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.File; +import java.net.URI; +import java.util.ArrayList; + +import javax.xml.bind.JAXBException; + +import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.ResourceComponent; +import org.eclipse.ice.item.jobLauncher.JobLauncher; +import org.eclipse.ice.item.jobprofile.JobProfile; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.junit.Test; + +/** + * This class is responsible for testing the JobProfileBuilder. It is primarily + * concerned with checking the ability of the JobProfileBuilder to write the new + * profile to disk correctly after it is created. + * + * @author Jay Jay Billings, Anna Wojtowicz + */ +public class JobProfileTester { + + /** + * A JobProfile used for testing. + */ + private JobProfile jobProfile; + + /** + * This operation checks the JobProfile by processing it and reviewing + * comparing the Item it creates to the original. It also checks the + * quantities in the XML to make sure that they are consistent with the + * specification and useful for launching jobs. + * + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + */ + @Test + public void checkProfileWriting() throws NullPointerException, JAXBException, IOException { + + // Begin by setting up a project space we can work with + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String separator = System.getProperty("file.separator"); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace. Use + // file() to get around the URI problems with spaces. + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + // Now we have the project space, pass project into jobProfile + + // Create a job profile + jobProfile = new JobProfile(project); + // Should persist file to XML + jobProfile.process("Create a Job Launcher"); + + // Get the persisted file and make sure it's valid + IFile file = project.getFolder("jobProfiles").getFile("JobProfile.xml"); + assertTrue(file.exists()); + + // Load file into inputStream + ByteArrayInputStream inputStream = null; + try { + + // Convert to a string and then convert that string to an + // InputStream + BufferedReader br = new BufferedReader(new InputStreamReader( + file.getContents())); + + StringBuilder sb = new StringBuilder(); + String line; + try { + while ((line = br.readLine()) != null) { + sb.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println(sb.toString()); + inputStream = new ByteArrayInputStream(sb.toString().getBytes()); + } catch (CoreException e) { + e.printStackTrace(); + } + + // Load file from inputSteam to object + JobLauncher launcher = new JobLauncher(); + + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(JobLauncher.class); + classList.add(ResourceComponent.class); + launcher = (JobLauncher) xmlHandler.read(classList, inputStream); + + // check contents of JobLauncher (item portion). Should be default + // values besides form: + JobLauncher comparisonLauncher = new JobLauncher(); + comparisonLauncher.setName("JobProfile"); + comparisonLauncher + .setDescription("This operation will execute JobProfile"); + comparisonLauncher.setItemBuilderName("JobProfile"); + assertEquals(comparisonLauncher.getName(), launcher.getName()); + assertEquals(comparisonLauncher.getDescription(), + launcher.getDescription()); + assertEquals(comparisonLauncher.getItemType(), launcher.getItemType()); + assertEquals(comparisonLauncher.getStatus(), launcher.getStatus()); + assertEquals(comparisonLauncher.getItemBuilderName(), + launcher.getItemBuilderName()); + // This next check is to make sure that the JobProfile sets the builder + // name according to the specification on the class. + assertEquals(launcher.getName(), launcher.getItemBuilderName()); + + // Check contents of form + Form form = launcher.getForm(); + assertEquals("JobProfile Launcher", form.getName()); + assertEquals("This operation will execute JobProfile", + form.getDescription()); + assertEquals(3, form.getComponents().size()); + + // Enable OpenMP and MPI on the launcher + launcher.enableMPI(1, 512000, 1); + launcher.enableOpenMP(1, 16, 1); + + // Verify they were set correctly + DataComponent component = (DataComponent) form.getComponents().get(3); + Entry mpiEntry = (Entry) component.retrieveAllEntries().get(1); + Entry openMPEntry = (Entry) component.retrieveAllEntries().get(2); + assertEquals("1", mpiEntry.getValue()); + assertEquals("1", openMPEntry.getValue()); + + // Delete the files from the workspace + try { + // Remove any old test files + for (IResource resource : project.members()) { + if (resource.getType() == IResource.FILE + && !(".project").equals(resource.getName())) { + // Convert the resource to a File resource. It's necessary + // to do this for the Windows build so we can use + // File.deleteOnExit() here. When Windows attempts to delete + // a resource, it does not automatically release any open + // handles on files the same way *nix systems do. Failing + // to delete these resources causes subsequent Item tests + // to fail on a Windows build. + File fileResource = + new File(resource.getLocation().toOSString()); + fileResource.deleteOnExit(); + } + } + // Refresh the project space + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e1) { + // Complain + e1.printStackTrace(); + fail(); + } + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/LoginInfoFormTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/LoginInfoFormTester.java new file mode 100644 index 0000000000000000000000000000000000000000..9ebe3737b36999e31b72de8c96f2903148c68965 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/LoginInfoFormTester.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.util.ArrayList; + +import org.junit.Test; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.item.action.LoginInfoForm; + +/** + *

+ * This class is responsible for testing the LoginInfoForm class. + *

+ * + * @author Jay Jay Billings + */ +public class LoginInfoFormTester { + /** + *

+ * The LoginInfoForm that is under test. + *

+ * + */ + private LoginInfoForm loginInfoForm; + + /** + *

+ * This operation checks the Form to ensure that it is a Form with single + * DataComponent and that the Entries in that component are setup to reflect + * usernames and passwords. + *

+ * + */ + @Test + public void checkForm() { + + // Local Declarations + ArrayList entries = null; + + // Allocate the login Form + loginInfoForm = new LoginInfoForm(); + + // Check the number of DataComponents + assertEquals(1, loginInfoForm.getNumberOfComponents()); + + // Check the number of Entries + entries = ((DataComponent) (loginInfoForm.getComponents().get(0))) + .retrieveAllEntries(); + assertNotNull(entries); + assertEquals(2, entries.size()); + + // Check the default Entry names + assertEquals("Username", entries.get(0).getName()); + assertEquals("Password", entries.get(1).getName()); + + // Make sure that the password Entry is secret + assertTrue(entries.get(1).isSecret()); + + return; + + } + + /** + *

+ * This operation checks the convenience methods on the LoginInfoForm that + * are used to set the description of the Form and the prompt names for the + * Entries. + *

+ * + */ + @Test + public void checkConvenienceMethods() { + + // Local Declarations + ArrayList entries = null; + Entry username = null, password = null; + + // Allocate the login Form + loginInfoForm = new LoginInfoForm(); + + // Check the number of Entries + entries = ((DataComponent) (loginInfoForm.getComponents().get(0))) + .retrieveAllEntries(); + assertNotNull(entries); + + // Check setting the username prompt + username = entries.get(0); + loginInfoForm.setUsernamePrompt("Peeps"); + assertEquals("Peeps", username.getName()); + + // Check setting the password prompt + password = entries.get(0); + loginInfoForm.setUsernamePrompt("Throwing Fire"); + assertEquals("Throwing Fire", password.getName()); + + // Check setting the description + loginInfoForm.setPromptDescription("Prompt Description"); + assertEquals("Prompt Description", loginInfoForm.getDescription()); + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/MultiLauncherTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/MultiLauncherTester.java new file mode 100644 index 0000000000000000000000000000000000000000..8c9d42d12da12d3f036a9f48a90153a8dc28b9ab --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/MultiLauncherTester.java @@ -0,0 +1,417 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.ice.datastructures.ICEObject.Component; +import org.eclipse.ice.datastructures.ICEObject.ListComponent; +import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; + +import static org.eclipse.ice.item.jobLauncher.multiLauncher.MultiLauncher.*; +import static org.junit.Assert.*; + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.form.MasterDetailsComponent; +import org.eclipse.ice.datastructures.form.TimeDataComponent; +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.datastructures.form.ResourceComponent; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ice.datastructures.form.TableComponent; +import org.eclipse.ice.datastructures.form.MatrixComponent; +import org.eclipse.ice.datastructures.form.emf.EMFComponent; +import org.eclipse.ice.datastructures.form.geometry.IShape; +import org.eclipse.ice.datastructures.form.geometry.GeometryComponent; +import org.eclipse.ice.datastructures.form.mesh.MeshComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemBuilder; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.jobLauncher.multiLauncher.MultiLauncher; +import org.eclipse.ice.item.jobLauncher.multiLauncher.MultiLauncherBuilder; + +/** + *

+ * This class is responsible for testing the MultiLauncherBuilder and the + * MultiLauncher classes. It realizes the IComponentVisitor interface so that it + * can sort and examine the components from the MultiLauncher's Form. + *

+ * + * @author Jay Jay Billings + */ +public class MultiLauncherTester implements IComponentVisitor { + /** + * + */ + private MultiLauncherBuilder multiLauncherBuilder; + + /** + * + */ + private DataComponent dataComponent = null; + /** + *

+ * The MasterDetailsComponent from the MultiLauncher. + *

+ * + */ + private MasterDetailsComponent masterDetailsComponent = null; + + /** + *

+ * A reference to the project space. + *

+ * + */ + private static IProject projectSpace; + + /** + *

+ * The ResourceComponent from the MultiLauncher. + *

+ * + */ + private ResourceComponent resourceComponent; + + /** + *

+ * This operation is called before the test to setup the project space. + *

+ * + */ + @BeforeClass + public static void Before() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + String separator = System.getProperty("file.separator"); + String filename = null; + + // Setup the project + try { + // Get the project handle + projectSpace = workspaceRoot.getProject("itemTesterWorkspace"); + // If the project does not exist, create it + if (!projectSpace.exists()) { + // Set the location as ${workspace_loc}/ItemTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.dir") + separator + + "itemTesterWorkspace")).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription("itemTesterWorkspace"); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + projectSpace.create(desc, null); + } + // Open the project if it is not already open + if (projectSpace.exists() && !projectSpace.isOpen()) { + projectSpace.open(null); + } + } catch (CoreException e) { + // Catch for creating the project + e.printStackTrace(); + fail(); + } + + } + + /** + *

+ * This operation checks the MultiLauncherBuilder to make sure that it can + * create a fully initialized MultiLauncher. It does this by registering + * several anonymous subclasses of Item, some with the ItemType.Simulation + * type and some with other types, and then calls build() to create the + * launcher. It considers the test successful if it can retrieve the Form + * from the launcher and find information for each of the Items that it + * registered with type ItemType.Simulation. + *

+ * + */ + @Test + public void checkConstruction() { + + // Create the builder + int numBuilders = 4; + FakeItemBuilder builder = null; + ArrayList builders = new ArrayList(); + multiLauncherBuilder = new MultiLauncherBuilder(); + + // Check the details of the builder + assertEquals("MultiLauncher", multiLauncherBuilder.getItemName()); + assertEquals(ItemType.Simulation, multiLauncherBuilder.getItemType()); + + // Make sure calling build returns null since no builders have been + // added + assertNull(multiLauncherBuilder.build(projectSpace)); + + // Create some ItemBuilders and register them with the + // MultiLauncherBuilder + for (int i = 0; i < numBuilders; i++) { + builder = new FakeItemBuilder(); + builder.setNameForTest("Sally " + i); + builders.add(builder); + } + // Add one more that is not a JobLauncher + builder = new FakeItemBuilder(); + builder.setNameForTest("Love Hitchiker"); + builder.setTypeForTest(ItemType.ModelOutputPackage); + builders.add(builder); + + // Set the list of builders + multiLauncherBuilder.addBuilders(builders); + + // Build a MultiLauncher + Item launcher = multiLauncherBuilder.build(projectSpace); + + // Check the launcher + assertNotNull(launcher); + assertTrue(launcher instanceof MultiLauncher); + assertTrue(launcher.getName().contains("MultiLauncher")); + + // Grab the Form and take a look at it. It should have one component. + Form form = launcher.getForm(); + assertEquals(2, form.getNumberOfComponents()); + + // Get the Component from the Form and visit it to get the data and + // master-details components + ArrayList components = form.getComponents(); + assertNotNull(components); + assertEquals(2, components.size()); + for (Component component : components) { + component.accept(this); + } + // Check the DataComponent. This component is the header or "globals" + // component from the MasterDetailsComponent of the launcher. + assertNotNull(dataComponent); + assertEquals("Execution Mode", dataComponent.getName()); + assertNotNull(dataComponent.retrieveEntry("Enable Parallel Execution")); + // The DataComponent should have id = 3 + assertEquals(3, dataComponent.getId()); + + // Check the MasterDetailsComponent + assertNotNull(masterDetailsComponent); + assertEquals(numBuilders, masterDetailsComponent + .getAllowedMasterValues().size()); + // The MasterDetailsComponent should have id = 1 + assertEquals(1, masterDetailsComponent.getId()); + ArrayList allowedMasterValues = masterDetailsComponent + .getAllowedMasterValues(); + // Loop over the builders and check them as they were constructed above. + for (int i = 0; i < numBuilders; i++) { + assertTrue(allowedMasterValues.contains("Sally " + i)); + } + // The launcher should not contain an Item named "Love Hitchiker" + // because it was not a JobLauncher. + assertTrue(!allowedMasterValues.contains("Love Hitchiker")); + + // Check the ResourceComponent + assertNotNull(resourceComponent); + // The ResourceComponent should have id = 2 + assertEquals(2, resourceComponent.getId()); + + } + + /** + *

+ * This operation modifies the Form retrieved from the MultiLauncher and + * submits it back to the launcher to make sure that it can be submitted + * successfully. + *

+ * + */ + @Test + public void checkFormSubmission() { + + // Create the builder + int numBuilders = 4; + FakeItemBuilder builder = null; + ArrayList builders = new ArrayList(); + multiLauncherBuilder = new MultiLauncherBuilder(); + + // Check the details of the builder + assertEquals("MultiLauncher", multiLauncherBuilder.getItemName()); + assertEquals(ItemType.Simulation, multiLauncherBuilder.getItemType()); + + // Create some ItemBuilders and register them with the + // MultiLauncherBuilder + for (int i = 0; i < numBuilders; i++) { + builder = new FakeItemBuilder(); + builder.setNameForTest("Sally " + i); + builders.add(builder); + } + // Set the list of builders + multiLauncherBuilder.addBuilders(builders); + + // Build a MultiLauncher + Item launcher = multiLauncherBuilder.build(projectSpace); + assertNotNull(launcher); + + // Grab the Form and get the component + Form form = launcher.getForm(); + ArrayList components = form.getComponents(); + components.get(0).accept(this); + + // Add a few "Sally" launchers + int id = masterDetailsComponent.addMaster(); + masterDetailsComponent.setMasterInstanceValue(id, "Sally 1"); + masterDetailsComponent.addMaster(); + masterDetailsComponent.setMasterInstanceValue(id, "Sally 1"); + masterDetailsComponent.addMaster(); + masterDetailsComponent.setMasterInstanceValue(id, "Sally 2"); + masterDetailsComponent.addMaster(); + masterDetailsComponent.setMasterInstanceValue(id, "Sally 0"); + + // Submit the Form and make sure it is accepted + assertEquals(FormStatus.ReadyToProcess, launcher.submitForm(form)); + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(DataComponent component) + */ + public void visit(DataComponent component) { + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(ResourceComponent component) + */ + public void visit(ResourceComponent component) { + + resourceComponent = component; + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(TableComponent component) + */ + public void visit(TableComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(MatrixComponent component) + */ + public void visit(MatrixComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(IShape component) + */ + public void visit(IShape component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(GeometryComponent component) + */ + public void visit(GeometryComponent component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(MasterDetailsComponent component) + */ + public void visit(MasterDetailsComponent component) { + + // Set the MasterDetailsComponent + masterDetailsComponent = component; + // Set its header component + dataComponent = masterDetailsComponent.getGlobalsComponent(); + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(TreeComposite component) + */ + public void visit(TreeComposite component) { + // TODO Auto-generated method stub + + } + + /** + * (non-Javadoc) + * + * @see IComponentVisitor#visit(IReactorComponent component) + */ + public void visit(IReactorComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(TimeDataComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(MeshComponent component) { + // TODO Auto-generated method stub + + } + + + @Override + public void visit(AdaptiveTreeComposite component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(EMFComponent component) { + // TODO Auto-generated method stub + + } + + @Override + public void visit(ListComponent component) { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ParameterListTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ParameterListTester.java new file mode 100644 index 0000000000000000000000000000000000000000..2ca3d18ec5ca29ec3f0aa7dacc6e18615d7a5350 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ParameterListTester.java @@ -0,0 +1,351 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import javax.xml.bind.JAXBException; + +import org.junit.Test; +import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.utilities.trilinos.Parameter; +import org.eclipse.ice.item.utilities.trilinos.ParameterList; + +/** + * This class checks the Parameter and ParameterList classes to make sure that + * their toEntry() and toTreeComposite() operations work as described. + */ +public class ParameterListTester { + /** + *

+ * This operation checks the parameter classes toEntry() operation. + *

+ * + */ + @Test + public void checkParameter() { + + // Local Declarations + Parameter param = null, retParam = null; + + // Create a parameter + param = new Parameter(); + param.name = "MyParameter"; + param.value = "0.1"; + param.type = "double"; + + // Create an Entry from the parameter - start with double + Entry parameterEntry = param.toEntry(); + // Check the name + assertEquals(param.name, parameterEntry.getName()); + // Check the value + assertEquals(param.value, parameterEntry.getDefaultValue()); + assertEquals(param.value, parameterEntry.getValue()); + // Check the description + assertEquals(param.name, parameterEntry.getDescription()); + // Check the AllowedValueType + assertEquals(AllowedValueType.Continuous, parameterEntry.getValueType()); + // Check the bounds + assertTrue(parameterEntry.getAllowedValues().contains( + String.valueOf(Double.POSITIVE_INFINITY))); + assertTrue(parameterEntry.getAllowedValues().contains( + String.valueOf(Double.NEGATIVE_INFINITY))); + // Create parameter from this Entry + retParam = new Parameter(); + retParam.fromEntry(parameterEntry); + // And check it + assertEquals(param.name, retParam.name); + assertEquals(param.type, retParam.type); + assertEquals(param.value, retParam.value); + + // Change the value and type to check integers + param.type = "int"; + param.value = "1"; + parameterEntry = param.toEntry(); + // Check the AllowedValueType + assertEquals(AllowedValueType.Continuous, parameterEntry.getValueType()); + // Check the bounds + assertTrue(parameterEntry.getAllowedValues().contains( + String.valueOf(Double.POSITIVE_INFINITY))); + assertTrue(parameterEntry.getAllowedValues().contains( + String.valueOf(Double.NEGATIVE_INFINITY))); + // Create parameter from this Entry + retParam = new Parameter(); + retParam.fromEntry(parameterEntry); + // And check it + assertEquals(param.name, retParam.name); + assertEquals(param.type, retParam.type); + assertEquals(param.value, retParam.value); + + // Change the value and type to check booleans + param.type = "bool"; + param.value = "true"; + parameterEntry = param.toEntry(); + // Check the AllowedValueType + assertEquals(AllowedValueType.Discrete, parameterEntry.getValueType()); + // Check the bounds + assertTrue(parameterEntry.getAllowedValues().contains("true")); + assertTrue(parameterEntry.getAllowedValues().contains("false")); + // Create parameter from this Entry + retParam = new Parameter(); + retParam.fromEntry(parameterEntry); + // And check it + assertEquals(param.name, retParam.name); + assertEquals(param.type, retParam.type); + assertEquals(param.value, retParam.value); + + // Change the value and type to check strings + param.type = "string"; + param.value = "myString"; + parameterEntry = param.toEntry(); + // Check the AllowedValueType + assertEquals(AllowedValueType.Undefined, parameterEntry.getValueType()); + // Create parameter from this Entry + retParam = new Parameter(); + retParam.fromEntry(parameterEntry); + // And check it + assertEquals(param.name, retParam.name); + assertEquals(param.type, retParam.type); + assertEquals(param.value, retParam.value); + + // Change the value and type to check arrays + param.type = "Array(string)"; + param.value = "{1,1,1,1}"; + parameterEntry = param.toEntry(); + // Check the AllowedValueType + assertEquals(AllowedValueType.Undefined, parameterEntry.getValueType()); + // Create parameter from this Entry + retParam = new Parameter(); + retParam.fromEntry(parameterEntry); + // And check it + assertEquals(param.name, retParam.name); + assertEquals(param.type, retParam.type); + assertEquals(param.value, retParam.value); + + return; + } + + /** + *

+ * This operation checks the ParameterLists toTreeComposite() operation. + *

+ * + */ + @Test + public void checkParameterList() { + + // Create a couple of parameter lists + ParameterList pList = new ParameterList(); + ParameterList secondPList = new ParameterList(); + ParameterList thirdPList = new ParameterList(); + ParameterList retParamList = new ParameterList(); + ArrayList retParams = new ArrayList(); + int numParameters = 10; + + // Set the names + pList.name = "MyParameterList"; + secondPList.name = "MySecondParameterList"; + thirdPList.name = "MyThirdParameterList"; + + // Create parameters + pList.parameters = new ArrayList(); + for (int i = 0; i < numParameters; i++) { + Parameter param = new Parameter(); + param.name = (new Integer(i)).toString(); + param.value = param.name; + param.type = "string"; + pList.parameters.add(param); + } + + // Add the second parameter list as a child to the first + pList.parameterLists = new ArrayList(); + pList.parameterLists.add(secondPList); + + // Add the third parameter list as a child to the second + secondPList.parameterLists = new ArrayList(); + secondPList.parameterLists.add(thirdPList); + + // Get the TreeComposite + TreeComposite pListTreeComp = pList.toTreeComposite(); + + // Check the name and description + assertEquals(pList.name, pListTreeComp.getName()); + assertEquals(pList.name, pListTreeComp.getDescription()); + // Make sure there is a component available + assertNotNull(pListTreeComp.getDataNodes()); + assertEquals(1, pListTreeComp.getDataNodes().size()); + assertTrue(pListTreeComp.getDataNodes().get(0) instanceof DataComponent); + // Get the data component and check out its info + DataComponent dataComp = (DataComponent) pListTreeComp.getDataNodes() + .get(0); + assertEquals(pList.name + " Parameters", dataComp.getName()); + assertEquals(pList.name + " Parameters", dataComp.getDescription()); + // Check out the entries on the DataComponent + assertEquals(10, dataComp.retrieveAllEntries().size()); + for (int i = 0; i < numParameters; i++) { + assertEquals((new Integer(i)).toString(), dataComp + .retrieveAllEntries().get(i).getName()); + assertEquals(i + 1, dataComp.retrieveAllEntries().get(i).getId()); + } + // Make sure the sub-tree is available + assertNotNull(pListTreeComp.getChildAtIndex(0)); + assertTrue(pListTreeComp.getChildAtIndex(0) instanceof TreeComposite); + TreeComposite retSecondPListTreeComp = pListTreeComp.getChildAtIndex(0); + // Check the name + assertEquals(secondPList.name, retSecondPListTreeComp.getName()); + // Make sure the sub-tree of the sub-tree is available + assertNotNull(retSecondPListTreeComp.getChildAtIndex(0)); + assertTrue(retSecondPListTreeComp.getChildAtIndex(0) instanceof TreeComposite); + TreeComposite retThirdPListTreeComp = retSecondPListTreeComp + .getChildAtIndex(0); + // Check the name + assertEquals(thirdPList.name, retThirdPListTreeComp.getName()); + + // Convert the TreeComposite back to a parameter list + retParamList.fromTreeComposite(pListTreeComp); + + // Check the name + assertEquals(pList.name, retParamList.name); + // Check the parameters + retParams = retParamList.parameters; + assertEquals(pList.parameters.size(), retParamList.parameters.size()); + for (int i = 0; i < numParameters; i++) { + assertEquals(pList.parameters.get(i).name, retParams.get(i).name); + assertEquals(pList.parameters.get(i).value, retParams.get(i).value); + assertEquals(pList.parameters.get(i).type, retParams.get(i).type); + } + // Check the children + assertEquals(pList.parameterLists.size(), + retParamList.parameterLists.size()); + assertEquals(pList.parameterLists.get(0).name, + retParamList.parameterLists.get(0).name); + assertEquals(secondPList.parameterLists.size(), + retParamList.parameterLists.get(0).parameterLists.size()); + assertEquals(secondPList.parameterLists.get(0).name, + retParamList.parameterLists.get(0).parameterLists.get(0).name); + + return; + } + + /** + * This operation checks that a parameter lists can be loaded to and from + * XML properly. + * @throws IOException + * @throws JAXBException + * @throws NullPointerException + */ + @Test + public void checkXMLPersistence() throws NullPointerException, JAXBException, IOException { + + // Local Declarations + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + InputStream inputStream = null; + Parameter param = new Parameter(), loadedParam = null, secondParam = new Parameter(); + ParameterList pList = new ParameterList(), secondPList = new ParameterList(); + ParameterList loadedList = null, secondLoadedList = null; + ICEJAXBHandler xmlHandler = new ICEJAXBHandler(); + ArrayList classList = new ArrayList(); + classList.add(ParameterList.class); + + System.out.println("----- Testing Parameter XML Persistence -----"); + + // Create a parameter + param.name = "A parameter"; + param.value = "only simple bits and bites"; + param.type = "string"; + + // Write it to XML + xmlHandler.write(param, classList, outputStream); + + // Read it from XML + inputStream = new ByteArrayInputStream(outputStream.toByteArray()); + loadedParam = new Parameter(); + loadedParam = (Parameter) xmlHandler.read(classList, inputStream); + + // Check the name + assertEquals(param.name, loadedParam.name); + // Check the value + assertEquals(param.value, loadedParam.value); + // Check the type + assertEquals(param.type, loadedParam.type); + + // Clear the streams + try { + outputStream.flush(); + outputStream.close(); + inputStream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println("----- Testing ParameterList XML Persistence -----"); + + // Setup the second parameter + secondParam.name = "that took Jay all night"; + secondParam.value = "-----"; + secondParam.type = "string"; + + // Setup the parameter lists + pList.name = "ICE's Parameter List"; + pList.parameters = new ArrayList(); + pList.parameters.add(param); + secondPList.name = "ICE's Second Parameter List"; + secondPList.parameters = new ArrayList(); + secondPList.parameters.add(secondParam); + pList.parameterLists = new ArrayList(); + pList.parameterLists.add(secondPList); + + // Write the tree + outputStream = new ByteArrayOutputStream(); + xmlHandler.write(pList, classList, outputStream); + + // Load the tree + inputStream = new ByteArrayInputStream(outputStream.toByteArray()); + loadedList = new ParameterList(); + loadedList = (ParameterList) xmlHandler.read(classList, inputStream); + + // Check the name + assertEquals(pList.name, loadedList.name); + // Check the parameter for the top level tree + assertNotNull(loadedList.parameters.size()); + assertEquals(1, loadedList.parameters.size()); + assertEquals(param.name, loadedList.parameters.get(0).name); + assertEquals(param.value, loadedList.parameters.get(0).value); + assertEquals(param.type, loadedList.parameters.get(0).type); + // Check the second level parameter list in the tree + assertNotNull(loadedList.parameterLists); + assertEquals(1, loadedList.parameterLists.size()); + secondLoadedList = loadedList.parameterLists.get(0); + // Check the parameter for the second level tree + assertNotNull(secondLoadedList.parameters.size()); + assertEquals(1, secondLoadedList.parameters.size()); + assertEquals(secondParam.name, secondLoadedList.parameters.get(0).name); + assertEquals(secondParam.value, + secondLoadedList.parameters.get(0).value); + assertEquals(secondParam.type, secondLoadedList.parameters.get(0).type); + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/RegistryTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/RegistryTester.java new file mode 100644 index 0000000000000000000000000000000000000000..587882585e4e6963fb6d28ce55923868cc4707dc --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/RegistryTester.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2011, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.util.ArrayList; + +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.item.Registry; +import org.junit.*; + +/** + *

+ * The RegistryTester is responsible for testing the Registry class. + *

+ * + * @author Jay Jay Billings + */ +public class RegistryTester { + + /** + */ + private Registry registry; + + /** + * + */ + private FakeDataComponent fakeDataComponent; + + /** + *

+ * This operation tests the Registry class by checking that values can be + * set and retrieved and check for existence. + *

+ */ + @Test + public void checkValues() { + + // Some keys and values + String key1 = "Stone Temple Pilots", value1 = "Dead & Bloated"; + String key2 = "Motley Crue", value2 = "Dr. Feelgood"; + String value3 = "Knife", value4 = "Bow and Arrow"; + + // Create a registry to test + registry = new Registry(); + + // Set the values + registry.setValue(key1, value1); + registry.setValue(key2, value2); + // Check the values + assertEquals(value1, registry.getValue(key1)); + assertEquals(value2, registry.getValue(key2)); + + // Update the values and make sure they changed + registry.updateValue(key1, value3); + registry.updateValue(key2, value4); + assertEquals(value3, registry.getValue(key1)); + assertEquals(value4, registry.getValue(key2)); + + // Make sure that updating a value doesn't work for something that is + // not in the registry + registry.updateValue("not in there key", "not in there value"); + assertNull(registry.getValue("not in there key")); + + return; + + } + + /** + *

+ * This operation tests the Registry class by insuring that Entries can be + * registered against keys. + *

+ */ + @Test + public void checkRegistration() { + // A key and a value + String key = "Seether"; + + // Create a Registry to test + registry = new Registry(); + + // Create the DataComponents + DataComponent dc1 = new DataComponent(); + dc1.setId(1); + dc1.setName("Updated DataComponent"); + DataComponent dc2 = new DataComponent(); + dc1.setId(2); + dc1.setName("Updated DataComponent"); + + // Register the Entries against the key + assertTrue(registry.register(dc1, key)); + assertTrue(registry.register(dc2, key)); + + // Make sure the Registry contains the key + assertTrue(registry.containsKey(key)); + + } + + /** + *

+ * This operation checks the Registry class by checking that it will + * properly update Entries. + *

+ */ + @Test + public void testDispatching() { + // A key and a value + String key = "Disturbed"; + String value = "Prayer"; + + // Create a Registry to test + registry = new Registry(); + + // Create the DataComponents + FakeDataComponent dc1 = new FakeDataComponent(); + dc1.setId(1); + dc1.setName("Updated DataComponent"); + FakeDataComponent dc2 = new FakeDataComponent(); + dc2.setId(2); + dc2.setName("Updated DataComponent"); + + // Register the Entries against the key and insure they are registered + assertTrue(registry.register(dc1, key)); + assertTrue(registry.register(dc2, key)); + + // Set the value and insure it is set + assertTrue(registry.setValue(key, value)); + + // Dispatch updates since the value is set + registry.dispatch(); + + // Check the values of the entries and make sure they were set + assertEquals(value, dc1.getUpdatedValue()); + assertEquals(value, dc2.getUpdatedValue()); + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SerializedItemBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SerializedItemBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..b475372cfc464da65ecede8bf8a36850fdb04960 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SerializedItemBuilderTester.java @@ -0,0 +1,199 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; + +import org.junit.Ignore; +import org.junit.Test; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.SerializedItemBuilder; + +/** + *

+ * The SerializedItemBuilderTester is responsible for testing the + * SerializedItemBuilder. It is primarily concerned with ensuring that the + * SerializedItemBuilder can load an Item from an InputStream and return the + * proper name and type. + *

+ * + * @author Jay Jay Billings + */ +public class SerializedItemBuilderTester { + /** + *

+ * An Item reference used in the testing. + *

+ * + */ + private Item serializedItem; + /** + *

+ * The SerializedItemBuilder under test. + *

+ * + */ + private SerializedItemBuilder serializedItemBuilder; + + /** + *

+ * This operation checks the SerializedItemBuilder using a Painfully Simple + * Form (PSF) file. It checks the name and type of the Item and tries to + * create and check a SerializedItem initialized from the PSF. + *

+ * + */ + @Test + public void checkLoadingFromPSF() { + + // Local Declarations + ByteArrayInputStream stream = null; + Form form = null; + DataComponent dataComp1 = null, dataComp2 = null; + Entry entry = null; + String psfItemString = ""; + + // Local Declarations + ArrayList PSFForm = new ArrayList(); + + // Setup the string containing the Form in PSF format. This was + // taken from the Painfully Simple Form article at + // https://sourceforge.net/apps/mediawiki/niceproject/index.php?title=ICE_Painfully_Simple_Form + // and is a good example because it is complete, contains lots of + // whitespace and comments and, of course, interesting! I have added + // whitespaces and comments in some places to make the test more + // rigorous and changed some of the comment statements from "//" to "#" + // to cover all the possibilities. + PSFForm.add("\t \n"); + PSFForm.add("#Form name and type\n"); + PSFForm.add("formName=PSF Wiki Article Form\n"); + PSFForm.add("formDescription=A PSF Wiki Article Sample\n"); + PSFForm.add("formType=Model\n"); + PSFForm.add(" \n"); + PSFForm.add("#The DataComponents block - it must come first!\n"); + PSFForm.add("group=Assembly\n"); + PSFForm.add("groupDescription=Relevant quantities for modeling a full assembly\n"); + PSFForm.add("\n"); + PSFForm.add("#The Entry blocks will appear below this line"); + PSFForm.add("\n"); + PSFForm.add("\t \n"); + PSFForm.add("#Some comments to ignore at the top\n"); + PSFForm.add("//More comments to ignore at the top\n"); + PSFForm.add("name=Coolant Temperature " + + " #The name that a user " + + "will see\n"); + PSFForm.add("description=The temperature of the coolant that surrounds " + + "the assembly and pins //A description that will help the user\n"); + PSFForm.add("defaultValue=550 " + + " //The default value\n"); + PSFForm.add("allowedValueType=Continuous " + + " //Indicates that the value can be " + + "anything between 550 and 650 K.\n"); + PSFForm.add("allowedValue=550 " + + " //The lower bound of the range\n"); + PSFForm.add("allowedValue=650 " + + " //The upper bound of the range\n"); + PSFForm.add("tag=coolantTemperature " + + " //A tag to mark it\n"); + PSFForm.add("parent=Full Assembly Flag " + + " //The parent\n"); + PSFForm.add("group=Assembly " + + " //The group\n"); + PSFForm.add(" \t \n"); + PSFForm.add("name=Number of Pins\n"); + PSFForm.add("description=The number of pins in an assembly\n"); + PSFForm.add("defaultValue=289\n"); + PSFForm.add("allowedValueType=Discrete\n"); + PSFForm.add("allowedValue=196\n"); + PSFForm.add("allowedValue=289\n"); + PSFForm.add("tag=numberOfPins\n"); + PSFForm.add("parent=Full Assembly Flag\n"); + PSFForm.add("group=Assembly\n"); + PSFForm.add(" \t \n"); + PSFForm.add("name=Full Assembly Flag\n"); + PSFForm.add("description=True if a full assembly should be modeled, false if not\n"); + PSFForm.add("defaultValue=false\n"); + PSFForm.add("allowedValueType=Discrete\n"); + PSFForm.add("allowedValue=true\n"); + PSFForm.add("allowedValue=false\n"); + PSFForm.add("tag=fullAssemblyFlag\n"); + PSFForm.add("group=Assembly\n"); + + // Convert the ArrayList to a string + for (String i : PSFForm) { + psfItemString += i; + } + System.out.println("Printing stream:\n" + psfItemString); + + // Create the InputStream + stream = new ByteArrayInputStream(psfItemString.getBytes()); + + // Setup the builder + try { + serializedItemBuilder = new SerializedItemBuilder(stream); + } catch (IOException e) { + e.printStackTrace(); + fail(); + } + + // Check the name + assertEquals("PSF Wiki Article Form", + serializedItemBuilder.getItemName()); + // Check the type + assertEquals(ItemType.Model, serializedItemBuilder.getItemType()); + + // Build and Item and check its Form + serializedItem = serializedItemBuilder.build(null); + form = serializedItem.getForm(); + assertNotNull(form); + // Check the Form in some random spots - FIXME: Use Form.equals() once + // AJM implements it! + assertEquals("PSF Wiki Article Form", form.getName()); + assertEquals("A PSF Wiki Article Sample", form.getDescription()); + assertEquals(1, form.getNumberOfComponents()); + dataComp1 = (DataComponent) form.getComponent(1); + dataComp2 = (DataComponent) form.getComponent(2); + assertNotNull(dataComp1); + assertEquals("Assembly", dataComp1.getName()); + assertEquals(null, dataComp2);// There should only be one component! + entry = dataComp1.retrieveEntry("Number of Pins"); + assertNotNull(entry); + assertEquals("289", entry.getDefaultValue()); + assertEquals("numberOfPins", entry.getTag()); + + // If we've made it this far, then + + // Try loading the Item from a null stream, which should result in an + // exception + boolean exceptionCaught = false; + try { + serializedItemBuilder = new SerializedItemBuilder(null); + } catch (IOException e) { + // Mark the flag as true. + exceptionCaught = true; + } + // Make sure the exception was caught + assertTrue(exceptionCaught); + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SuiteLauncherTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SuiteLauncherTester.java new file mode 100644 index 0000000000000000000000000000000000000000..2de6066e1aa33b876623ed81e3452c2232539a8b --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/SuiteLauncherTester.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +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.util.ArrayList; + +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.item.jobLauncher.JobLauncher; +import org.eclipse.ice.item.jobLauncher.JobLauncherForm; +import org.eclipse.ice.item.jobLauncher.SuiteLauncher; +import org.junit.Test; + +/** + * This class is responsible for testing the SuiteLauncher. + * + * @author Jay Jay Billings + * + */ +public class SuiteLauncherTester { + + /** + * This operation makes sure that the executables can be dynamically + * configured on the SuiteLauncher. + */ + @Test + public void checkSettingExecutables() { + // Create the launcher + SuiteLauncher launcher = new SuiteLauncher(null); + + // Create the list of executables + ArrayList execs = new ArrayList(); + execs.add("conj_ht"); + execs.add("conj_ht_moab"); + execs.add("bison"); + + // Set the list + launcher.addExecutables(execs); + + // Get the list and check it + DataComponent execComp = (DataComponent) (launcher.getForm()) + .getComponent(JobLauncherForm.parallelId + 2); + Entry execEntry = execComp.retrieveAllEntries().get(0); + assertEquals(execs, execEntry.getAllowedValues()); + + return; + } + + /** + * This operation makes sure that SuiteLaunchers can be copied. + */ + @Test + public void checkCopying() { + + // Local Declarations + SuiteLauncher cloneItem = new SuiteLauncher(), copyItem = new SuiteLauncher(); + SuiteLauncher jobItem = new SuiteLauncher(); + + // Create the list of executables + ArrayList execs = new ArrayList(); + execs.add("conj_ht"); + execs.add("conj_ht_moab"); + execs.add("bison"); + + // Set the launcher details + jobItem.setDescription("I am a job!"); + jobItem.setExecutable("LS", "/opt/bin", "DOIT!!!!"); + + // Set the list + jobItem.addExecutables(execs); + + // run clone operations + cloneItem = (SuiteLauncher) jobItem.clone(); + + // check contents + assertEquals(jobItem.getAvailableActions(), + cloneItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), cloneItem.getDescription()); + assertTrue(jobItem.getForm().equals(cloneItem.getForm())); + assertEquals(jobItem.getId(), cloneItem.getId()); + assertEquals(jobItem.getItemType(), cloneItem.getItemType()); + assertEquals(jobItem.getName(), cloneItem.getName()); + assertEquals(jobItem.getStatus(), cloneItem.getStatus()); + assertEquals(jobItem.getAllHosts(), cloneItem.getAllHosts()); + + // Get the executable list and check it + DataComponent execComp = (DataComponent) cloneItem.getForm() + .getComponent(JobLauncherForm.parallelId + 2); + Entry execEntry = execComp.retrieveAllEntries().get(0); + assertEquals(execs, execEntry.getAllowedValues()); + + // run copy operation + copyItem.copy(jobItem); + + // check contents + assertEquals(jobItem.getAvailableActions(), + copyItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), copyItem.getDescription()); + assertTrue(jobItem.getForm().equals(copyItem.getForm())); + assertEquals(jobItem.getId(), copyItem.getId()); + assertEquals(jobItem.getItemType(), copyItem.getItemType()); + assertEquals(jobItem.getName(), copyItem.getName()); + assertEquals(jobItem.getStatus(), copyItem.getStatus()); + assertEquals(jobItem.getAllHosts(), copyItem.getAllHosts()); + + // Get the executable list and check it + execComp = (DataComponent) copyItem.getForm().getComponent( + JobLauncherForm.parallelId + 2); + execEntry = execComp.retrieveAllEntries().get(0); + assertEquals(execs, execEntry.getAllowedValues()); + + // run copy operation by passing null + copyItem.copy(null); + + // check contents - nothing has changed + assertEquals(jobItem.getAvailableActions(), + copyItem.getAvailableActions()); + assertEquals(jobItem.getDescription(), copyItem.getDescription()); + assertTrue(jobItem.getForm().equals(copyItem.getForm())); + assertEquals(jobItem.getId(), copyItem.getId()); + assertEquals(jobItem.getItemType(), copyItem.getItemType()); + assertEquals(jobItem.getName(), copyItem.getName()); + assertEquals(jobItem.getStatus(), copyItem.getStatus()); + assertEquals(jobItem.getAllHosts(), copyItem.getAllHosts()); + + // Get the executable list and check it + execComp = (DataComponent) copyItem.getForm().getComponent( + JobLauncherForm.parallelId + 2); + execEntry = execComp.retrieveAllEntries().get(0); + assertEquals(execs, execEntry.getAllowedValues()); + + return; + } + + /** + * This operation makes sure that SuiteLaunchers can be accurately checked + * for Equality. + */ + @Test + public void checkEquals() { + // Create JobLauncherItems to test + SuiteLauncher item = new SuiteLauncher(); + SuiteLauncher equalItem = new SuiteLauncher(); + SuiteLauncher unEqualItem = new SuiteLauncher(); + SuiteLauncher transitiveItem = new SuiteLauncher(); + + // Create the list of executables + ArrayList execs = new ArrayList(); + execs.add("conj_ht"); + execs.add("conj_ht_moab"); + execs.add("bison"); + + // Set ids + equalItem.setId(item.getId()); + transitiveItem.setId(item.getId()); + unEqualItem.setId(2); + + // Set names + equalItem.setName(item.getName()); + transitiveItem.setName(item.getName()); + unEqualItem.setName("DC UnEqual"); + + // Set executables + item.addExecutables(execs); + equalItem.addExecutables(execs); + transitiveItem.addExecutables(execs); + unEqualItem.addExecutables(null); + + // Assert two equal Items return true + assertTrue(item.equals(equalItem)); + + // Assert two unequal Items return false + assertFalse(item.equals(unEqualItem)); + + // Assert equals() is reflexive + assertTrue(item.equals(item)); + + // Assert the equals() is Symmetric + assertTrue(item.equals(equalItem) && equalItem.equals(item)); + + // Assert equals() is transitive + if (item.equals(equalItem) && equalItem.equals(transitiveItem)) { + assertTrue(item.equals(transitiveItem)); + } else { + fail(); + } + + // Assert equals is consistent + assertTrue(item.equals(equalItem) && item.equals(equalItem) + && item.equals(equalItem)); + assertTrue(!item.equals(unEqualItem) && !item.equals(unEqualItem) + && !item.equals(unEqualItem)); + + // Assert checking equality with null is false + assertFalse(item==null); + + // Assert that two equal objects return same hashcode + assertTrue(item.equals(equalItem) + && item.hashCode() == equalItem.hashCode()); + + // Assert that hashcode is consistent + assertTrue(item.hashCode() == item.hashCode()); + + // Assert that hashcodes from unequal objects are different + assertTrue(item.hashCode() != unEqualItem.hashCode()); + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TaggedOutputWriterActionTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TaggedOutputWriterActionTester.java new file mode 100644 index 0000000000000000000000000000000000000000..4b3201320dc15d7be9b66b72fe7e21a3385977a0 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TaggedOutputWriterActionTester.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Hashtable; +import java.util.Properties; + +import org.junit.Test; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.item.action.TaggedOutputWriterAction; + +/** + *

+ * This class is responsible for checking that the TaggedOutputWriter action can + * write a set of key-value pairs to an output file. + *

+ * + * @author Jay Jay Billings + */ +public class TaggedOutputWriterActionTester { + /** + * + */ + private TaggedOutputWriterAction taggedOutputWriterAction; + + /** + *

+ * This operation checks that the TaggedOutputWriter action can write a set + * of key-value pairs to an output file. + *

+ * + */ + @Test + public void checkWriting() { + + // Local Declarations + Hashtable testDictionary = new Hashtable(); + + // Create a dictionary + testDictionary.put("Kirk", "captain"); + testDictionary.put("Spock", "first officer"); + testDictionary.put("Bones", "chief medical officer"); + testDictionary.put("Scotty", "chief engineer"); + + // Load and execute the action - make sure it returns the proper return + // value + taggedOutputWriterAction = new TaggedOutputWriterAction(); + // First make sure it returns FormStatus.InfoError if it receives null + assertEquals(FormStatus.InfoError, + taggedOutputWriterAction.execute(null)); + // Second make sure that it returns FormStatus.InfoError if it receives + // a dictionary missing the file name + assertEquals(FormStatus.InfoError, + taggedOutputWriterAction.execute(testDictionary)); + // Add the file name and do the real execution, which should return + // FormStatus.Processed and will write a file that can be checked + testDictionary.put("iceTaggedOutputFileName", "taggedTestFile.txt"); + assertEquals(FormStatus.Processed, + taggedOutputWriterAction.execute(testDictionary)); + + // Check the file + File testFile = new File("taggedTestFile.txt"); + assertTrue(testFile.exists()); + assertTrue(testFile.canRead()); + + // Load the file and check it + Properties testFileProperties = new Properties(); + try { + testFileProperties.load(new FileInputStream(testFile)); + } catch (FileNotFoundException e) { + // Fail if it catches an exception + e.printStackTrace(); + fail(); + } catch (IOException e) { + // Fail if it catches an exception + e.printStackTrace(); + fail(); + } + System.out.println(testFileProperties); + assertTrue(testFileProperties.containsKey("Kirk")); + assertEquals(testFileProperties.get("Kirk"), testDictionary.get("Kirk")); + assertTrue(testFileProperties.containsKey("Spock")); + assertEquals(testFileProperties.get("Spock"), + testDictionary.get("Spock")); + assertTrue(testFileProperties.containsKey("Bones")); + assertEquals(testFileProperties.get("Bones"), + testDictionary.get("Bones")); + assertTrue(testFileProperties.containsKey("Scotty")); + assertEquals(testFileProperties.get("Scotty"), + testDictionary.get("Scotty")); + + // Get rid of the file if everything worked + if (testFile.exists()) { + testFile.delete(); + } + + return; + + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestAction.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestAction.java new file mode 100644 index 0000000000000000000000000000000000000000..710aa11925d3525574ffbb8ba4a04e480f3f42e7 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestAction.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import java.util.Dictionary; + +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.item.action.Action; + +/** + *

+ * The TestAction is used for testing Actions and for faking actions in ICE + * Items. It does not override Action's Form accessors. + *

+ * + * @author Jay Jay Billings + */ +public class TestAction extends Action { + /** + *

+ * The constructor. It initializes the Action's Form to a basic Form. + *

+ * + */ + public TestAction() { + + // Initialize the Form + actionForm = new Form(); + + return; + + } + + /** + * (non-Javadoc) + * + * @see Action#execute(Dictionary dictionary) + */ + public FormStatus execute(Dictionary dictionary) { + // TODO Auto-generated method stub + return null; + } + + /** + * (non-Javadoc) + * + * @see Action#cancel() + */ + public FormStatus cancel() { + // TODO Auto-generated method stub + return null; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItem.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItem.java new file mode 100644 index 0000000000000000000000000000000000000000..bee4b9b612b9526011e559e74f8d034280e63663 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItem.java @@ -0,0 +1,364 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import java.util.ArrayList; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.io.serializable.IReader; +import org.eclipse.ice.io.serializable.IWriter; +import org.eclipse.ice.item.IActionFactory; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.messaging.Message; + +/** + *

+ * This is a subclass of Item that implements setupForm(), reviewEntries() and + * process() so that the other operations of Item can be tested. It creates a + * relatively simple Form that is used during the tests. + *

+ * + * @author Jay Jay Billings + */ +@XmlRootElement(name = "TestItem") +public class TestItem extends Item { + + /** + *

+ * True if the TestItem was successfully updated, false otherwise. + *

+ * + */ + private boolean updated = false; + + /** + *

+ * The constructor + *

+ * + */ + public TestItem() { + // Punt + this(null); + } + + /** + *

+ * The constructor + *

+ * + * @param project + *

+ * The Eclipse IProject that should be used by the TestItem. + *

+ */ + public TestItem(IProject project) { + + super(project); + + } + + /** + *

+ * This operation overrides setupForm() to setup a Form for the tests. + *

+ * + */ + protected void setupForm() { + + // This operations creates four DataComponents and makes + // one of them dependent on the value of another. This setups up a Form + // with the names of the ICE team members circa February 2011. + + // Create the Form + form = new Form(); + + // Create the data components - the first is a Fake for testing + FakeDataComponent dc1 = new FakeDataComponent(); + dc1.setId(1); + dc1.setName("Jay"); + Entry dc1Entry = new Entry(); + dc1Entry.setName("Jay"); + dc1Entry.setValue("Awesome"); + dc1Entry.setTag("jayjaybillings"); + dc1.addEntry(dc1Entry); + + DataComponent dc2 = new DataComponent(); + dc2.setId(2); + dc2.setName("David"); + Entry dc2Entry = new Entry(); + dc2Entry.setId(5); + dc2Entry.setName("David's Entry"); + dc2Entry.setValue("The boss"); + dc2.addEntry(dc2Entry); + + DataComponent dc3 = new DataComponent(); + dc3.setId(3); + dc3.setName("Alex"); + + DataComponent dc4 = new DataComponent(); + dc4.setId(4); + dc4.setName("Bobo the Drunken Clown"); + + // Add the components to the Form + form.addComponent(dc1); + form.addComponent(dc2); + form.addComponent(dc3); + form.addComponent(dc4); + + // Set the particulars about the Item + setName("Test Item"); + setId(15); + setDescription("An Item used for testing."); + + return; + } + + /** + *

+ * This operation overrides reviewEntries to modify the Form that it setup + * in some specific ways. + *

+ * + * @param preparedForm + *

+ * The Form under review. + *

+ * @return

+ * The status. + *

+ */ + protected FormStatus reviewEntries(Form preparedForm) { + + // This implementation of reviewEntries looks for the value + // of David and passes it to Jay through the Registry. + + // Local Declarations + int i = 0; + FormStatus retVal = FormStatus.InfoError; + ArrayList components = new ArrayList(); + DataComponent dc2 = null; + Entry dc2Entry = null; + + // Grab the DataComponents + for (i = 0; i < this.form.getNumberOfComponents(); i++) { + components.add((DataComponent) form.getComponent(i + 1)); + } + + // Get David's data component in the list and get + // the value from David's entry + dc2 = components.get(1); + dc2Entry = ((DataComponent) dc2).retrieveEntry("David's Entry"); + // Set the value in the Registry + registry.setValue("Boss", dc2Entry.getValue()); + // Set the return value + if (dc2Entry != null) { + retVal = FormStatus.ReadyToProcess; + } + // Tell the Registry to dispatch any updates that are waiting + registry.dispatch(); + + // Return + return retVal; + } + + /** + *

+ * Overrides super class operation to register a data component. + *

+ * + */ + protected void registerUpdateables() { + + // Call the super class' registerUpdateables operation first + super.registerUpdateables(); + + // Register Entries against keys + registry.register(form.getComponent(1), "Boss"); + + return; + } + + /** + *

+ * This operation directs the TestItem to notify its listeners so that the + * ItemTester can see that the Item super class correctly handles the + * request. + *

+ * + */ + public void notifyListeners() { + + notifyListenersOfProjectChange(); + + return; + } + + /** + *

+ * This operation fakes setting some preferences, but calls + * getPreferencesDirectory() so that the Item base class tries to create the + * preferences directory. + *

+ * + */ + public void setPreferences() { + + // Force the Item to create a preferences directory + getPreferencesDirectory(); + + return; + } + + /** + *

+ * This operation returns true if the TestItem was successfully updated, + * false otherwise. + *

+ * + * @return

+ * True if updated, false otherwise. + *

+ */ + public boolean wasUpdated() { + return updated; + } + + /** + * This operation overrides Item.update() to catch the update and mark the + * update flag. + */ + @Override + public boolean update(Message msg) { + super.update(msg); + updated = true; + return true; + } + + /** + * This method is used by ItemTester to test that Item.getFiles functions + * appropriately. + * + * @param directory + * @return + */ + public ArrayList getYAMLFiles(String directory) { + return getFiles(directory, ".yaml"); + } + + /** + * This method is used by the ItemTester to test that the Item.moveFile + * method functions correctly. + * + * @param fromDir + * @param toDir + * @param fileName + */ + public void moveTestFile(String fromDir, String toDir, String fileName) { + moveFile(fromDir, toDir, fileName); + } + + /** + * This method is used by the ItemTester to test that the + * Item.deleteDirectory method functions correctly. + * + * @param dir + */ + public void deleteTestDirectory(String dir) { + deleteDirectory(dir); + } + + /** + * This method is used by the ItemTester to test that the Item.copyFile + * method functions correctly. + * + * @param fromDir + * @param toDir + * @param newName + */ + public void copyTestFile(String fromDir, String toDir, String newName) { + copyFile(fromDir, toDir, newName); + } + + /** + * This method is used by the ItemTester to test that the Item.copyFiles + * method functions correctly. + * + * @param fromDir + * @param toDir + * @param newName + */ + public void copyMultipleFiles(String src, String dest, String ext) { + + copyFiles(src, dest, ext); + + } + + /** + * This method is used by the ItemTester to test that the Item.moveiles + * method functions correctly. + * + * @param fromDir + * @param toDir + * @param newName + */ + public void moveMultipleFiles(String src, String dest, String ext) { + moveFiles(src, dest, ext); + } + + /** + * This method is used by the ItemTester to test that the Item.moveiles + * method functions correctly. + * + * @param fromDir + * @param toDir + * @param newName + */ + public void copyTestDirectory(String src, String dest) { + copyDirectory(src, dest); + } + + /** + * Return the IO type, this is used for the ItemTester.checkIOService. + */ + @Override + protected String getIOType() { + return "fake"; + } + + /** + * This method is just a utility for ItemTester to check that the IReader + * reference is valid. + * + * @return + */ + public IReader getTestReader() { + return getReader(); + } + + /** + * This method is just a utility for ItemTester to check that the IWriter + * reference is valid. + * + * @return + */ + public IWriter getTestWriter() { + return getWriter(); + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItemBuilder.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItemBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..6492f8835b6aeb5d331d8e60b202c63831cb01e9 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestItemBuilder.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemBuilder; +import org.eclipse.ice.item.ItemType; + +/** + * A simple builder for the TestItem so that the XML Persistence Provider can be + * configured. + * + * @author Jay Jay Billings + * + */ +public class TestItemBuilder implements ItemBuilder { + + @Override + public String getItemName() { + return "Test Item"; + } + + @Override + public ItemType getItemType() { + return ItemType.Simulation; + } + + @Override + public Item build(IProject projectSpace) { + return new TestItem(projectSpace); + } + +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java new file mode 100644 index 0000000000000000000000000000000000000000..0f5b2c7beccd69b4957478f9f78428d974403954 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2012, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ice.item.IActionFactory; +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.jobLauncher.JobLauncher; + +/** + *

+ * This class inherits from JobLauncher and sets the test executable to the "ls" + * command. It is only used for testing and for setting this executable command + * name. Everything else is handled by the JobLauncher. + *

+ * + * @author Jay Jay Billings + */ +public class TestJobLauncher extends JobLauncher { + + /** + * True if the setupFormWithServices() operation was called, false otherwise. + */ + boolean setupAfterServices = false; + + /** + * The Constructor + * + * @param projectSpace + */ + public TestJobLauncher(IProject projectSpace) { + super(projectSpace); + } + + /** + * This operation sets the executable name to ls + * + * @see Item#setupForm() + */ + @Override + protected void setupForm() { + + // Setup the Form + super.setupForm(); + + // Setup the executable information + setExecutable("ls", "A launcher for the " + "\"ls\" command. ", "ls"); + + // Add a dummy host + addHost("notlocalhost", "linux", "/bin"); + + return; + } + + /** + * This operation returns the ActionFactory so that the tests can make sure + * the Items received the services. + */ + public IActionFactory getActionFactoryForTest() { + return getActionFactory(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ice.item.Item#setupFormWithServices() + */ + public void setupFormWithServices() { + setupAfterServices = true; + } + + /** + * This operation describes whether or not the setupFormWithServices + * operation was called after the Item was constructed. It is used by the + * tests to make sure that the AbstractItemBuilder builds the Item properly. + * + * @return True if the setupFormWithServices operation was called, false + * otherwise. + */ + public boolean setupFormWithServicesWasCalled() { + return setupAfterServices; + } + +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/YAMLTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/YAMLTester.java new file mode 100644 index 0000000000000000000000000000000000000000..8a90b3df818eb32c5ffa3fe4167615590bb80971 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/YAMLTester.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Map; + +import org.junit.Test; +import org.yaml.snakeyaml.*; + +/** + * This class tests the SnakeYAML parser to make sure that it is integrated into + * ICE IO correctly. + * + * @author Jay Jay Billings + * + */ +public class YAMLTester { + + /** + * This operation runs a simple SnakeYAML example from their website and + * checks the results. + */ + @Test + public void checkSnakeYAML() { + + // Create a YAML tree + Yaml yaml = new Yaml(); + String document = "hello: 25"; + // Load it from the string + Map map = (Map) yaml.load(document); + // Check the map + assertEquals("{hello=25}", map.toString()); + assertEquals(new Integer(25), map.get("hello")); + + return; + } + + /** + * This operation loads input from INL's BISON application, based on MOOSE, + * to make sure that the file can be parsed. It is also based on an example + * from the SnakeYAML website. + */ + @Test + public void checkSnakeYAMLWithBison() { + + // Local Declarations + String separator = System.getProperty("file.separator"); + InputStream input = null; + File bisonFile = null; + String userDir = System.getProperty("user.home") + separator + + "ICETests" + separator + "itemData"; + + // Load the bison file + try { + bisonFile = new File(userDir + separator + "bison.yaml"); + input = new FileInputStream(bisonFile); + } catch (FileNotFoundException e) { + // Complain if the file is not found + e.printStackTrace(); + // Fail, cry and go home ;) + fail(); + } + + // Load the YAML tree + Yaml yaml = new Yaml(); + ArrayList data = (ArrayList) yaml.load(input); + Map dataMap = (Map) data.get(0); + + // Dump the file for review + // String output = yaml.dump(data); + // System.out.println(output); + + // Check the input. The short input file only has the /Adaptivity block + // from the input, so size = 1. + assertEquals(34, data.size()); + // Check the name, type and description of the /Adaptivity block + assertEquals("/Adaptivity", dataMap.get("name")); + assertEquals("", dataMap.get("description")); + assertEquals(null, dataMap.get("type")); + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/messaging/MessageTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/messaging/MessageTester.java new file mode 100644 index 0000000000000000000000000000000000000000..a459d05998048a703de72034854b1f5843906e92 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/messaging/MessageTester.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.messaging; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.ice.item.messaging.Message; +import org.junit.Test; + +/** + *

+ * This class is responsible for testing the Message class to make sure the Bean + * works correctly. + *

+ * + * @author Jay Jay Billings + */ +public class MessageTester { + /** + *

+ * This operation makes sure that the accessors of the Message class work. + *

+ * + */ + @Test + public void checkAccessors() { + + // Local Declarations + int id = 1, itemId = 2; + String type = "FILE_UPDATED", content = "Starfleet Academy"; + + // Create a message + Message msg = new Message(); + msg.setId(id); + msg.setItemId(itemId); + msg.setMessage(content); + msg.setType(type); + + // Check it + assertEquals(id, msg.getId()); + assertEquals(itemId, msg.getItemId()); + assertEquals(content, msg.getMessage()); + assertEquals(type, msg.getType()); + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/BlockTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/BlockTester.java new file mode 100644 index 0000000000000000000000000000000000000000..fef44096bf1ee8b8fdfac76fa47f5433fdc7a045 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/BlockTester.java @@ -0,0 +1,342 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.moose; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; + +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.item.utilities.moose.Block; +import org.eclipse.ice.item.utilities.moose.Parameter; +import org.junit.Test; + +/** + * This operation checks the MOOSE Block class. The loadFromMap() operation is + * checked by the MOOSEFileHandlerTester class because it requires integration + * with SnakeYAML. + * + * @author Jay Jay Billings + */ +public class BlockTester { + /** + * This operation checks the accessors for the Block class. + */ + @Test + public void checkAccessors() { + + // Local Declarations + String name = "Snow", description = "Snow always mirrors"; + String comment = "Some comment", type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + ArrayList paramList = new ArrayList(); + Block block = new Block(), subBlock = new Block(); + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setDescription(description); + block.setComment(comment); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type("Test Param 1"); + param1.setDescription("Test Param 1"); + param1.setRequired(true); + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault("Test Param 2"); + param2.setCpp_type("Test Param 2"); + param2.setDescription("Test Param 2"); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + block.setActive(true); + + // Check the block + assertEquals(name, block.getName()); + assertEquals(description, block.getDescription()); + assertEquals(comment, block.getComment()); + assertEquals(type, block.getType()); + assertEquals(blockList.size(), block.getSubblocks().size()); + assertEquals(true, block.isActive()); + assertEquals(paramList.size(), block.getParameters().size()); + + // Check switching the required mode off + block.setActive(false); + assertEquals(false, block.isActive()); + + return; + + } + + /** + * This operation checks the ability of the Block to write itself to an ICE + * TreeComposite. + */ + @Test + public void checkToTreeComposite() { + + // Local Declarations + String name = "Snow", description = "Snow always mirrors"; + String type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + ArrayList paramList = new ArrayList(); + Block block = new Block(), subBlock = new Block(); + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setDescription(description); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type("Test Param 1"); + param1.setDescription("Test Param 1"); + param1.setRequired(true); + + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault("Test Param 2"); + param2.setCpp_type("Test Param 2"); + param2.setDescription("Test Param 2"); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + block.setActive(true); + + // Create a TreeComposite from the Block + TreeComposite tree = block.toTreeComposite(); + + // Check the tree + assertEquals(name, tree.getName()); + assertEquals(description, tree.getDescription()); + assertEquals(true, tree.isActive()); + // Check the parameters + assertEquals(1, tree.getNumberOfDataNodes()); + assertTrue(tree.getComponent(1) instanceof DataComponent); + DataComponent parameters = (DataComponent) tree.getComponent(1); + assertEquals(paramList.size(), parameters.retrieveAllEntries().size()); + // Check the subblocks + assertEquals(blockList.size(), tree.getNumberOfChildren()); + + return; + } + + /** + * This operation checks the ability of the block to write itself in a + * GetPot compatible string. + */ + @Test + public void checkToGetPot() { + + // Local Declarations + String name = "Snow", comment = "Snow always mirrors"; + String type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + Parameter param3 = new Parameter(); + ArrayList paramList = new ArrayList(); + ArrayList subBlockParamList = new ArrayList(); + Block block = new Block(), subBlock = new Block(); + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setComment(comment); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type("Test Param 1"); + param1.setRequired(true); + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault(""); + param2.setCpp_type("Test Param 2"); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + block.setActive(true); + + // Setup the subblock + param3.setName("Test Param 3"); + param3.setDefault("Test Param 3"); + param3.setCpp_type("Test Param 3"); + param3.setRequired(true); + subBlockParamList.add(param3); + subBlock.setParameters(subBlockParamList); + subBlock.setActive(true); + + // Create a GetPot string from the Block and check it + // System.out.println(block.toGetPot(null)); + String testString = + "[Snow] # Snow always mirrors\n" + + " Test Param 1 = Test Param 1\n" + + "# Test Param 2 = \n" + + " [./]\n" + + " Test Param 3 = Test Param 3\n" + + " [../]\n" + + "[]\n"; + // System.out.println(testString); + assertEquals(testString, block.toGetPot(null)); + // Make sure that toString() works as described. + // System.out.println(testString); + assertEquals(testString, block.toString()); + + return; + } + + /** + * This operation checks the Block to make sure that it can be loaded from a + * GetPot-compatible string. + */ + @Test + public void checkFromGetPot() { + + // Local Declarations + String name = "Snow", description = "Snow always mirrors"; + String type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + Parameter param3 = new Parameter(); + ArrayList paramList = new ArrayList(); + ArrayList subBlockParamList = new ArrayList(); + Block block = new Block(), subBlock = new Block(); + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setDescription(description); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type("Test Param 1"); + param1.setRequired(true); + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault("Test Param 2"); + param2.setCpp_type("Test Param 2"); + param2.setRequired(true); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + block.setActive(true); + + // Setup the subblock + param3.setName("Test Param 3"); + param3.setDefault("Test Param 3"); + param3.setCpp_type("Test Param 3"); + param3.setRequired(true); + subBlockParamList.add(param3); + subBlock.setParameters(subBlockParamList); + subBlock.setActive(true); + + // Create a block to test + Block testBlock = new Block(); + testBlock.fromGetPot(block.toGetPot(null)); + System.out.println(block.toGetPot(null)); + + // Check the block information + assertEquals(block.getName(), testBlock.getName()); + + // Grab the parameters from the test block + ArrayList testParameters = testBlock.getParameters(); + assertEquals(block.getParameters().size(), testParameters.size()); + // Check the first one + Parameter testParam = testParameters.get(0); + assertEquals(param1.getName(), testParam.getName()); + assertEquals(param1.getDefault(), testParam.getDefault()); + // Check the second one + testParam = testParameters.get(1); + assertEquals(param2.getName(), testParam.getName()); + assertEquals(param2.getDefault(), testParam.getDefault()); + + // Grab the subblock and check it + ArrayList testSubBlocks = testBlock.getSubblocks(); + assertEquals(block.getSubblocks().size(), testSubBlocks.size()); + Block testSubBlock = testSubBlocks.get(0); + assertEquals(subBlock.getName(), testSubBlock.getName()); + // Check the parameter list of the subblock + testParameters = testSubBlock.getParameters(); + assertEquals(subBlock.getParameters().size(), testParameters.size()); + // Check the parameter + testParam = testParameters.get(0); + assertEquals(param3.getName(), testParam.getName()); + assertEquals(param3.getDefault(), testParam.getDefault()); + + return; + } + + /** + * This operation checks the Block to make sure that it can be loaded from a + * TreeComposite. + */ + @Test + public void checkFromTreeComposite() { + + // Local Declarations + String name = "Snow", description = "Snow always mirrors"; + String type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + ArrayList paramList = new ArrayList(); + Block block = new Block(), subBlock = new Block(), testBlock = null; + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setDescription(description); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type(type); + param1.setDescription("Test Param 1"); + param1.setRequired(true); + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault("Test Param 2"); + param2.setCpp_type(type); + param2.setDescription("Test Param 2"); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + block.setActive(true); + + // Create a TreeComposite from the Block + TreeComposite tree = block.toTreeComposite(); + assertNotNull(tree); + + // Load the test block + testBlock = new Block(); + testBlock.fromTreeComposite(tree); + + // Check the Block + assertEquals(block.getName(), testBlock.getName()); + assertEquals(block.getDescription(), testBlock.getDescription()); + assertEquals(block.getParameters().size(), testBlock.getParameters() + .size()); + assertEquals(block.getSubblocks().size(), testBlock.getSubblocks() + .size()); + assertEquals(block.isActive(), testBlock.isActive()); + // System.out.println(block.toGetPot(null)); + + // There's no need to check the children thoroughly. At least, not yet. + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java new file mode 100644 index 0000000000000000000000000000000000000000..8c4c9ec9ba85dde1b03fa6c244c4c5934d966846 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java @@ -0,0 +1,397 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.moose; + +import static org.junit.Assert.*; + +import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; +import org.eclipse.ice.item.utilities.moose.Parameter; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; + +import org.junit.Test; + +/** + * This class tests the MOOSEFileHandler. + * + * @author Jay Jay Billings + */ +public class MOOSEFileHandlerTester { + /** + * This operation makes sure that MOOSE data can be loaded a gold-standard + * YAML file. + */ + @Test + public void checkLoadingFromYAML() { + + // Local Declarations + 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"; + 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 blocks = null; + try { + blocks = handler.loadYAML(shortFilePath); + } catch (IOException e) { + e.printStackTrace(); + } + + // Check the blocks. This file should only have one block. + assertNotNull(blocks); + assertEquals(3, 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()); + // 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); + + return; + + } + + /** + * This method is responsible for checking that action syntax file is + * correctly loaded. + * + * @throws IOException + */ + @Test + public void checkLoadingActionSyntax() throws IOException { + + // Local declarations + String separator = System.getProperty("file.separator"); + String userDir = System.getProperty("user.home") + separator + + "ICETests" + separator + "itemData"; + String pathName = userDir + separator + "bison.syntax"; + + // Create a new MOOSEFileHandler + MOOSEFileHandler handler = new MOOSEFileHandler(); + + // Load the action syntax + ArrayList actionSyntax = handler.loadActionSyntax(pathName); + + // Verify it loaded an ArrayList correctly + assertNotNull(actionSyntax); + assertEquals(21, 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("Executioner/TimeStepper", actionSyntax.get(13)); + assertEquals("GlobalParams", actionSyntax.get(14)); + assertEquals("Problem", actionSyntax.get(19)); + assertEquals("Variables/*/InitialCondition", actionSyntax.get(20)); + + // Try loading with an invalid pathname + actionSyntax = handler.loadActionSyntax(null); + + // Check that it didn't work + assertNull(actionSyntax); + + return; + } + + /** + * This operation ensures that the MOOSEFileHandler can create a MOOSE input + * file from a set of incoming TreeComposites. + */ + @Test + public void checkWritingInputFileFromTree() { + + // 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"; + 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; + + // Load the blocks + ArrayList blocks = null; + try { + blocks = handler.loadYAML(filePath); + } catch (IOException e1) { + e1.printStackTrace(); + } + + // Create an analytical indicator + adaptivity = blocks.get(0); + indicators = (TreeComposite) adaptivity.getChildExemplars().get(0) + .clone(); + analyticalIndicator = (TreeComposite) indicators.getChildExemplars() + .get(1).clone(); + fluxJumpIndicator = (TreeComposite) indicators.getChildExemplars() + .get(2).clone(); + // Add these to the block. It *MUST* be done in this order. + adaptivity.setNextChild(indicators); + indicators.setNextChild(analyticalIndicator); + analyticalIndicator.setActive(true); + indicators.setNextChild(fluxJumpIndicator); + // Make the blocks active + adaptivity.setActive(true); + indicators.setActive(true); + analyticalIndicator.setActive(true); + fluxJumpIndicator.setActive(true); + + // Get and mark the enabled entries for the Adaptivity tree. + DataComponent adaptivityData = (DataComponent) adaptivity.getDataNodes().get(0); + adaptivity.setActiveDataNode(adaptivityData); + adaptivityData.retrieveEntry("initial_steps").setTag("true"); + adaptivityData.retrieveEntry("marker").setTag("true"); + adaptivityData.retrieveEntry("steps").setTag("true"); + + // Get and set entries for the Indicators subblocks + DataComponent analyticalIndicatorsComponent = + (DataComponent) analyticalIndicator.getDataNodes().get(0); + analyticalIndicatorsComponent.retrieveEntry("block").setTag("false"); + analyticalIndicatorsComponent.retrieveEntry("type").setTag("true"); + // "function" and "variable" are marked required by the YAML file + DataComponent fluxJumpIndicatorComponent = + (DataComponent) fluxJumpIndicator.getDataNodes().get(0); + fluxJumpIndicatorComponent.retrieveEntry("block").setTag("false"); + fluxJumpIndicatorComponent.retrieveEntry("scale_by_flux_faces").setTag("false"); + 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(); + // Add the exemplar clone back into the function. Again it *MUST* be + // done this way. + function.setNextChild(powerHistory); + // Configure the power history + powerHistory.setName("power_history"); + // Activate both nodes + function.setActive(true); + powerHistory.setActive(true); + + // Configure the power history tree's data + DataComponent powerData = (DataComponent) powerHistory.getDataNodes().get(0); + powerData.retrieveEntry("type").setTag("true"); + powerData.retrieveEntry("scale_factor").setTag("true"); + // Add a parameter for the data file + Parameter dataFileParam = new Parameter(); + dataFileParam.setName("data_file"); + dataFileParam.setDefault("powerhistory.csv"); + dataFileParam.setEnabled(true); + powerData.addEntry(dataFileParam.toEntry()); + + // Dump the input file + handler.dumpInputFile(outputFilePath, blocks); + + // Check to see if the file(s) exists + outputFile = new File(outputFilePath); + assertTrue(outputFile.exists()); + + // Compare the input file to the reference file + int firstHash, lastHash; + try { + // Load the input file into a byte array + RandomAccessFile inputFileRAF = new RandomAccessFile(inputFilePath, + "r"); + byte[] inputBytes = new byte[(int) inputFileRAF.length()]; + inputFileRAF.read(inputBytes); + // Convert to a string + String inputString = new String(inputBytes); + + // Chop off the comments at the end of each line. The parameter + // descriptions from the YAML file are appended as comments via the + // process loading YAML through the MOOSEFileHandler. But this is + // an additional feature, and these comments aren't found in the + // original reference file, so we must remove them for testing + String[] inputArray = inputString.split("\\n+"); + inputString = ""; + boolean hasComment = false; + for (String line : inputArray) { + hasComment = !(line.lastIndexOf(" # ") == -1); + if (hasComment) { + + // Figure out if it's the whole line commented out, or just + // an in-line comment (only remove the inline) + firstHash = line.trim().indexOf("#"); + lastHash = line.trim().lastIndexOf("#"); + + // If the whole line is commented out, and has no in-line + // comment + if (firstHash == 0 && firstHash == lastHash) { + // do nothing + } else { + // Lop off the in-line comment. Unfortunately we must + // do this, as loading up a YAML file adds descriptions + // as comments, so the files won't be exactly the same. + line = line.substring(0, line.lastIndexOf(" # ")); + line = line.replaceAll("\\s+$", ""); + } + + if (line.endsWith("=")) { + line += " "; + } + } + + inputString += line + "\n"; + } + + // Load the reference file into a byte array + RandomAccessFile refFileRAF = new RandomAccessFile(refFilePath, "r"); + byte[] refBytes = new byte[(int) refFileRAF.length()]; + refFileRAF.read(refBytes); + // Convert to a string + String refString = new String(refBytes); + + // Compare the strings + System.out.println(inputString); + assertEquals(refString, inputString); + // Close everything + inputFileRAF.close(); + refFileRAF.close(); + outputFile.deleteOnExit(); + } catch (IOException e) { + e.printStackTrace(); + fail(); + } + + return; + } + + /** + * This operation checks the MOOSEFileHandler to make sure that it can load + * a MOOSE GetPot file into a TreeComposite. + */ + @Test + public void checkLoadingFromGetPot() { + + // 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"; + // Turn debugging on + System.setProperty("DebugICE", "on"); + // Create the handler + MOOSEFileHandler handler = new MOOSEFileHandler(); + + // Load the file into a TreeComposite with the Handler + ArrayList potTree = handler.loadFromGetPot(refFilePath); + + // Hehe... "potTree." + + // Write an output file based on the tree that was loaded + handler.dumpInputFile(outFilePath, potTree); + + // Compare the input file to the reference file + try { + // Load the reference file into a byte array + RandomAccessFile refFileRAF = new RandomAccessFile(refFilePath, "r"); + byte[] refBytes = new byte[(int) refFileRAF.length()]; + refFileRAF.read(refBytes); + // Load the input file into a byte array + RandomAccessFile outputFileRAF = new RandomAccessFile(outFilePath, + "r"); + byte[] outputBytes = new byte[(int) outputFileRAF.length()]; + outputFileRAF.read(outputBytes); + // Compare the strings + assertEquals(new String(refBytes), new String(outputBytes)); + // Close everything + outputFileRAF.close(); + refFileRAF.close(); + // Delete the output file + File inputFile = new File(outFilePath); + inputFile.delete(); + } catch (IOException e) { + e.printStackTrace(); + // One reason that this might happen is because the tree wasn't + // loaded from the pot file correctly. + fail(); + } + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/ParameterTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/ParameterTester.java new file mode 100644 index 0000000000000000000000000000000000000000..7909622eccd8e25d92cc348bb6608dce4201f757 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/ParameterTester.java @@ -0,0 +1,201 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.moose; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.item.utilities.moose.Parameter; + +/** + * This operation checks the MOOSE Parameter class. + * + * @author Jay Jay Billings + */ +public class ParameterTester { + + /** + * This operation checks the accessors for the Parameter class. + */ + @Test + public void checkAccessors() { + + // Local Declarations + String name = "Clara", description = "Companion", defaultValue = "Oswin"; + String comment = "Souffle Girl", group_name = "Oswald", cpp_type = "MooseEnum"; + boolean required = true; + String options = "option1 option2 option3"; + Parameter param = new Parameter(); + + // Setup the parameter + param.setName(name); + param.setCpp_type(cpp_type); + param.setDefault(defaultValue); + param.setDescription(description); + param.setComment(comment); + param.setGroup_name(group_name); + param.setRequired(required); + param.setOptions(options); + + // Check the parameter + assertEquals(name, param.getName()); + assertEquals(description, param.getDescription()); + assertEquals(comment, param.getComment()); + assertEquals(group_name, param.getGroup_name()); + assertEquals(required, param.isRequired()); + assertEquals(cpp_type, param.getCpp_type()); + assertEquals(defaultValue, param.getDefault()); + assertEquals(param.getOptions().toString(), "[option1, option2, option3]"); + + // Check switching the required mode off + param.setRequired(false); + assertEquals(false, param.isRequired()); + + return; + } + + /** + * This operation checks the ability of the Parameter to write itself to a + * ICE Entry. + */ + @Test + public void checkToEntry() { + + // Local Declarations + String name = "Souffle Girl", description = "Companion", defaultValue = "option1"; + String group_name = "Clara", cpp_type = "MooseEnum", comment = "Some comment"; + boolean required = true; + String options = "option1 option2 option3"; + Parameter param = new Parameter(); + + // Setup the parameter + param.setName(name); + param.setCpp_type(cpp_type); + param.setDefault(defaultValue); + param.setDescription(description); + param.setComment(comment); + param.setGroup_name(group_name); + param.setRequired(required); + param.setOptions(options); + + // Get the Entry + Entry entry = param.toEntry(); + + // Check the Entry + assertEquals(name, entry.getName()); + assertEquals(description, entry.getDescription()); + assertEquals(comment, entry.getComment()); + assertEquals(defaultValue, entry.getDefaultValue()); + assertEquals(required, entry.isRequired()); + assertEquals(entry.getValueType(), AllowedValueType.Discrete); + assertEquals(entry.getAllowedValues().toString(), + "[option1, option2, option3]"); + + return; + } + + /** + * This operation checks the ability of the parameter to write itself as a + * string. + */ + @Test + public void checkToString() { + + // Local Declarations + String name = "Clara", description = "Companion", defaultValue = "Oswin"; + String group_name = "Oswald", cpp_type = "std::string"; + boolean required = true; + Parameter param = new Parameter(); + + // Setup the parameter + param.setName(name); + param.setCpp_type(cpp_type); + param.setDefault(defaultValue); + param.setDescription(description); + param.setGroup_name(group_name); + param.setRequired(required); + + // Check the string + assertEquals(name + " = " + defaultValue, param.toString()); + + return; + } + + /** + * This operation checks the Parameter class to make sure that it can be + * loaded from a string. + */ + @Test + public void checkFromString() { + + // Local Declarations + String name = "Clara", defaultValue = "Companion"; + String paramString = name + " = " + defaultValue; + Parameter param = new Parameter(); + + // Load the parameter + param.fromString(paramString); + // Check the parameter + assertEquals(name, param.getName()); + assertEquals(defaultValue, param.getDefault()); + + return; + } + + /** + * This operation checks the Parameter to make sure that it can be loaded + * from an Entry. + */ + @Test + public void checkFromEntry() { + + // Local Declarations + String name = "Amy", description = "Companion", defaultValue = "option2"; + String group_name = "Pond", cpp_type = "MooseEnum", comment = "Scottish"; + boolean required = true; + String options = "option1 option2 option3"; + Parameter param = new Parameter(), testParam = null; + Entry paramEntry = null; + + // Setup the parameter + param.setName(name); + param.setCpp_type(cpp_type); + param.setDefault(defaultValue); + param.setDescription(description); + param.setComment(comment); + param.setGroup_name(group_name); + param.setRequired(required); + param.setOptions(options); + + // Create an Entry from the parameter + paramEntry = param.toEntry(); + assertNotNull(paramEntry); + + // Load the test parameter + testParam = new Parameter(); + testParam.fromEntry(paramEntry); + + // Check the Parameter. Only the name, description and value are + // converted. + assertEquals(param.getName(), testParam.getName()); + assertEquals(param.getDescription(), testParam.getDescription()); + assertEquals(param.getComment(), testParam.getComment()); + assertEquals(param.getDefault(), testParam.getDefault()); + assertEquals(param.isRequired(), testParam.isRequired()); + assertEquals(param.getOptions(), testParam.getOptions()); + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/YAMLBlockTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/YAMLBlockTester.java new file mode 100644 index 0000000000000000000000000000000000000000..90636f0301d969d7bb725b52b61f75ba0aeaddb3 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/YAMLBlockTester.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.moose; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.item.utilities.moose.Block; +import org.eclipse.ice.item.utilities.moose.Parameter; +import org.eclipse.ice.item.utilities.moose.YAMLBlock; + +import java.util.ArrayList; + +import org.junit.Test; + +/** + * This class is responsible for testing the YAMLBlock class. + * + * @author Jay Jay Billings + */ +public class YAMLBlockTester { + /** + * This operation checks the ability of the YAMLBlock to write itself to a + * ICE TreeComposite. + */ + @Test + public void checkToTreeComposite() { + + // Local Declarations + String name = "Snow", description = "Snow always mirrors"; + String type = "std::string"; + Parameter param1 = new Parameter(), param2 = new Parameter(); + ArrayList paramList = new ArrayList(); + Block block = new YAMLBlock(), subBlock = new YAMLBlock(); + ArrayList blockList = new ArrayList(); + + // Setup the block + block.setName(name); + block.setType(type); + block.setDescription(description); + param1.setName("Test Param 1"); + param1.setDefault("Test Param 1"); + param1.setCpp_type("Test Param 1"); + param1.setDescription("Test Param 1"); + param1.setComment("Test Param 1"); + param1.setRequired(true); + paramList.add(param1); + param2.setName("Test Param 2"); + param2.setDefault("Test Param 2"); + param2.setCpp_type("Test Param 2"); + param2.setDescription("Test Param 2"); + param2.setComment("Test Param 2"); + paramList.add(param2); + block.setParameters(paramList); + blockList.add(subBlock); + block.setSubblocks(blockList); + + // Create a TreeComposite from the Block + TreeComposite tree = block.toTreeComposite(); + + // Check the tree + assertEquals(name, tree.getName()); + assertEquals(description, tree.getDescription()); + assertEquals(type, block.getType()); + // Check the parameters + assertEquals(1, tree.getNumberOfDataNodes()); + assertTrue(tree.getComponent(1) instanceof DataComponent); + DataComponent parameters = (DataComponent) tree.getComponent(1); + assertEquals(paramList.size(), parameters.retrieveAllEntries().size()); + // Check the subblocks. For YAML blocks they should be configured as + // child exemplars of the TreeComposite. + assertEquals(0, tree.getNumberOfChildren()); + assertTrue(tree.hasChildExemplars()); + assertEquals(blockList.size(), tree.getChildExemplars().size()); + + return; + } +} diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java new file mode 100644 index 0000000000000000000000000000000000000000..9bb914d0644d94dc5a163760732d309b166d6979 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java @@ -0,0 +1,227 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.nuclear; + +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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.net.URI; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.io.serializable.IOService; +import org.eclipse.ice.item.nuclear.MOOSELauncher; +import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This class tests the MOOSELauncher Item to make sure that it can correctly + * create its Form and process a modified Form. + * + * @author Jay Jay Billings + */ +public class MOOSELauncherTester { + + /** + * The project space used to create the workspace for the tests. + */ + private static IProject projectSpace; + + /** + * The IO Service used to read/write via MOOSEFileHandler. + */ + private static IOService service; + + /** + * A MOOSE Launcher used for testing. + */ + private static MOOSELauncher launcher; + + /** + * This operation sets up the workspace. It copies the necessary MOOSE data + * files into ${workspace}/MOOSE. + */ + @BeforeClass + public static void beforeTests() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String projectName = "MOOSEModelTesterWorkspace"; + 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"; + // Debug information + System.out.println("MOOSE Test Data File: " + filePath); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject(projectName); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as + // ${workspace_loc}/MOOSEModelTesterWorkspace + defaultProjectLocation = (new File(userDir + separator + + projectName)).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription(projectName); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + + // Create the File handle and input stream for the Bison 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); + } + + 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) { + // Catch exception for creating the project + e.printStackTrace(); + fail(); + } catch (FileNotFoundException e) { + // Catch exception for failing to load the file + e.printStackTrace(); + fail(); + } + + // Set the global project reference. + projectSpace = project; + + // Set up an IO service and add a reader + launcher = new MOOSELauncher(projectSpace); + service = new IOService(); + service.addReader(new MOOSEFileHandler()); + launcher.setIOService(service); + + return; + } + + @Test + public void checkDynamicFileGeneration() { + + // Local Declarations + DataComponent fileDataComp = + (DataComponent) launcher.getForm().getComponent(1); + assertTrue(fileDataComp + .retrieveEntry("Input File").setValue("input_coarse10.i")); + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + assertEquals(4, fileDataComp.retrieveAllEntries().size()); + + // Now change the file name + assertTrue(fileDataComp + .retrieveEntry("Input File").setValue("input_coarse10_filetest.i")); + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + assertEquals(3, fileDataComp.retrieveAllEntries().size()); + } + + @Test + public void checkCustomAppEntry() { + + // Local declarations + DataComponent execDataComp = + (DataComponent) launcher.getForm().getComponent(5); + final String customExecName = "Custom executable name"; + Entry standardExecEntry = execDataComp.retrieveEntry("Executable"); + Entry customExecEntry = execDataComp.retrieveEntry(customExecName); + + // Verify the DataComponent that holds the executable Entries + assertEquals(execDataComp.retrieveAllEntries().size(), 2); + assertNotNull(standardExecEntry); + assertNotNull(customExecEntry); + + // Verify the standard Entry contains an option for a custom app + assertTrue(standardExecEntry.getAllowedValues().contains(customExecName)); + + // Verify the custom app Entry's type + assertEquals(customExecEntry.getValueType(), AllowedValueType.Undefined); + + return; + } + + /** + * Closes the MOOSE tester workspace created in the BeforeClass method. + */ + @AfterClass + public static void afterTests() { + + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + try { + // Close and delete the fake workspace created + projectSpace.close(null); + workspaceRoot.delete(true, true, null); + + // Nullify the IO service + service = null; + + } catch (CoreException e) { + e.printStackTrace(); + } + + return; + } + +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelBuilderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelBuilderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..68182300fb7f78d214ec8f0dcdc70a8c6acabc82 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelBuilderTester.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.nuclear; + +import static org.junit.Assert.*; + +import org.eclipse.ice.item.Item; +import org.eclipse.ice.item.ItemType; +import org.eclipse.ice.item.nuclear.MOOSEModel; +import org.eclipse.ice.item.nuclear.MOOSEModelBuilder; +import org.junit.Test; + +/** + *

+ * This class is responsible for testing the MOOSEModelBuilder. + *

+ * + * @author Jay Jay Billings + */ +public class MOOSEModelBuilderTester { + /** + *

+ * This operation insures that the builder can properly construct the + * MOOSEModel. + *

+ * + */ + @Test + public void checkItemBuild() { + + MOOSEModelBuilder builder = new MOOSEModelBuilder(); + assertEquals("MOOSE Model Builder", MOOSEModelBuilder.name); + assertEquals("MOOSE Model Builder", builder.getItemName()); + assertEquals(ItemType.Model, MOOSEModelBuilder.type); + assertEquals(ItemType.Model, builder.getItemType()); + Item model = builder.build(null); + assertTrue(model instanceof MOOSEModel); + + return; + } +} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java new file mode 100644 index 0000000000000000000000000000000000000000..8c633278fa3660d360181791b00e7d10f7e61c50 --- /dev/null +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java @@ -0,0 +1,401 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014- UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.item.test.nuclear; + +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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.net.URI; +import java.util.ArrayList; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.ice.datastructures.ICEObject.Component; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.form.ResourceComponent; +import org.eclipse.ice.datastructures.form.TreeComposite; +import org.eclipse.ice.io.serializable.IOService; +import org.eclipse.ice.item.nuclear.MOOSEModel; +import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This class tests the MOOSEModel Item to make sure that it can correctly + * create its Form and process a modified Form. + * + * @author Jay Jay Billings + */ +public class MOOSEModelTester { + + /** + * The project space used to create the workspace for the tests. + */ + private static IProject projectSpace; + + /** + * The IO Service used to read/write via MOOSEFileHandler. + */ + private static IOService service; + + /** + * This operation sets up the workspace. It copies the necessary MOOSE data + * files into ${workspace}/MOOSE. + */ + @BeforeClass + public static void beforeTests() { + + // Local Declarations + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + URI defaultProjectLocation = null; + IProject project = null; + String projectName = "MOOSEModelTesterWorkspace"; + 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"; + + // Debug information + System.out.println("MOOSE Test Data File: " + filePath); + + // Setup the project + try { + // Get the project handle + project = workspaceRoot.getProject(projectName); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as + // ${workspace_loc}/MOOSEModelTesterWorkspace + defaultProjectLocation = (new File(userDir + separator + + projectName)).toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription(projectName); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + + // Create the File handle and input stream for the Bison 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); + } + + // Create the File handle and input stream for the Bison 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); + } + + // Refresh the workspace + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // Catch exception for creating the project + e.printStackTrace(); + fail(); + } catch (FileNotFoundException e) { + // Catch exception for failing to load the file + e.printStackTrace(); + fail(); + } + + // Set the global project reference. + projectSpace = project; + + // Set up an IO service and add a reader and writer + service = new IOService(); + service.addWriter(new MOOSEFileHandler()); + service.addReader(new MOOSEFileHandler()); + + return; + } + + /** + * This operation checks the MOOSEModel and makes sure that it can properly + * construct its Form. + */ + @Test + public void checkConstruction() { + + // Create a MOOSEModel to test + MOOSEModel model = setupMOOSEItem(); + + // Check the form + Form form = model.getForm(); + assertNotNull(form); + assertEquals(3, form.getComponents().size()); + + // Check the data component + assertTrue(form.getComponent(MOOSEModel.fileDataComponentId) instanceof DataComponent); + + // Check the MOOSE app entry + Entry mooseAppEntry = ((DataComponent) form + .getComponent(MOOSEModel.fileDataComponentId)) + .retrieveEntry("MOOSE-Based Application"); + assertNotNull(mooseAppEntry); + assertEquals(1, mooseAppEntry.getId()); + assertEquals("None", mooseAppEntry.getDefaultValue()); + assertEquals(mooseAppEntry.getDefaultValue(), mooseAppEntry.getValue()); + + // Check the output file Entry + Entry outputFileEntry = ((DataComponent) form + .getComponent(MOOSEModel.fileDataComponentId)) + .retrieveEntry("Output File Name"); + assertNotNull(outputFileEntry); + assertEquals(2, outputFileEntry.getId()); + assertEquals("mooseModel.i", outputFileEntry.getValue()); + + // Check the TreeComposite + assertTrue(form.getComponent(MOOSEModel.mooseTreeCompositeId) instanceof TreeComposite); + + // Check the ResourceComponent + assertTrue(form.getComponent(MOOSEModel.resourceComponentId) instanceof ResourceComponent); + + return; + } + + /** + * This operation checks the MOOSEModel to make sure that it can correctly + * process its Form and generate a MOOSE input file. + */ + @Test + public void checkProcessing() { + + // Local Declarations + String testFilename = "bison_test_file.inp"; + + // Create a MOOSEModel to test + MOOSEModel model = setupMOOSEItem(); + + // Set the IOService on the model so we can write out + model.setIOService(service); + + // Check the form + Form form = model.getForm(); + assertNotNull(form); + + // Check the action list + assertEquals(2, form.getActionList().size()); + assertTrue(form.getActionList().contains("Write MOOSE File")); + + // Change the output file name to make sure that it is possible + Entry outputFileEntry = ((DataComponent) form.getComponent(1)) + .retrieveEntry("Output File Name"); + outputFileEntry.setValue(testFilename); + + // Resubmit the form + assertEquals(FormStatus.ReadyToProcess, model.submitForm(form)); + + // Direct the model to write the output file + assertEquals(FormStatus.Processed, model.process("Write MOOSE File")); + + // Check that the file exists + assertTrue(projectSpace.getFile(testFilename).exists()); + + return; + } + + /** + * This operation is responsible for ensuring that the MOOSEModel can load + * input. This operation checks this by passing it an input file for Bison. + */ + @Test + public void checkLoadingInput() { + + // Local Declarations + int numMooseBlocks = 20; + + // Create a MOOSE Item + MOOSEModel mooseItem = setupMOOSEItem(); + + // Set the IO service on the item so we can read/load data in + mooseItem.setIOService(service); + + // Load the input + mooseItem.loadInput("input_coarse10.i"); + + // Pull the Form + Form form = mooseItem.getForm(); + + // Get the TreeComposite to search it for known blocks and parameters + TreeComposite mooseTree = (TreeComposite) form + .getComponent(MOOSEModel.mooseTreeCompositeId); + + // Get its children + ArrayList subMooseTrees = new ArrayList(); + int loopSize = mooseTree.getNumberOfChildren(); + for (int i = 0; i < loopSize; i++) { + subMooseTrees.add(mooseTree.getChildAtIndex(i)); + } + + // Make sure we have the correct number of sub trees + assertEquals(numMooseBlocks, subMooseTrees.size()); + + // Get the names of the blocks + ArrayList blockNames = new ArrayList(); + loopSize = subMooseTrees.size(); + int outputsBlockIndex = 0; + for (int i = 0; i < loopSize; i++) { + // System.out.println("Blocknames: " + + // subMooseTrees.get(i).getName()); + blockNames.add(subMooseTrees.get(i).getName()); + + // Determine the index of the "Outputs" block (used in the next set + // of tests) + if ("Outputs".equals(subMooseTrees.get(i).getName())) { + outputsBlockIndex = i; + } + } + + // 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")); + assertTrue(blockNames.contains("Functions")); + assertTrue(blockNames.contains("SolidMechanics")); + assertTrue(blockNames.contains("Kernels")); + assertTrue(blockNames.contains("Burnup")); + assertTrue(blockNames.contains("AuxKernels")); + assertTrue(blockNames.contains("AuxBCs")); + assertTrue(blockNames.contains("Contact")); + assertTrue(blockNames.contains("ThermalContact")); + assertTrue(blockNames.contains("BCs")); + assertTrue(blockNames.contains("CoolantChannel")); + assertTrue(blockNames.contains("Materials")); + assertTrue(blockNames.contains("Dampers")); + assertTrue(blockNames.contains("Executioner")); + assertTrue(blockNames.contains("Postprocessors")); + assertTrue(blockNames.contains("Outputs")); + + // Get the "Outputs" block and its data node + TreeComposite outputsTree = (TreeComposite) subMooseTrees + .get(outputsBlockIndex); + DataComponent dataNode = (DataComponent) outputsTree + .getActiveDataNode(); + assertNotNull(dataNode); + + // Get the parameters off the data node + ArrayList parameters = dataNode.retrieveAllEntries(); + assertNotNull(parameters); + assertEquals(3, parameters.size()); + // Check the first one + Entry param = parameters.get(0); + assertEquals("interval", param.getName()); + assertEquals("1", param.getValue()); + // Check the second one + param = parameters.get(1); + assertEquals("output_initial", param.getName()); + assertEquals("true", param.getValue()); + // Check the third one + param = parameters.get(2); + assertEquals("exodus", param.getName()); + assertEquals("true", param.getValue()); + + // Get the console block off the output block + TreeComposite consoleTree = outputsTree.getChildAtIndex(0); + assertNotNull(consoleTree); + assertEquals("console", consoleTree.getName()); + + // Get the parameters from the console block + dataNode = (DataComponent) consoleTree.getActiveDataNode(); + parameters = dataNode.retrieveAllEntries(); + assertNotNull(parameters); + assertEquals(4, parameters.size()); + // Check the first one + param = parameters.get(0); + assertEquals("type", param.getName()); + assertEquals("Console", param.getValue()); + // Check the second one + param = parameters.get(1); + assertEquals("perf_log", param.getName()); + assertEquals("true", param.getValue()); + // Check the third one + param = parameters.get(2); + assertEquals("linear_residuals", param.getName()); + assertEquals("true", param.getValue()); + // Check the fourth one + param = parameters.get(3); + assertEquals("max_rows", param.getName()); + assertEquals("25", param.getValue()); + + return; + } + + /** + * This operation configures a MOOSEModel. It is used by both test + * operations. + * + * @return A newly instantiated MOOSEModel. + */ + private MOOSEModel setupMOOSEItem() { + + // Local Declarations + MOOSEModel model = new MOOSEModel(projectSpace); + + return model; + } + + /** + * Closes the MOOSE tester workspace created in the BeforeClass method. + */ + @AfterClass + public static void afterTests() { + try { + // Close and delete the fake workspace created + projectSpace.close(null); + + // Nullify the IO service + service = null; + } catch (CoreException e) { + e.printStackTrace(); + } + + return; + } + +} diff --git a/org.eclipse.ice.item.test/taggedTestFile.txt b/org.eclipse.ice.item.test/taggedTestFile.txt new file mode 100644 index 0000000000000000000000000000000000000000..d790166f280a756ce129cc625f3fe15c91cd893b --- /dev/null +++ b/org.eclipse.ice.item.test/taggedTestFile.txt @@ -0,0 +1,4 @@ +Scotty=chief engineer +Kirk=captain +Bones=chief medical officer +Spock=first officer diff --git a/repository/org.eclipse.ice.repository/ice.product.launch b/repository/org.eclipse.ice.repository/ice.product.launch index 318584a3cab67644e9bbc1f9ae1c3e2f250e7621..e012ff9c5e42a7fe247b843dda550455e529962b 100644 --- a/repository/org.eclipse.ice.repository/ice.product.launch +++ b/repository/org.eclipse.ice.repository/ice.product.launch @@ -1,37 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/mesh/MeshAppState.java b/src/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/mesh/MeshAppState.java index 0f8192084d161d6a147ee0dc1555bb91dff56829..49adefeb34cbe240aff79c380bc1d67ccfc4faaf 100644 --- a/src/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/mesh/MeshAppState.java +++ b/src/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/mesh/MeshAppState.java @@ -1388,7 +1388,7 @@ public class MeshAppState extends ViewAppState implements vSize = vertexSize; vertexSize = (distance < 10f ? 0.0159f * distance + 0.0413f : 0.2f); - if (vSize != vertexSize) { + if (Math.abs(vSize - vertexSize) > 0.001f) { updateVertices = true; vSize = vertexSize; } @@ -1398,7 +1398,7 @@ public class MeshAppState extends ViewAppState implements // changed. eSize = edgeSize; edgeSize = (distance < 10f ? 0.1f * distance + 4f : 5f); - if (eSize != edgeSize) { + if (Math.abs(eSize - edgeSize) > 0.001f) { updateEdges = true; eSize = edgeSize; } diff --git a/src/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java b/src/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java index 650e8c40598e88bbe85bf9fe2cf74d3958001aa3..9255319d0095bc1662a12d06190d97f20dd4e417 100644 --- a/src/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java +++ b/src/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java @@ -66,7 +66,7 @@ public class ToolItemMenuListener implements Listener { // event.detail == SWT.ARROW means the arrow has been clicked. // event.detail == SWT.NONE means the button has been clicked. - if (event.detail == SWT.ARROW | event.detail == SWT.NONE) { + if (event.detail == SWT.ARROW || event.detail == SWT.NONE) { Rectangle r = toolItem.getBounds(); Point p = new Point(r.x, r.y + r.height); p = toolItem.getParent().toDisplay(p.x, p.y); diff --git a/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/CoreConnectDialog.java b/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/CoreConnectDialog.java index d4efa292eb2bb0ab38c51d90750db09f14ef4c33..ac0f30263d6a44d96e357288abfe40a98ec02cb5 100644 --- a/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/CoreConnectDialog.java +++ b/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/CoreConnectDialog.java @@ -68,7 +68,7 @@ public class CoreConnectDialog extends Dialog { portLabel.setText("Port: "); // Create a new text box to input port - portField = new Text(comp, SWT.SINGLE | SWT.SINGLE); + portField = new Text(comp, SWT.SINGLE); data = new GridData(GridData.FILL_HORIZONTAL); portField.setLayoutData(data); diff --git a/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/NewItemWizard.java b/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/NewItemWizard.java index aa93750e6e00a787b63ceb3fe4f45012d0f3a54d..2ecbc9b52e2e5ea1c0e8bc585ad60bb2e6ae56f0 100644 --- a/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/NewItemWizard.java +++ b/src/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/NewItemWizard.java @@ -111,7 +111,7 @@ public class NewItemWizard extends Wizard implements INewWizard { String selectedItem = page.getSelectedItem(); // Direct the client to create a new Item if a selection was made - if (selectedItem != null && selectedItem != null) { + if (selectedItem != null) { finished = client.createItem(selectedItem) > 0; } diff --git a/src/org.eclipse.ice.materials/data/userMatDB.xml b/src/org.eclipse.ice.materials/data/userMatDB.xml index 8eb5c8ebbcc4394ef8098c8b4605d7f9c319acbe..24d4a84e1e0432a3c8df89e0bf36d6db7f8b4b9b 100644 --- a/src/org.eclipse.ice.materials/data/userMatDB.xml +++ b/src/org.eclipse.ice.materials/data/userMatDB.xml @@ -11760,4 +11760,4 @@ - + \ No newline at end of file diff --git a/src/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java b/src/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java index e66a3b4ebf370c0a9e1148bdd851fc592fe90600..49bdbf46a7ce9ad7e0bb347cab7bc02cf08476f7 100644 --- a/src/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java +++ b/src/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java @@ -169,10 +169,10 @@ public class NekWriter implements IComponentVisitor { hostname = InetAddress.getLocalHost().getHostName(); String iceHeader = String.format( - "C *** Nek5000 reafile generated by ICE ***\n" - + "C (Eclipse Integrated Computational Environment)\n" - + "C\n" + "C Created: %-30s\n" - + "C User: %-30s\n" + "C Hostname: %-30s", + "C *** Nek5000 reafile generated by ICE ***%n" + + "C (Eclipse Integrated Computational Environment)%n" + + "C%n" + "C Created: %-30s%n" + + "C User: %-30s%n" + "C Hostname: %-30s", date, user, hostname); // Write to the output stream @@ -204,10 +204,10 @@ public class NekWriter implements IComponentVisitor { String currLine; // Construct the header - String paramHeader = String.format(" ****** PARAMETERS *****\n" - + " %9s NEKTON VERSION\n" - + " %d DIMENSIONAL RUN\n" - + " %3d PARAMETERS FOLLOW\n", + String paramHeader = String.format(" ****** PARAMETERS *****%n" + + " %9s NEKTON VERSION%n" + + " %d DIMENSIONAL RUN%n" + + " %3d PARAMETERS FOLLOW%n", properties.getNekVersion(), properties.getNumDimensions(), numEntries); @@ -223,7 +223,7 @@ public class NekWriter implements IComponentVisitor { currName = currEntry.getName(); currDesc = currEntry.getDescription(); currValue = currEntry.getValue(); - currLine = String.format(" %-14s %s %s\n", currValue, + currLine = String.format(" %-14s %s %s%n", currValue, currName, currDesc); // Write to the output stream @@ -256,7 +256,7 @@ public class NekWriter implements IComponentVisitor { // Construct the header String passiveScalarsHeader = String.format( " %3s Lines of passive scalar data follows" - + "2 CONDUCT; 2RHOCP\n", numEntries); + + "2 CONDUCT; 2RHOCP%n", numEntries); // Write the passive scalars header byte[] byteArray = passiveScalarsHeader.getBytes(); @@ -268,7 +268,7 @@ public class NekWriter implements IComponentVisitor { // Define the current passive scalar line currEntry = passiveScalars.retrieveAllEntries().get(i); currValue = currEntry.getValue(); - currLine = String.format(" %-10s\n", currValue); + currLine = String.format(" %-10s%n", currValue); // Write to the output stream byteArray = currLine.getBytes(); @@ -301,7 +301,7 @@ public class NekWriter implements IComponentVisitor { // Construct the header String switchesHeader = String.format( - " %3s LOGICAL SWITCHES FOLLOW\n", numEntries); + " %3s LOGICAL SWITCHES FOLLOW%n", numEntries); // Write the logical switches header byte[] byteArray = switchesHeader.getBytes(); @@ -318,7 +318,7 @@ public class NekWriter implements IComponentVisitor { // Construct the current line if (currName.contains("IFNAV") && currName.contains("IFADVC")) { - currLine = String.format(" %s IFNAV & IFADVC %s\n", // This + currLine = String.format(" %s IFNAV & IFADVC %s%n", // This // entry's // name // has @@ -329,10 +329,10 @@ public class NekWriter implements IComponentVisitor { // just write the } // name out here else if (currName.contains("IFTMSH")) { - currLine = String.format(" %s %s %s\n", currValue, currName, + currLine = String.format(" %s %s %s%n", currValue, currName, currDesc); } else { - currLine = String.format(" %s %s\n", currValue, currName); + currLine = String.format(" %s %s%n", currValue, currName); } // Write to the output stream byteArray = currLine.getBytes(); @@ -368,7 +368,7 @@ public class NekWriter implements IComponentVisitor { currEntry = preNekAxes.retrieveAllEntries().get(i); currValue = currEntry.getValue(); currName = currEntry.getName(); - currLine = String.format(" %s %s\n", currValue, currName); + currLine = String.format(" %s %s%n", currValue, currName); // Write to the output stream byteArray = currLine.getBytes(); @@ -423,7 +423,7 @@ public class NekWriter implements IComponentVisitor { currQuad = (Quad) mesh.getPolygons().get(i); currValue = String.format(" ELEMENT%6s [ %4s]" // FORMAT: // 18X,I6,4X,I3,A1,11x,i5 - + " GROUP %5s\n", (i + 1), currQuad + + " GROUP %5s%n", (i + 1), currQuad .getPolygonProperties().getMaterialId(), currQuad .getPolygonProperties().getGroupNum()); @@ -467,7 +467,7 @@ public class NekWriter implements IComponentVisitor { // Construct the proper string format currValue = String.format( - " %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G\n", + " %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G%n", currBC.getType().id, (i + 1), (j + 1), currBCValues.get(0), currBCValues.get(1), currBCValues.get(2), currBCValues.get(3), @@ -490,7 +490,7 @@ public class NekWriter implements IComponentVisitor { // Construct the proper string format currValue = String.format( - " %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G\n", + " %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G%n", currBC.getType().id, (i + 1), (j + 1), currBCValues.get(0), currBCValues.get(1), currBCValues.get(2), currBCValues.get(3), @@ -524,7 +524,7 @@ public class NekWriter implements IComponentVisitor { // Construct the proper string format currValue = String - .format(" %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G\n", + .format(" %-3s%3d%3d%14.7G%14.7G%14.7G%14.7G%14.7G%n", currBC.getType().id, (i + 1), (j + 1), currBCValues.get(0), currBCValues.get(1), @@ -542,8 +542,8 @@ public class NekWriter implements IComponentVisitor { } // Write the coordinates to the buffer - currValue = String.format(" %9.6G %9.6G %9.6G %9.6G\n" - + " %9.6G %9.6G %9.6G %9.6G\n", xCoords.get(0), + currValue = String.format(" %9.6G %9.6G %9.6G %9.6G%n" + + " %9.6G %9.6G %9.6G %9.6G%n", xCoords.get(0), xCoords.get(1), xCoords.get(2), xCoords.get(3), yCoords.get(0), yCoords.get(1), yCoords.get(2), yCoords.get(3)); @@ -565,8 +565,8 @@ public class NekWriter implements IComponentVisitor { // Construct the header String meshHeader = String - .format(" *** MESH DATA ***\n" - + " %3d %3d %3d NEL,NDIM,NELV\n", + .format(" *** MESH DATA ***%n" + + " %3d %3d %3d NEL,NDIM,NELV%n", properties.getNumThermalElements(), properties.getNumDimensions(), properties.getNumFluidElements()); @@ -605,9 +605,9 @@ public class NekWriter implements IComponentVisitor { // Construct the header String curvedSidesHeader = String.format( - " ***** CURVED SIDE DATA *****\n" + " ***** CURVED SIDE DATA *****%n" + " %3s Curved sides follow " - + "IEDGE,IEL,CURVE(I),I=1,5, CCURVE\n", numEntries); + + "IEDGE,IEL,CURVE(I),I=1,5, CCURVE%n", numEntries); // Write the curved sides header byte[] byteArray = curvedSidesHeader.getBytes(); @@ -642,7 +642,7 @@ public class NekWriter implements IComponentVisitor { ArrayList> passiveScalarBCs) throws IOException { // Construct the header - String boundaryConditionHeader = " ***** BOUNDARY CONDITIONS *****\n"; + String boundaryConditionHeader = " ***** BOUNDARY CONDITIONS *****%n"; // Write the boundary conditions header byte[] byteArray = boundaryConditionHeader.getBytes(); @@ -651,7 +651,7 @@ public class NekWriter implements IComponentVisitor { // Check that there are fluid boundary conditions if (!fluidBCs.isEmpty()) { // Write the fluid boundary conditions header - String fluidHeader = " ***** FLUID BOUNDARY CONDITIONS *****\n"; + String fluidHeader = " ***** FLUID BOUNDARY CONDITIONS *****%n"; byteArray = fluidHeader.getBytes(); stream.write(byteArray); @@ -661,7 +661,7 @@ public class NekWriter implements IComponentVisitor { stream.write(byteArray); } } else { - String noFluidHeader = " ***** NO FLUID BOUNDARY CONDITIONS *****\n"; + String noFluidHeader = " ***** NO FLUID BOUNDARY CONDITIONS *****%n"; byteArray = noFluidHeader.getBytes(); stream.write(byteArray); } @@ -669,7 +669,7 @@ public class NekWriter implements IComponentVisitor { // Check that there are thermal boundary conditions if (!thermalBCs.isEmpty()) { // Write the thermal boundary conditions header - String thermalHeader = " ***** THERMAL BOUNDARY CONDITIONS *****\n"; + String thermalHeader = " ***** THERMAL BOUNDARY CONDITIONS *****%n"; byteArray = thermalHeader.getBytes(); stream.write(byteArray); @@ -679,7 +679,7 @@ public class NekWriter implements IComponentVisitor { stream.write(byteArray); } } else { - String noThermalHeader = " ***** NO THERMAL BOUNDARY CONDITIONS *****\n"; + String noThermalHeader = " ***** NO THERMAL BOUNDARY CONDITIONS *****%n"; byteArray = noThermalHeader.getBytes(); stream.write(byteArray); } @@ -697,7 +697,7 @@ public class NekWriter implements IComponentVisitor { // Write the passive scalar boundary conditions header String passiveScalarHeader = String - .format(" ***** PASSIVE SCALAR %3s BOUNDARY CONDITIONS *****\n", + .format(" ***** PASSIVE SCALAR %3s BOUNDARY CONDITIONS *****%n", (i + 1)); byteArray = passiveScalarHeader.getBytes(); stream.write(byteArray); @@ -736,7 +736,7 @@ public class NekWriter implements IComponentVisitor { // Construct the header String presolveRestartOptsHeader = String.format( - "%3s PRESOLVE/RESTART OPTIONS *****\n", numEntries); + "%3s PRESOLVE/RESTART OPTIONS *****%n", numEntries); // Write the presolve/restart options header byte[] byteArray = presolveRestartOptsHeader.getBytes(); @@ -746,7 +746,7 @@ public class NekWriter implements IComponentVisitor { // Define the current pre-solve/restart option currEntry = presolveRestartOpts.retrieveAllEntries().get(i); - currValue = currEntry.getValue() + "\n"; + currValue = currEntry.getValue() + "%n"; // Write to the output stream byteArray = currValue.getBytes(); @@ -776,7 +776,7 @@ public class NekWriter implements IComponentVisitor { // Construct the header String initialConditionsHeader = String.format( - "%3s INITIAL CONDITIONS *****\n", numEntries); + "%3s INITIAL CONDITIONS *****%n", numEntries); // Write the initial conditions header byte[] byteArray = initialConditionsHeader.getBytes(); @@ -786,7 +786,7 @@ public class NekWriter implements IComponentVisitor { // Define the current initial condition currEntry = initialConditions.retrieveAllEntries().get(i); - currValue = currEntry.getValue() + "\n"; + currValue = currEntry.getValue() + "%n"; // Write to the output stream byteArray = currValue.getBytes(); @@ -817,8 +817,8 @@ public class NekWriter implements IComponentVisitor { // Construct the header String driveForceDataHeader = String - .format(" ***** DRIVE FORCE DATA ***** BODY FORCE, FLOW, Q\n" - + " %3s Lines of Drive force data follow\n", + .format(" ***** DRIVE FORCE DATA ***** BODY FORCE, FLOW, Q%n" + + " %3s Lines of Drive force data follow%n", numEntries); // Write the drive force data header @@ -829,7 +829,7 @@ public class NekWriter implements IComponentVisitor { // Define the current drive force datum currEntry = driveForceData.retrieveAllEntries().get(i); - currValue = currEntry.getValue() + "\n"; + currValue = currEntry.getValue() + "%n"; // Write to the output stream byteArray = currValue.getBytes(); @@ -859,8 +859,8 @@ public class NekWriter implements IComponentVisitor { // Construct the header String varPropertyDataHeader = String.format( - " ***** Variable Property Data ***** Overrrides Parameter data.\n" - + "%3s Lines follow.\n", numEntries); + " ***** Variable Property Data ***** Overrrides Parameter data.%n" + + "%3s Lines follow.%n", numEntries); // Write the variable property data header byte[] byteArray = varPropertyDataHeader.getBytes(); @@ -870,7 +870,7 @@ public class NekWriter implements IComponentVisitor { // Define the current variable property datum currEntry = varPropertyData.retrieveAllEntries().get(i); - currValue = currEntry.getValue() + "\n"; + currValue = currEntry.getValue() + "%n"; // Write to the output stream byteArray = currValue.getBytes(); @@ -901,8 +901,8 @@ public class NekWriter implements IComponentVisitor { // Construct the header String historyIntegralDataHeader = String.format( - " ***** HISTORY AND INTEGRAL DATA *****\n" - + " %3s POINTS. Hcode, I,J,H,IEL\n", + " ***** HISTORY AND INTEGRAL DATA *****%n" + + " %3s POINTS. Hcode, I,J,H,IEL%n", numEntries); // Write the history and integral data header @@ -913,7 +913,7 @@ public class NekWriter implements IComponentVisitor { // Define the current history and integral datum currEntry = historyIntegralData.retrieveAllEntries().get(i); - currValue = currEntry.getValue() + "\n"; + currValue = currEntry.getValue() + "%n"; // Write to the output stream byteArray = currValue.getBytes(); @@ -946,8 +946,8 @@ public class NekWriter implements IComponentVisitor { // Construct the header String outputFieldSpecHeader = String.format( - " ***** OUTPUT FIELD SPECIFICATION *****\n" - + " %3s SPECIFICATIONS FOLLOW\n", numEntries); + " ***** OUTPUT FIELD SPECIFICATION *****%n" + + " %3s SPECIFICATIONS FOLLOW%n", numEntries); // Write the output field specification header byte[] byteArray = outputFieldSpecHeader.getBytes(); @@ -960,7 +960,7 @@ public class NekWriter implements IComponentVisitor { currName = currEntry.getName(); currValue = ("YES".equals(currEntry.getValue()) ? "T" : ("NO" .equals(currEntry.getValue()) ? "F" : currEntry.getValue())); - currLine = String.format(" %s %s\n", currValue, currName); + currLine = String.format(" %s %s%n", currValue, currName); // Write to the output stream byteArray = currLine.getBytes(); @@ -992,7 +992,7 @@ public class NekWriter implements IComponentVisitor { String currLine; // Construct the header - String objectSpecHeader = " ***** OBJECT SPECIFICATION *****\n"; + String objectSpecHeader = " ***** OBJECT SPECIFICATION *****%n"; // Write the object specification header byte[] byteArray = objectSpecHeader.getBytes(); @@ -1004,7 +1004,7 @@ public class NekWriter implements IComponentVisitor { currEntry = objectSpec.retrieveAllEntries().get(i); currValue = currEntry.getValue(); currName = currEntry.getName(); - currLine = String.format(" %3s %-7s Objects\n", currValue, + currLine = String.format(" %3s %-7s Objects%n", currValue, currName); // Write to the output stream diff --git a/src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItPlotRender.java b/src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItPlotRender.java index b2db0a03c16572e9592cc3fb8257fe9655378582..f4ecf36738ebeeeb1c047af1cca47469fed31299 100644 --- a/src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItPlotRender.java +++ b/src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItPlotRender.java @@ -1,431 +1,431 @@ -/******************************************************************************* - * Copyright (c) 2015 UT-Battelle, LLC. - * 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: - * Jordan Deyton (UT-Battelle, LLC.) - initial API and implementation and/or initial documentation - * - *******************************************************************************/ -package org.eclipse.ice.viz.service.visit; - -import gov.lbnl.visit.swt.VisItSwtConnection; -import gov.lbnl.visit.swt.VisItSwtWidget; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - -import org.eclipse.ice.client.common.ActionTree; -import org.eclipse.ice.viz.service.connections.ConnectionPlotRender; -import org.eclipse.ice.viz.service.connections.IConnectionAdapter; -import org.eclipse.ice.viz.service.visit.widgets.TimeSliderComposite; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.events.MenuListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; - -import visit.java.client.ViewerMethods; - -public class VisItPlotRender extends ConnectionPlotRender { - - /** - * A reference to the associated {@code IPlot} implementation. This may be - * required for specific implementation details, e.g., for determining the - * {@link #representation}. - */ - private final VisItPlot plot; - - // TODO This could be moved to the parent class, as the connection adapter - // may prove useful. - private final IConnectionAdapter adapter; - - /** - * - * The current plot representation. This must be pulled from the list of - * representations from {@link VisItPlot#getRepresentations(String)}. - */ - private String representation; - - /** - * The current plot category rendered in the associated rendering widget. - *

- * Note: This value should only be updated when the corresponding UI - * piece is updated. - *

- */ - private String plotCategory; - /** - * The current plot representation rendered in the associated rendering - * widget. - *

- * Note: This value should only be updated when the corresponding UI - * piece is updated. - *

- */ - private String plotRepresentation; - /** - * The current plot type rendered in the associated rendering widget. - *

- * Note: This value should only be updated when the corresponding UI - * piece is updated. - *

- */ - private String plotType; - - /** - * The widget used to adjust the current timestep. - */ - private TimeSliderComposite timeSlider; - - /** - * The currently timestep rendered by the VisIt widget. - */ - private int renderedTimestep = 0; - /** - * The current timestep as reported by the {@link #timeSlider} on the UI - * thread. - */ - private final AtomicInteger widgetTimestep = new AtomicInteger(); - /** - * An ExecutorService for launching worker threads. Only one thread is - * processed at a time in the order in which they are added. - */ - private final ExecutorService executorService = Executors - .newSingleThreadExecutor(); - - /** - * The plot {@code Composite} that renders the files through the VisIt - * connection. - */ - private VisItSwtWidget canvas; - - /** - * An ActionTree for populating the context menu with a list of allowed - * representations. This should be updated (as necessary) when the context - * menu is opened. - */ - private final ActionTree repTree; - - /** - * The default constructor. - * - * @param parent - * The parent Composite that contains the plot render. - * @param plot - * The rendered ConnectionPlot. This cannot be changed. - */ - public VisItPlotRender(Composite parent, VisItPlot plot) { - super(parent, plot); - - // Store the adapter so that we can access its connection later. - adapter = plot.getVisItConnectionAdapter(); - - // Set a reference to the VisItPlot. We specifically need this - // implementation to access the plot representations. - this.plot = plot; - - // Create the ActionTree that will contain the representations for the - // current plot category. - repTree = new ActionTree("Representation"); - - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# - * getPreferenceNodeID() - */ - @Override - protected String getPreferenceNodeID() { - return "org.eclipse.ice.viz.service.paraview.preferences"; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# - * createPlotComposite(org.eclipse.swt.widgets.Composite, int, - * java.lang.Object) - */ - @Override - protected Composite createPlotComposite(Composite parent, int style, - final VisItSwtConnection connection) throws Exception { - - // Create a new window on the VisIt server if one does not already - // exist. We will need the corresponding connection and a window ID. If - // the window ID is -1, a new one is created. - - Composite container = new Composite(parent, style); - container.setBackground(parent.getBackground()); - container.setLayout(new GridLayout(1, false)); - - // Create the canvas. - canvas = new VisItSwtWidget(container, SWT.DOUBLE_BUFFERED); - canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - canvas.setBackground(parent.getBackground()); - int windowWidth = Integer.parseInt(adapter - .getConnectionProperty("windowWidth")); - int windowHeight = Integer.parseInt(adapter - .getConnectionProperty("windowHeight")); - - // Establish the canvas' connection to the VisIt server. This may throw - // an exception. - int windowId = plot.getVisItConnectionAdapter().getNextWindowId(); - canvas.setVisItSwtConnection(connection, windowId, windowWidth, - windowHeight); - - // Create a mouse manager to handle mouse events inside the - // canvas. - new VisItMouseManager(canvas); - - // Set up the canvas' context Menu. - MenuManager menuManager = new MenuManager(); - // If the parent context Menu is not available, create a new one. - Menu menu = parent.getMenu(); - if (menu == null) { - menu = menuManager.createContextMenu(canvas); - // TODO Populate the "Set Plot Type" menu with the plot categories - // and types in case it's not already available. - } - - // When the Menu is about to be shown, add the representation options to - // it. - menu.addMenuListener(new MenuListener() { - @Override - public void menuHidden(MenuEvent e) { - // Nothing to do. - } - - @Override - public void menuShown(MenuEvent e) { - repTree.getContributionItem().fill((Menu) e.widget, -1); - } - }); - - canvas.setMenu(menu); - - // Add a time slider widget. - timeSlider = new TimeSliderComposite(container, SWT.NONE); - timeSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - timeSlider.setBackground(parent.getBackground()); - // Add a listener to trigger an update to the current timestep. - timeSlider.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - // Record the current timestep from the TimeSliderComposite. - widgetTimestep.set(timeSlider.getTimestep()); - - // Launch a worker thread to update the timestep for the VisIt - // widget. - executorService.submit(new Runnable() { - @Override - public void run() { - - // FIXME We need a way to move to a specific timestep - // rather than cycling through them. - - ViewerMethods methods = connection.getViewerMethods(); - - // Send next or previous timestep requests to the VisIt - // widget until it matches the current timestep in the - // TimeSliderComposite. - int targetStep; - while (renderedTimestep != (targetStep = widgetTimestep - .get())) { - if (renderedTimestep < targetStep) { - methods.animationNextState(); - renderedTimestep++; - } else { - methods.animationPreviousState(); - renderedTimestep--; - } - } - return; - } - }); - return; - } - }); - - // TODO We need to figure out how to get the actual times from the VisIt - // client API. We are currently using the timestep indices. - // Get the available timesteps. - ViewerMethods widget = connection.getViewerMethods(); - int timestepCount = widget.timeSliderGetNStates(); - List times = new ArrayList(timestepCount); - for (double i = 0.0; i < timestepCount; i++) { - times.add(i); - } - timeSlider.setTimes(times); - - return container; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# - * updatePlotComposite(org.eclipse.swt.widgets.Composite, java.lang.Object) - */ - @Override - protected void updatePlotComposite(Composite plotComposite, - VisItSwtConnection connection) throws Exception { - - // Check the input arguments. The canvas should be the plot Composite. - if (plotComposite != canvas.getParent()) { - throw new Exception("VisItPlot error: " - + "The canvas was not created properly."); - } - - // Get the source path from the VisItPlot class. We can't, - // unfortunately, use the URI as specified. - String sourcePath = VisItPlot.getSourcePath(plot.getDataSource()); - - // See if the plot category and type have been updated since the last - // refresh. We should also make sure the current plot category and type - // are valid before we try to update them. - final String category = getPlotCategory(); - final String representation = getPlotRepresentation(); - final String type = getPlotType(); - // Check that the type is non-null and new. Then do the same for the - // representation and category. - boolean plotTypeChanged = (type != null && !type.equals(plotType)); - plotTypeChanged |= (representation != null && !representation - .equals(plotRepresentation)); - plotTypeChanged |= (category != null && !category.equals(plotCategory)); - // Now check the validity of each property. - if (plotTypeChanged && type != null) { - plotTypeChanged = false; - // Check that the category and type is valid. - String[] types = plot.getPlotTypes().get(category); - if (types != null) { - for (int i = 0; !plotTypeChanged && i < types.length; i++) { - if (type.equals(types[i])) { - plotTypeChanged = true; - } - } - } - // Check that the representation is valid. - List reps = plot.getRepresentations(category); - plotTypeChanged &= reps.contains(representation); - } else { - // If the type is null, then don't proceed. - plotTypeChanged = false; - } - - // Make sure the Canvas is activated. - canvas.activate(); - - // If the plot category or type changed (and they are both valid), - // update the reference to the currently drawn category and type and - // update the widget. - if (plotTypeChanged) { - - // Draw the specified plot on the Canvas. - ViewerMethods widget = canvas.getViewerMethods(); - - // Remove all existing plots. - widget.deleteActivePlots(); - - // FIXME How do we handle invalid paths? - widget.openDatabase(sourcePath); - widget.addPlot(representation, type); - widget.drawPlots(); - - // Rebuild the VisIt representation tree based on the current - // category (if the category actually changed). - if (!category.equals(plotCategory)) { - repTree.removeAll(); - for (final String rep : plot.getRepresentations(category)) { - repTree.add(new ActionTree(new Action(rep) { - @Override - public void run() { - setPlotRepresentation(rep); - refresh(); - } - })); - } - } - - // Change the record of the current plot category and type for this - // PlotRender. - plotCategory = category; - plotRepresentation = representation; - plotType = type; - } - - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.viz.service.PlotRender#clearCache() - */ - @Override - protected void clearCache() { - // Nothing to do yet. - } - - /** - * Overrides the default behavior to set the plot representation to its - * default value given the new category. - */ - @Override - public void setPlotCategory(String category) { - String oldCategory = getPlotCategory(); - - // Proceed with the normal process that sets the plot category. - super.setPlotCategory(category); - - // If the category changed, we will need to update the representation to - // the default representation for the new category, or null if the - // category has no valid representations. - if (oldCategory != category - && (oldCategory == null || !oldCategory.equals(category))) { - List reps = plot.getRepresentations(category); - setPlotRepresentation(reps.isEmpty() ? null : reps.get(0)); - } - - return; - } - - /** - * Sets the current plot representation. This is a "sub-category" that lies - * between the plot category and type as derived from the {@link VisItPlot}. - *

- * Note: A subsequent call to {@link #refresh()} will be necessary to - * sync the UI with this call's changes. - *

- * - * @param representation - * The new plot representation. - */ - private void setPlotRepresentation(String representation) { - this.representation = representation; - } - - /** - * Gets the current plot representation. This is a "sub-category" that lies - * between the plot category and type as derived from the {@link VisItPlot}. - * - * @return The current plot representation. - */ - private String getPlotRepresentation() { - return representation; - } -} +/******************************************************************************* + * Copyright (c) 2015 UT-Battelle, LLC. + * 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: + * Jordan Deyton (UT-Battelle, LLC.) - initial API and implementation and/or initial documentation + * + *******************************************************************************/ +package org.eclipse.ice.viz.service.visit; + +import gov.lbnl.visit.swt.VisItSwtConnection; +import gov.lbnl.visit.swt.VisItSwtWidget; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.ice.client.common.ActionTree; +import org.eclipse.ice.viz.service.connections.ConnectionPlotRender; +import org.eclipse.ice.viz.service.connections.IConnectionAdapter; +import org.eclipse.ice.viz.service.visit.widgets.TimeSliderComposite; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.events.MenuListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; + +import visit.java.client.ViewerMethods; + +public class VisItPlotRender extends ConnectionPlotRender { + + /** + * A reference to the associated {@code IPlot} implementation. This may be + * required for specific implementation details, e.g., for determining the + * {@link #representation}. + */ + private final VisItPlot plot; + + // TODO This could be moved to the parent class, as the connection adapter + // may prove useful. + private final IConnectionAdapter adapter; + + /** + * + * The current plot representation. This must be pulled from the list of + * representations from {@link VisItPlot#getRepresentations(String)}. + */ + private String representation; + + /** + * The current plot category rendered in the associated rendering widget. + *

+ * Note: This value should only be updated when the corresponding UI + * piece is updated. + *

+ */ + private String plotCategory; + /** + * The current plot representation rendered in the associated rendering + * widget. + *

+ * Note: This value should only be updated when the corresponding UI + * piece is updated. + *

+ */ + private String plotRepresentation; + /** + * The current plot type rendered in the associated rendering widget. + *

+ * Note: This value should only be updated when the corresponding UI + * piece is updated. + *

+ */ + private String plotType; + + /** + * The widget used to adjust the current timestep. + */ + private TimeSliderComposite timeSlider; + + /** + * The currently timestep rendered by the VisIt widget. + */ + private int renderedTimestep = 0; + /** + * The current timestep as reported by the {@link #timeSlider} on the UI + * thread. + */ + private final AtomicInteger widgetTimestep = new AtomicInteger(); + /** + * An ExecutorService for launching worker threads. Only one thread is + * processed at a time in the order in which they are added. + */ + private final ExecutorService executorService = Executors + .newSingleThreadExecutor(); + + /** + * The plot {@code Composite} that renders the files through the VisIt + * connection. + */ + private VisItSwtWidget canvas; + + /** + * An ActionTree for populating the context menu with a list of allowed + * representations. This should be updated (as necessary) when the context + * menu is opened. + */ + private final ActionTree repTree; + + /** + * The default constructor. + * + * @param parent + * The parent Composite that contains the plot render. + * @param plot + * The rendered ConnectionPlot. This cannot be changed. + */ + public VisItPlotRender(Composite parent, VisItPlot plot) { + super(parent, plot); + + // Store the adapter so that we can access its connection later. + adapter = plot.getVisItConnectionAdapter(); + + // Set a reference to the VisItPlot. We specifically need this + // implementation to access the plot representations. + this.plot = plot; + + // Create the ActionTree that will contain the representations for the + // current plot category. + repTree = new ActionTree("Representation"); + + return; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# + * getPreferenceNodeID() + */ + @Override + protected String getPreferenceNodeID() { + return "org.eclipse.ice.viz.service.paraview.preferences"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# + * createPlotComposite(org.eclipse.swt.widgets.Composite, int, + * java.lang.Object) + */ + @Override + protected Composite createPlotComposite(Composite parent, int style, + final VisItSwtConnection connection) throws Exception { + + // Create a new window on the VisIt server if one does not already + // exist. We will need the corresponding connection and a window ID. If + // the window ID is -1, a new one is created. + + Composite container = new Composite(parent, style); + container.setBackground(parent.getBackground()); + container.setLayout(new GridLayout(1, false)); + + // Create the canvas. + canvas = new VisItSwtWidget(container, SWT.DOUBLE_BUFFERED); + canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + canvas.setBackground(parent.getBackground()); + int windowWidth = Integer.parseInt(adapter + .getConnectionProperty("windowWidth")); + int windowHeight = Integer.parseInt(adapter + .getConnectionProperty("windowHeight")); + + // Establish the canvas' connection to the VisIt server. This may throw + // an exception. + int windowId = plot.getVisItConnectionAdapter().getNextWindowId(); + canvas.setVisItSwtConnection(connection, windowId, windowWidth, + windowHeight); + + // Create a mouse manager to handle mouse events inside the + // canvas. + new VisItMouseManager(canvas); + + // Set up the canvas' context Menu. + MenuManager menuManager = new MenuManager(); + // If the parent context Menu is not available, create a new one. + Menu menu = parent.getMenu(); + if (menu == null) { + menu = menuManager.createContextMenu(canvas); + // TODO Populate the "Set Plot Type" menu with the plot categories + // and types in case it's not already available. + } + + // When the Menu is about to be shown, add the representation options to + // it. + menu.addMenuListener(new MenuListener() { + @Override + public void menuHidden(MenuEvent e) { + // Nothing to do. + } + + @Override + public void menuShown(MenuEvent e) { + repTree.getContributionItem().fill((Menu) e.widget, -1); + } + }); + + canvas.setMenu(menu); + + // Add a time slider widget. + timeSlider = new TimeSliderComposite(container, SWT.NONE); + timeSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + timeSlider.setBackground(parent.getBackground()); + // Add a listener to trigger an update to the current timestep. + timeSlider.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // Record the current timestep from the TimeSliderComposite. + widgetTimestep.set(timeSlider.getTimestep()); + + // Launch a worker thread to update the timestep for the VisIt + // widget. + executorService.submit(new Runnable() { + @Override + public void run() { + + // FIXME We need a way to move to a specific timestep + // rather than cycling through them. + + ViewerMethods methods = connection.getViewerMethods(); + + // Send next or previous timestep requests to the VisIt + // widget until it matches the current timestep in the + // TimeSliderComposite. + int targetStep; + while (renderedTimestep != (targetStep = widgetTimestep + .get())) { + if (renderedTimestep < targetStep) { + methods.animationNextState(); + renderedTimestep++; + } else { + methods.animationPreviousState(); + renderedTimestep--; + } + } + return; + } + }); + return; + } + }); + + // TODO We need to figure out how to get the actual times from the VisIt + // client API. We are currently using the timestep indices. + // Get the available timesteps. + ViewerMethods widget = connection.getViewerMethods(); + int timestepCount = widget.timeSliderGetNStates(); + List times = new ArrayList(timestepCount); + for (double i = 0.0; i < timestepCount; i++) { + times.add(i); + } + timeSlider.setTimes(times); + + return container; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender# + * updatePlotComposite(org.eclipse.swt.widgets.Composite, java.lang.Object) + */ + @Override + protected void updatePlotComposite(Composite plotComposite, + VisItSwtConnection connection) throws Exception { + + // Check the input arguments. The canvas should be the plot Composite. + if (plotComposite != canvas.getParent()) { + throw new Exception("VisItPlot error: " + + "The canvas was not created properly."); + } + + // Get the source path from the VisItPlot class. We can't, + // unfortunately, use the URI as specified. + String sourcePath = VisItPlot.getSourcePath(plot.getDataSource()); + + // See if the plot category and type have been updated since the last + // refresh. We should also make sure the current plot category and type + // are valid before we try to update them. + final String category = getPlotCategory(); + final String representation = getPlotRepresentation(); + final String type = getPlotType(); + // Check that the type is non-null and new. Then do the same for the + // representation and category. + boolean plotTypeChanged = (type != null && !type.equals(plotType)); + plotTypeChanged |= (representation != null && !representation + .equals(plotRepresentation)); + plotTypeChanged |= (category != null && !category.equals(plotCategory)); + // Now check the validity of each property. + if (plotTypeChanged && type != null) { + plotTypeChanged = false; + // Check that the category and type is valid. + String[] types = plot.getPlotTypes().get(category); + if (types != null) { + for (int i = 0; !plotTypeChanged && i < types.length; i++) { + if (type.equals(types[i])) { + plotTypeChanged = true; + } + } + } + // Check that the representation is valid. + List reps = plot.getRepresentations(category); + plotTypeChanged &= reps.contains(representation); + } else { + // If the type is null, then don't proceed. + plotTypeChanged = false; + } + + // Make sure the Canvas is activated. + canvas.activate(); + + // If the plot category or type changed (and they are both valid), + // update the reference to the currently drawn category and type and + // update the widget. + if (plotTypeChanged) { + + // Draw the specified plot on the Canvas. + ViewerMethods widget = canvas.getViewerMethods(); + + // Remove all existing plots. + widget.deleteActivePlots(); + + // FIXME How do we handle invalid paths? + widget.openDatabase(sourcePath); + widget.addPlot(representation, type); + widget.drawPlots(); + + // Rebuild the VisIt representation tree based on the current + // category (if the category actually changed). + if (!category.equals(plotCategory)) { + repTree.removeAll(); + for (final String rep : plot.getRepresentations(category)) { + repTree.add(new ActionTree(new Action(rep) { + @Override + public void run() { + setPlotRepresentation(rep); + refresh(); + } + })); + } + } + + // Change the record of the current plot category and type for this + // PlotRender. + plotCategory = category; + plotRepresentation = representation; + plotType = type; + } + + return; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ice.viz.service.PlotRender#clearCache() + */ + @Override + protected void clearCache() { + // Nothing to do yet. + } + + /** + * Overrides the default behavior to set the plot representation to its + * default value given the new category. + */ + @Override + public void setPlotCategory(String category) { + String oldCategory = getPlotCategory(); + + // Proceed with the normal process that sets the plot category. + super.setPlotCategory(category); + + // If the category changed, we will need to update the representation to + // the default representation for the new category, or null if the + // category has no valid representations. + if (oldCategory != category + && (oldCategory == null || !oldCategory.equals(category))) { + List reps = plot.getRepresentations(category); + setPlotRepresentation(reps.isEmpty() ? null : reps.get(0)); + } + + return; + } + + /** + * Sets the current plot representation. This is a "sub-category" that lies + * between the plot category and type as derived from the {@link VisItPlot}. + *

+ * Note: A subsequent call to {@link #refresh()} will be necessary to + * sync the UI with this call's changes. + *

+ * + * @param representation + * The new plot representation. + */ + private void setPlotRepresentation(String representation) { + this.representation = representation; + } + + /** + * Gets the current plot representation. This is a "sub-category" that lies + * between the plot category and type as derived from the {@link VisItPlot}. + * + * @return The current plot representation. + */ + private String getPlotRepresentation() { + return representation; + } +} \ No newline at end of file diff --git a/src/org.eclipse.ice.viz.service/.classpath b/src/org.eclipse.ice.viz.service/.classpath index 098194ca4b7d8f45177f94e735506ae3a26b5c94..b1dabee38291b97f08cc3a18bee4e65b1e550530 100644 --- a/src/org.eclipse.ice.viz.service/.classpath +++ b/src/org.eclipse.ice.viz.service/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/src/org.eclipse.ice.viz.service/META-INF/MANIFEST.MF b/src/org.eclipse.ice.viz.service/META-INF/MANIFEST.MF index 018811b40a860457edadf765ff74870038dba812..c48bdfec2d72e89f08fa399c1f7e79754c1b32a9 100644 --- a/src/org.eclipse.ice.viz.service/META-INF/MANIFEST.MF +++ b/src/org.eclipse.ice.viz.service/META-INF/MANIFEST.MF @@ -5,10 +5,13 @@ Bundle-SymbolicName: org.eclipse.ice.viz.service;singleton:=true Bundle-Version: 2.0.0 Bundle-Vendor: Oak Ridge National Laboratory Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: org.eclipse.core.commands.common, +Import-Package: org.eclipse.core.commands, + org.eclipse.core.commands.common, org.eclipse.core.runtime;version="3.4.0", + org.eclipse.core.runtime.jobs, org.eclipse.core.runtime.preferences, org.eclipse.draw2d, + org.eclipse.e4.ui.workbench, org.eclipse.equinox.security.storage;version="1.0.0", org.eclipse.ice.analysistool, org.eclipse.ice.client.common, @@ -32,8 +35,10 @@ Import-Package: org.eclipse.core.commands.common, org.eclipse.swt.widgets, org.eclipse.ui, org.eclipse.ui.dialogs, + org.eclipse.ui.forms, org.eclipse.ui.forms.events, org.eclipse.ui.forms.widgets, + org.eclipse.ui.internal.registry, org.eclipse.ui.part, org.eclipse.ui.preferences, org.osgi.framework;version="1.7.0", @@ -41,7 +46,8 @@ Import-Package: org.eclipse.core.commands.common, Export-Package: org.eclipse.ice.viz.service, org.eclipse.ice.viz.service.connections, org.eclipse.ice.viz.service.csv, + org.eclipse.ice.viz.service.internal, org.eclipse.ice.viz.service.preferences -Service-Component: OSGI-INF/vizFactory.xml +Service-Component: OSGI-INF/vizFactory.xml, OSGI-INF/VizServiceFactoryHolder.xml Require-Bundle: org.eclipse.nebula.visualization.widgets;bundle-version="1.0.0", org.eclipse.nebula.visualization.xygraph;bundle-version="1.0.0" diff --git a/src/org.eclipse.ice.viz.service/OSGI-INF/VizServiceFactoryHolder.xml b/src/org.eclipse.ice.viz.service/OSGI-INF/VizServiceFactoryHolder.xml new file mode 100644 index 0000000000000000000000000000000000000000..17c1785ad2a5e8da40ac7c525bef826d87e2e4fe --- /dev/null +++ b/src/org.eclipse.ice.viz.service/OSGI-INF/VizServiceFactoryHolder.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/org.eclipse.ice.viz.service/build.properties b/src/org.eclipse.ice.viz.service/build.properties index e64965053faaf3c7eaf66924d38f6cb78f3f4ddc..3d482ec99c47bfa043e792e18ff9c49045c4e52a 100644 --- a/src/org.eclipse.ice.viz.service/build.properties +++ b/src/org.eclipse.ice.viz.service/build.properties @@ -3,5 +3,6 @@ bin.includes = META-INF/,\ .,\ OSGI-INF/,\ OSGI-INF/vizFactory.xml,\ + OSGI-INF/VizServiceFactoryHolder.xml,\ plugin.xml source.. = src/ diff --git a/src/org.eclipse.ice.viz.service/plugin.xml b/src/org.eclipse.ice.viz.service/plugin.xml index 8d9dbcf7333df30f3b7117bc83345cfd05458126..f4f531ac0a893398c60357c07ec911e5acfb36ba 100644 --- a/src/org.eclipse.ice.viz.service/plugin.xml +++ b/src/org.eclipse.ice.viz.service/plugin.xml @@ -16,5 +16,16 @@ + + + + + + diff --git a/src/org.eclipse.ice.viz.service/schema/org.eclipse.ui.perspectives.exsd b/src/org.eclipse.ice.viz.service/schema/org.eclipse.ui.perspectives.exsd new file mode 100644 index 0000000000000000000000000000000000000000..296a3a60d311b8e448321e6c5e8174c422d81f81 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/schema/org.eclipse.ui.perspectives.exsd @@ -0,0 +1,84 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.lock b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.lock new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.log b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.log new file mode 100644 index 0000000000000000000000000000000000000000..bef7357ee18f5f4e1a66b182dcb044a5d1d904c4 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.log @@ -0,0 +1,64 @@ +!SESSION 2015-06-23 11:57:53.010 ----------------------------------------------- +eclipse.buildId=unknown +java.version=1.8.0_31 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US +Framework arguments: -application org.eclipse.ui.ide.workbench +Command-line arguments: -application org.eclipse.ui.ide.workbench -data C:\Users\r8s\workspace\ice\src\org.eclipse.ice.viz.service\src\org\eclipse\ice\viz\service -dev file:C:/Users/r8s/workspace/.metadata/.plugins/org.eclipse.pde.core/Test Recorder Basic Dialog/dev.properties -os win32 -ws win32 -arch x86_64 + +!ENTRY org.eclipse.e4.ui.workbench 1 0 2015-06-23 11:57:55.930 +!MESSAGE Nothing to merge for "platform:/plugin/org.eclipse.ice.materials.ui/materialsFragment.e4xmi" + +!ENTRY org.eclipse.jface 2 0 2015-06-23 11:57:57.089 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2015-06-23 11:57:57.090 +!MESSAGE A conflict occurred for ALT+SHIFT+X R: +Binding(ALT+SHIFT+X R, + ParameterizedCommand(Command(org.eclipse.rap.ui.launch.RAPLaunchShortcut.run,Run RAP Application, + Run RAP Application, + Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@44fdce3c, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+X R, + ParameterizedCommand(Command(org.eclipse.wst.server.launchShortcut.run,Run on Server, + Run the current selection on a server, + Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@712c5463, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2015-06-23 11:57:57.090 +!MESSAGE A conflict occurred for ALT+SHIFT+D R: +Binding(ALT+SHIFT+D R, + ParameterizedCommand(Command(org.eclipse.rap.ui.launch.RAPLaunchShortcut.debug,Debug RAP Application, + Debug RAP Application, + Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6d33a66e, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+D R, + ParameterizedCommand(Command(org.eclipse.wst.server.launchShortcut.debug,Debug on Server, + Debug the current selection on a server, + Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2f14b0f6, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.egit.ui 2 0 2015-06-23 11:58:00.514 +!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level +Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory. +The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in +this system level configuration. The Git installation location can be configured on the +Team > Git > Configuration preference page's 'System Settings' tab. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.egit.ui 2 0 2015-06-23 11:58:00.515 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\r8s'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.mylyn/repositories.xml.zip b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000000000000000000000000000000000000..48fcd7830508f243ccd1fec86cb47d90521d5ce5 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.mylyn/repositories.xml.zip differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.core/.log b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.core/.log new file mode 100644 index 0000000000000000000000000000000000000000..a66b1ee00f1264e1e74e7703a436db6fe2846219 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.core/.log @@ -0,0 +1 @@ +*** SESSION Jun 23, 2015 11:57:58.62 ------------------------------------------- diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c @@ -0,0 +1 @@ + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp @@ -0,0 +1 @@ + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..1e099f3bff508a47e7cce4c8ace123e0c07a5306 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000000000000000000000000000000000000..ca55f71001ff4788ec98a1ea1a6c1abfd6502b90 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Jun 23 11:58:03 EDT 2015 +.gitdir=../../../../../../../../../.git diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000000000000000000000000000000000000..25cb955ba23571f6fefd57cecf5f67454210bbc8 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..6e187045ed8c7cef3c187a0814b56373c0eaccf9 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000000000000000000000000000000000000..6b2aaa7640726588bcd3d57e1de4b1315b7f315e --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 0000000000000000000000000000000000000000..7c7591d5498b33d9ae0db246b9915a8550caceeb Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000000000000000000000000000000000000..78c43c10db77b58f85ecb175eb3f0ce33af0a0e6 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..a6aee7e098be1b898493eb8f8ae88ebf29f6958a --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +spelling_locale_initialized=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000000000000000000000000000000000..77fe5831edcc889099237e6407f59dec737d1b4e --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +version=1 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..3ca378b0dcf68762cc67ab27b6414b0127dd1cc8 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..3d707c440c9b27361eb255a23785b4b5650b2928 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -0,0 +1,2 @@ +GitRepositoriesView.GitDirectories=C\:\\Users\\r8s\\workspace\\ice\\.git; +eclipse.preferences.version=1 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..29059e82d23f821d346b51e8d58230dedd77703a --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,15 @@ +content_assist_favorite_static_members=org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.*;org.hamcrest.Matchers.*;org.hamcrest.MatcherAssert.*;org.junit.Assert.*;org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.*;org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.*;org.eclipse.swtbot.swt.finder.SWTBotAssert.*;org.eclipse.swtbot.eclipse.finder.waits.Conditions.*;org.eclipse.swtbot.swt.finder.waits.Conditions.* +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +fontPropagated=true +org.eclipse.jdt.internal.ui.navigator.layout=2 +org.eclipse.jdt.ui.editor.tab.width= +org.eclipse.jdt.ui.formatterprofiles.version=12 +org.eclipse.jdt.ui.javadoclocations.migrated=true +org.eclipse.jface.textfont=1|Consolas|10.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; +proposalOrderMigrated=true +spelling_locale_initialized=true +tabWidthPropagated=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 0000000000000000000000000000000000000000..c05c14ca04a6155614121f867ff3535fb29c64bf --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..e5a71f29e8e89113f3416bdefea468e805ce4b8d --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..e0b8c16e4a1c8b8d8023116421c2c07f78599985 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..07d6ad69c209aa49a833851e332d990130514d48 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..08f06e2b36956c9140ab2e2b5167384208621426 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.rse.systemtype.local.systemType.defaultUserId=r8s diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..93d9a7485fc90cf1bc81e6e47b55a1bd908df2ce --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.rse.preferences.order.connections=UltraFluffy.Local diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..56114a2bc90f8d92da2534a36e328898ed082fd9 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +pref_first_startup=false diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..848e26387848c5003f8f6c6d55e833ee8c53e9bc --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.team.ui.first_time=false diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 0000000000000000000000000000000000000000..60dd1a44256b3be53976cf7e9bbdbd06836f1e44 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,5 @@ +TASKS_FILTERS_MIGRATE=true +eclipse.preferences.version=1 +platformState=1435074937031 +quickStart=false +tipsAndTricks=true diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 0000000000000000000000000000000000000000..98888350336420b71ba0209626352ac8f64aec26 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,4 @@ +//org.eclipse.ui.commands/state/org.eclipse.wst.xml.views.XPathView.processor.xpathprocessor/org.eclipse.ui.commands.radioState=xpath10 +ENABLED_DECORATORS=org.eclipse.m2e.core.mavenVersionDecorator\:false,org.eclipse.wst.server.ui.decorator\:false,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.cdt.managedbuilder.ui.includeFolder\:true,org.eclipse.cdt.internal.ui.CustomBuildSettingsDecorator\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.jdt.ui.override.decorator\:true,org.eclipse.jdt.ui.interface.decorator\:false,org.eclipse.jdt.ui.buildpath.decorator\:true,org.eclipse.m2e.core.maven2decorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.pde.ui.binaryProjectDecorator\:false,org.eclipse.ptp.rdt.sync.ui.decorator\:true,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.SymlinkDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false,org.eclipse.wst.jsdt.ui.override.decorator\:true,org.eclipse.wst.server.ui.navigatorDecorator\:true,oorg.eclipse.xtend.shared.ui.decorator\:true,org.eclipse.xtext.builder.nature.overlay\:true, +PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.m2e.discovery; +eclipse.preferences.version=1 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000000000000000000000000000000000000..49ea9caefac9f48aba817edd9e89be28b7538da5 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,3349 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.ice.client.rcp.fileActionSet + persp.actionSet:org.eclipse.mylyn.context.ui.actionSet + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.ptp.debug.ui.debugActionSet + persp.actionSet:org.eclipse.rse.core.search.searchActionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.wb.core.ui.actionset + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.views.BookmarkView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.PropertySheet + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.views.TaskList + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + persp.perspSC:org.eclipse.cdt.ui.CPerspective + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.perspSC:org.eclipse.jdt.ui.JavaPerspective + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.perspSC:org.eclipse.ptp.debug.ui.PTPDebugPerspective + persp.actionSet:org.eclipse.rephraserengine.ui.DebugActionSet + persp.perspSC:org.eclipse.team.cvs.ui.cvsPerspective + persp.perspSC:org.eclipse.team.ui.TeamSynchronizingPerspective + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.perspSC:org.eclipse.wst.jsdt.ui.JavaPerspective + persp.perspSC:org.eclipse.wst.xml.ui.perspective + + + + newtablook + org.eclipse.e4.primaryNavigationStack + active + + + + + + + newtablook + org.eclipse.e4.secondaryNavigationStack + + + + + + + + + newtablook + + + + + + + newtablook + org.eclipse.e4.secondaryDataStack + + + + + newtablook + + + + + + + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + newtablook + org.eclipse.e4.primaryDataStack + EditorStack + + + + + View + categoryTag:General + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Ant + + + View + categoryTag:General + + + View + categoryTag:Mylyn + + + + View + categoryTag:Performance Analysis + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Team + + + View + categoryTag:CVS + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + + + + + toolbarSeparator + + + + Draggable + + + + + Draggable + + + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + + + stretch + + + glue + + + + glue + + + Draggable + + + + + stretch + + + + Draggable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + platform:win32 + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + + + View + categoryTag:Ant + + + View + categoryTag:&C/C++ + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Make + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:&C/C++ + + + View + categoryTag:General + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Other + + + View + categoryTag:Debug + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Maven + + + View + categoryTag:Maven + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:API Tools + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Fortran Views + + + View + categoryTag:Fortran Views + + + View + categoryTag:Fortran Views + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Performance Analysis + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Remote Development + + + View + categoryTag:Remote Development + + + View + categoryTag:Remote Development + + + View + categoryTag:Remote Development + + + View + categoryTag:Remote Tools + + + View + categoryTag:Other + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Parallel Tools + + + View + categoryTag:Services + + + View + categoryTag:Recommenders + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:SWTBot Category + + + View + categoryTag:CVS + + + View + categoryTag:CVS + + + View + categoryTag:Team + + + View + categoryTag:Team + + + View + categoryTag:Terminal + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:WindowBuilder + + + View + categoryTag:WindowBuilder + + + View + categoryTag:General + + + View + categoryTag:Debug + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:Server + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:Xtend + + + View + categoryTag:Xtext + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000000000000000000000000000000000000..3de398e8f2856ff30f4c5dd9cf8cfd66b137fcc8 Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000000000000000000000000000000000000..6cd956293a0490bb8c15907d99ec686bdf5f08ae --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000000000000000000000000000000000000..8c365b725af2ff0e8c3bd75e6de465fb109f1b3e --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..1c4333caee058100b552bf9e90e279e9be53ff55 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser new file mode 100644 index 0000000000000000000000000000000000000000..1e9a069ce2c81f1416dddc1758ee55385f17251d Binary files /dev/null and b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser differ diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.photran.core.vpg/photran70vpg-log.txt b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.photran.core.vpg/photran70vpg-log.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.photran.core.vpg/photran70vpg.new b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.photran.core.vpg/photran70vpg.new new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/.log b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.local.files_0/node.properties b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.local.files_0/node.properties new file mode 100644 index 0000000000000000000000000000000000000000..d29add019644defbfa93d11a8c5cc38308bf4eda --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.local.files_0/node.properties @@ -0,0 +1,57 @@ +# RSE DOM Node +00-name=UltraFluffy\:local.files +01-type=FilterPool +03-attr.default=true +03-attr.deletable=true +03-attr.id=local.files +03-attr.nonRenamable=false +03-attr.owningParentName=null +03-attr.release=200 +03-attr.singleFilterStringOnly=false +03-attr.singleFilterStringOnlyESet=false +03-attr.stringsCaseSensitive=true +03-attr.supportsDuplicateFilterStrings=false +03-attr.supportsNestedFilters=true +03-attr.type=default +06-child.00000.00-name=My Home +06-child.00000.01-type=Filter +06-child.00000.03-attr.default=false +06-child.00000.03-attr.filterType=default +06-child.00000.03-attr.id=My Home +06-child.00000.03-attr.nonChangable=false +06-child.00000.03-attr.nonDeletable=false +06-child.00000.03-attr.nonRenamable=false +06-child.00000.03-attr.promptable=false +06-child.00000.03-attr.relativeOrder=0 +06-child.00000.03-attr.release=200 +06-child.00000.03-attr.singleFilterStringOnly=false +06-child.00000.03-attr.stringsCaseSensitive=false +06-child.00000.03-attr.stringsNonChangable=false +06-child.00000.03-attr.supportsDuplicateFilterStrings=false +06-child.00000.03-attr.supportsNestedFilters=true +06-child.00000.06-child.00000.00-name=C\:\\Users\\r8s\\* +06-child.00000.06-child.00000.01-type=FilterString +06-child.00000.06-child.00000.03-attr.default=false +06-child.00000.06-child.00000.03-attr.string=C\:\\Users\\r8s\\* +06-child.00000.06-child.00000.03-attr.type=default +06-child.00001.00-name=Drives +06-child.00001.01-type=Filter +06-child.00001.03-attr.default=false +06-child.00001.03-attr.filterType=default +06-child.00001.03-attr.id=Drives +06-child.00001.03-attr.nonChangable=false +06-child.00001.03-attr.nonDeletable=false +06-child.00001.03-attr.nonRenamable=false +06-child.00001.03-attr.promptable=false +06-child.00001.03-attr.relativeOrder=0 +06-child.00001.03-attr.release=200 +06-child.00001.03-attr.singleFilterStringOnly=false +06-child.00001.03-attr.stringsCaseSensitive=false +06-child.00001.03-attr.stringsNonChangable=false +06-child.00001.03-attr.supportsDuplicateFilterStrings=false +06-child.00001.03-attr.supportsNestedFilters=true +06-child.00001.06-child.00000.00-name=* +06-child.00001.06-child.00000.01-type=FilterString +06-child.00001.06-child.00000.03-attr.default=false +06-child.00001.06-child.00000.03-attr.string=* +06-child.00001.06-child.00000.03-attr.type=default diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.org.eclipse.ptp.remote.rse.core._0/node.properties b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.org.eclipse.ptp.remote.rse.core._0/node.properties new file mode 100644 index 0000000000000000000000000000000000000000..87e4bb2275a95f53fd6ec8373e7a79cbd4a55fa3 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/FP.org.eclipse.ptp.remote.rse.core._0/node.properties @@ -0,0 +1,15 @@ +# RSE DOM Node +00-name=UltraFluffy\:org.eclipse.ptp.remote.rse.core. +01-type=FilterPool +03-attr.default=true +03-attr.deletable=true +03-attr.id=org.eclipse.ptp.remote.rse.core. +03-attr.nonRenamable=false +03-attr.owningParentName=null +03-attr.release=200 +03-attr.singleFilterStringOnly=false +03-attr.singleFilterStringOnlyESet=false +03-attr.stringsCaseSensitive=true +03-attr.supportsDuplicateFilterStrings=false +03-attr.supportsNestedFilters=true +03-attr.type=default diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/H.local_16/node.properties b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/H.local_16/node.properties new file mode 100644 index 0000000000000000000000000000000000000000..2f1f433c1b325477916f9b2c48d4bf65da475726 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/H.local_16/node.properties @@ -0,0 +1,32 @@ +# RSE DOM Node +00-name=Local +01-type=Host +03-attr.description= +03-attr.hostname=LOCALHOST +03-attr.offline=false +03-attr.promptable=false +03-attr.systemType=org.eclipse.rse.systemtype.local +03-attr.type=Local +06-child.00000.00-name=Local Connector Service +06-child.00000.01-type=ConnectorService +06-child.00000.03-attr.group=Local Connector Service +06-child.00000.03-attr.port=0 +06-child.00000.03-attr.useSSL=false +06-child.00000.06-child.00000.00-name=Local Files +06-child.00000.06-child.00000.01-type=SubSystem +06-child.00000.06-child.00000.03-attr.hidden=false +06-child.00000.06-child.00000.03-attr.type=local.files +06-child.00000.06-child.00000.06-child.00000.00-name=UltraFluffy___UltraFluffy\:local.files +06-child.00000.06-child.00000.06-child.00000.01-type=FilterPoolReference +06-child.00000.06-child.00000.06-child.00000.03-attr.refID=local.files +06-child.00000.06-child.00001.00-name=Local Shells +06-child.00000.06-child.00001.01-type=SubSystem +06-child.00000.06-child.00001.03-attr.hidden=false +06-child.00000.06-child.00001.03-attr.type=local.shells +06-child.00000.06-child.00002.00-name=Local Process Spawner +06-child.00000.06-child.00002.01-type=SubSystem +06-child.00000.06-child.00002.03-attr.hidden=true +06-child.00000.06-child.00002.03-attr.type=org.eclipse.ptp.remote.rse.core. +06-child.00000.06-child.00002.06-child.00000.00-name=UltraFluffy___UltraFluffy\:org.eclipse.ptp.remote.rse.core. +06-child.00000.06-child.00002.06-child.00000.01-type=FilterPoolReference +06-child.00000.06-child.00002.06-child.00000.03-attr.refID=org.eclipse.ptp.remote.rse.core. diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/node.properties b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/node.properties new file mode 100644 index 0000000000000000000000000000000000000000..841a44b1ea0ecaa70e4dc939fd5f722859665076 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.ultrafluffy_1056/node.properties @@ -0,0 +1,8 @@ +# RSE DOM Node +00-name=UltraFluffy +01-type=Profile +03-attr.defaultPrivate=true +03-attr.isActive=true +05-ref.00000=FP.local.files_0 +05-ref.00001=FP.org.eclipse.ptp.remote.rse.core._0 +05-ref.00002=H.local_16 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.ui/.log b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.rse.ui/.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..52ab1498f1d2c3edd509183d11a4f336c62d8b35 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,146 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..630e1c4051e9b9991a0f5966e4293886431b4830 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,28 @@ + +
+
+ + + + + + + + + + +
+
+ + + + +
+
+ + + + + +
+
diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/version.ini b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/version.ini new file mode 100644 index 0000000000000000000000000000000000000000..c51ff745b6c995c410e2977bb11c544ed7f6ca76 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/.metadata/version.ini @@ -0,0 +1 @@ +org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/BasicVizServiceFactory.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/BasicVizServiceFactory.java index 5d1b7265847107cbf06ec80aaa67d570fb8e2ba3..16444de85713640253dcba0594b7158d82cc0c2e 100644 --- a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/BasicVizServiceFactory.java +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/BasicVizServiceFactory.java @@ -12,11 +12,18 @@ package org.eclipse.ice.viz.service; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import org.eclipse.ice.viz.service.csv.CSVVizService; import org.eclipse.ice.viz.service.preferences.CustomScopedPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.IFileEditorMapping; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.registry.EditorDescriptor; +import org.eclipse.ui.internal.registry.EditorRegistry; +import org.eclipse.ui.internal.registry.FileEditorMapping; /** * This class is the basic implementation of the IVizServiceFactory in ICE. It @@ -74,6 +81,31 @@ public class BasicVizServiceFactory implements IVizServiceFactory { // Put the service in service map so it can be retrieved later serviceMap.put(name, service); + Set supportedExtensions = new HashSet(); + supportedExtensions + .addAll(((AbstractVizService) service).supportedExtensions); + + // Register the plot editor as default editor for all file + // extensions handled by the new viz service + for (String ext : supportedExtensions) { + EditorRegistry editorReg = (EditorRegistry) PlatformUI + .getWorkbench().getEditorRegistry(); + EditorDescriptor editor = (EditorDescriptor) editorReg + .findEditor("org.eclipse.ice.viz.service.PlotEditor"); + FileEditorMapping mapping = new FileEditorMapping(ext); + mapping.addEditor(editor); + mapping.setDefaultEditor(editor); + + IFileEditorMapping[] mappings = editorReg + .getFileEditorMappings(); + FileEditorMapping[] newMappings = new FileEditorMapping[mappings.length + 1]; + for (int i = 0; i < mappings.length; i++) { + newMappings[i] = (FileEditorMapping) mappings[i]; + } + newMappings[mappings.length] = mapping; + editorReg.setFileEditorMappings(newMappings); + } + System.out.println("VizServiceFactory message: " + "Viz service \"" + name + "\" registered."); diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditor.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditor.java new file mode 100644 index 0000000000000000000000000000000000000000..ea501c015a9041b5c04c7e0581f08fb2bfef60e8 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditor.java @@ -0,0 +1,437 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.viz.service; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ice.client.common.ActionTree; +import org.eclipse.ice.viz.service.internal.VizServiceFactoryHolder; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.EditorPart; +import org.eclipse.ui.part.FileEditorInput; + +/** + * This class implements a plot editor. It takes as input a FileInput containing + * a file of visualization data. It can make use of any VizService registered to + * the BasicVizServiceFactory to create the plot. It can prompt the user in case + * there are multiple applicable services for the file. The UI contains options + * to redraw the plot using the IPlot's provided list of categories and plot + * types. The IPlot's provided context menu is also available to the user. + * + * @author Robert Smith + * + */ + +public class PlotEditor extends EditorPart { + /** + * Plot editor ID for external reference. + */ + public static final String ID = "org.eclipse.ice.viz.service.PlotEditor"; + + /** + * The FileEditorInput containing the plot the editor contains. + */ + private FileEditorInput plot; + + /** + * Default constructor. + */ + public PlotEditor() { + super(); + return; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime. + * IProgressMonitor) + */ + @Override + public void doSave(IProgressMonitor monitor) { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.EditorPart#doSaveAs() + */ + @Override + public void doSaveAs() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, + * org.eclipse.ui.IEditorInput) + */ + @Override + public void init(IEditorSite site, IEditorInput input) + throws PartInitException { + setSite(site); + setInput(input); + return; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.EditorPart#isDirty() + */ + @Override + public boolean isDirty() { + return false; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() + */ + @Override + public boolean isSaveAsAllowed() { + return false; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets + * .Composite) + */ + @Override + public void createPartControl(final Composite parent) { + setPartName("Plot Editor"); + // form = new ManagedForm(parent); + plot = (FileEditorInput) getEditorInput(); + final URI filepath = plot.getURI(); + + // Get the VizServiceFactory and all Viz Services + final IVizServiceFactory factory = (BasicVizServiceFactory) VizServiceFactoryHolder + .getFactory(); + + // An array of all registered service names. + String[] fullServiceNames = factory.getServiceNames(); + + // An ArrayList of all registered service names. + final ArrayList serviceNames = new ArrayList(); + AbstractVizService service = null; + + // An ArrayList of PlotEditorInputs, one created with each VizService + // capable of handling the file type. + ArrayList inputArray = new ArrayList(); + + for (int i = 0; i < fullServiceNames.length; i++) { + + service = (AbstractVizService) factory.get(fullServiceNames[i]); + + // If this service can handle the file extension, create a + // PlotEditorInput and add its name to the list of applicable + // services. + if (service != null && service.extensionSupported(filepath)) { + IPlot plot = null; + try { + plot = service.createPlot(filepath); + inputArray.add(new PlotEditorInput(plot)); + serviceNames.add(fullServiceNames[i]); + } catch (Exception e1) { + System.out + .println("Problem creating plot with visualization service " + + fullServiceNames[i] + "."); + } + + } + + } + + // If all available services failed to create a plot, give the user an + // error message. + if (serviceNames.isEmpty()) { + System.out + .println("All available visualizaiton services failed to render a plot."); + Status status = new Status(IStatus.ERROR, "org.eclipse.ice", 0, + "No visualization service could render the file.", null); + ErrorDialog + .openError( + Display.getCurrent().getActiveShell(), + "Visualization Failed", + "All visualization services failed to render a plot. \n" + + "If you are using an external rendering program, " + + "make sure it is connected to ICE.", + status); + return; + } + + // The number of services which succeeded in creating PlotEditorInputs + int numServices = serviceNames.size(); + + // Set up the editor window. + final Composite body = parent;// this. new + // Composite();//form.getForm().getBody(); + GridLayout grid = new GridLayout(); + grid.marginHeight = 0; + grid.marginWidth = 0; + body.setLayout(grid); + + // Array of names of all services which succeeded in creating + // PlotEditorInputs + String[] serviceNamesArray = new String[serviceNames.size()]; + serviceNames.toArray(serviceNamesArray); + + // The PlotEditorInput containing the IPlot rendered with the service + // selected for this editor. + final PlotEditorInput selectedService; + + // If more than one service is applicable, create a dialog window to + // prompt the user for which is to be used. Else, use the single + // available service. + if (numServices == 1) { + selectedService = inputArray.get(0); + } else { + PlotEditorDialog dialog = new PlotEditorDialog(PlatformUI + .getWorkbench().getActiveWorkbenchWindow().getShell()); + dialog.createDialogArea(new Shell(), serviceNamesArray); + selectedService = inputArray.get(dialog.getSelection()); + } + + // Reference to this editor instance + final IEditorPart thisEditor = this; + + // Finish loading and drawing the plot in a new thread. + Job drawPlot = new Job("Plot Editor Loading and Rendering") { + @Override + protected IStatus run(IProgressMonitor monitor) { + setUpEditor(body, selectedService, thisEditor); + return Status.OK_STATUS; + } + + }; + + drawPlot.schedule(); + return; + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + } + + /** + * Checks that the plot has finished loading and prepares variables for use + * in UI creation. Intended to be called on a non-UI thread. + * + * @param body + * Composite in which the PlotEditor will be drawn + * @param selectedService + * The service to be used in drawing the plot + * @param thisEditor + * A reference to the Editor calling the function + */ + public void setUpEditor(final Composite body, + final PlotEditorInput selectedService, final IEditorPart thisEditor) { + // Temporary holder for plot types available from the selected + // service + Map selectedServiceTypesTemp = null; + try { + selectedServiceTypesTemp = selectedService.getPlot().getPlotTypes(); + } catch (Exception e2) { + System.out.println("Error reading plot types."); + } + + // While loading is not yet complete, wait and periodically + // attempt to read the plot types again. + while (selectedServiceTypesTemp == null + || selectedServiceTypesTemp.isEmpty()) { + try { + Thread.sleep(500); + selectedServiceTypesTemp = selectedService.getPlot() + .getPlotTypes(); + } catch (Exception e1) { + System.out.println("Error reading plot types."); + } + } + + // Plot types available from the selected service + final Map selectedServiceTypes = selectedServiceTypesTemp; + + // The plot categories available from the selected service. + final Set selectedCategorySet = selectedServiceTypes.keySet(); + + // An array containing the plot categories available from the + // selected service + String[] selectedCategoryArray = selectedCategorySet + .toArray(new String[selectedCategorySet.size()]); + + // The category to use for drawing the plot initially + final String selectedCategory = selectedCategoryArray[0]; + + // The plot type to use for drawing the plot initially. + final String selectedPlotType = selectedServiceTypes + .get(selectedCategory)[0]; + + // Toolbar for the editor window + final ToolBarManager barManager = new ToolBarManager(); + + // Thread for creating the editor UI + body.getDisplay().asyncExec(new Runnable() { + + @Override + public void run() { + createUI(barManager, body, selectedCategorySet, + selectedServiceTypes, selectedService, thisEditor, + selectedCategory, selectedPlotType); + + } + }); + } + + /** + * Creates the UI for the PlotEditor and calls the visualization service to + * draw the opened plot. + * + * @param barManager + * Manager for the editor's toolbar + * @param body + * The composite in which the editor will be drawn + * @param selectedCategorySet + * The set of possible categories for the plot in the selected + * service + * @param selectedServiceTypes + * A map associating possible categories with the types of plot + * available within that category + * @param selectedService + * A PlotEditorInput containing the IPlot created with the + * selected visualization service + * @param thisEditor + * A reference to the editor being created. + * @param selectedCategory + * The category of the initial plot to draw + * @param selectedPlotType + * The type of the initial plot to draw + */ + private void createUI(ToolBarManager barManager, Composite body, + Set selectedCategorySet, + Map selectedServiceTypes, + final PlotEditorInput selectedService, + final IEditorPart thisEditor, final String selectedCategory, + final String selectedPlotType) { + // Finish setting up the editor window + ToolBar bar = barManager.createControl(body); + final Composite plotComposite = new Composite(body, SWT.NONE); + + // Menu manager for toolbar + MenuManager menu = new MenuManager("Menu"); + + // Top level menu + ActionTree menuTree = new ActionTree("Menu"); + + // Second level menu for plot category selection + ActionTree categoriesTree = new ActionTree("Plot Categories"); + menuTree.add(categoriesTree); + + // Add all categories and plot types to menu + for (final String category : selectedCategorySet) { + + // Third level menu for plot type selection within a + // specific category + ActionTree plotTree = new ActionTree(category); + categoriesTree.add(plotTree); + + for (final String type : selectedServiceTypes.get(category)) { + + // A menu item to redraw the plot with the + // selected category and plot type + Action tempAction = new Action(type) { + @Override + public void run() { + try { + selectedService.getPlot().draw(category, type, + plotComposite); + } catch (Exception e) { + System.out.println("Error while drawing plot."); + } + } + + }; + plotTree.add(new ActionTree(tempAction)); + + } + + } + + // An action to close the current editor window + Action close = new Action("Close") { + @Override + public void run() { + thisEditor.getEditorSite().getPage() + .closeEditor(thisEditor, false); + } + }; + + // Add close action directly under menu + menuTree.add(new ActionTree(close)); + + // Update menu + categoriesTree.getContributionItem().fill(menu.getMenu(), -1); + menu.updateAll(true); + barManager.add(menuTree.getContributionItem()); + + bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + // managedForm.getToolkit().adapt(bar); + barManager.update(true); + + plotComposite.setBackground(body.getBackground()); + plotComposite + .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + plotComposite.setLayout(new FillLayout()); + + // Draw the plot. + try { + selectedService.getPlot().draw(selectedCategory, selectedPlotType, + plotComposite); + } catch (Exception e) { + System.out.println("Error drawing plot."); + } + + body.layout(); + } +} diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorDialog.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..85f3550a3cc0cbe13115f69b528854ecf6dba094 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorDialog.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Jay Jay Billings + *******************************************************************************/ +package org.eclipse.ice.viz.service; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; + +/** + * A dialog box for querying the user about which visualization service to use + * during the opening of a PlotEditor. + * + * @author Robert Smith + * + */ +public class PlotEditorDialog extends Dialog { + // The index of the visualization service selected by the user in the combo + // box. + private int selectedServiceIndex; + + /** + * Default constructor. + * + * @param parentShell + */ + public PlotEditorDialog(Shell parentShell) { + super(parentShell); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets + * .Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + return container; + } + + /** + * Get method for the index of the selected service. + * + * @return The index of the service selected by the user form the combo box. + */ + protected int getSelection() { + return selectedServiceIndex; + } + + /** + * Creates the dialog box. + * + * @param parent + * The parent composite + * @param serviceNamesArray + * An array of names of available services to populate the combo + * box. + * @return Returns the dialog window's composite. + */ + public Composite createDialogArea(Composite parent, + String[] serviceNamesArray) { + // Set up the window. + //Container to be returned, create by superclass's constructor + Composite container = (Composite) super.createDialogArea(parent); + + //The current display + Display display = Display.getCurrent(); + + //The current shell + final Shell shell = container.getShell(); + + //The combo box containing the visualization service names + final Combo combo = new Combo(shell, SWT.NONE); + + //Name window and give it a grid layout + shell.setText("Open a Visualization File"); + shell.setLayout(new GridLayout()); + + //Populate the combo box and give it a default message + combo.setItems(serviceNamesArray); + combo.setText("Select a visualization service."); + + // Update the selected index when the user makes a new selection. + combo.addListener(SWT.DefaultSelection, new Listener() { + @Override + public void handleEvent(Event e) { + selectedServiceIndex = combo.getSelectionIndex(); + } + }); + + //Set the size of the combo box + combo.setLayoutData(new GridData(300, 100, false, false)); + + //Create the Ok button + Button button = new Button(shell, SWT.PUSH); + button.setText("Ok"); + + // Close the window when the ok button is pressed. + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + shell.close(); + } + }); + + //Set the ok button's size + button.setLayoutData(new GridData(SWT.CENTER)); + shell.setDefaultButton(button); + shell.setSize(200, 100); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + + return container; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets + * .Shell) + */ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() + */ + @Override + protected Point getInitialSize() { + return new Point(250, 100); + } + +} diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorInput.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorInput.java new file mode 100644 index 0000000000000000000000000000000000000000..1bf10859fb464c196298c1a3d3a202e8889c485b --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/PlotEditorInput.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Robert Smith + *******************************************************************************/ +package org.eclipse.ice.viz.service; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPersistableElement; + +/** + * An EditorInput for the PlotEditor. + * + * @author Robert Smith + * + */ +public class PlotEditorInput implements IEditorInput { + /** + * The plot to be rendered by the PlotEditor + */ + private IPlot data; + + /** + * Constructor. + * + * @param input + * The IPlot to be rendered by the plot editor. + */ + public PlotEditorInput(IPlot input) { + data = input; + } + + /** + * Getter for the input plot. + * + * @return the plot that is to be rendered by the plot editor. + */ + public IPlot getPlot() { + return data; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#exists() + */ + @Override + public boolean exists() { + return true; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getImageDescriptor() + */ + @Override + public ImageDescriptor getImageDescriptor() { + return ImageDescriptor.getMissingImageDescriptor(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getName() + */ + @Override + public String getName() { + String name = data.getDataSource().toString(); + return name; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getPersistable() + */ + @Override + public IPersistableElement getPersistable() { + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IEditorInput#getToolTipText() + */ + @Override + public String getToolTipText() { + return data.getDataSource().toString(); + } + +} diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/.project b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/.project new file mode 100644 index 0000000000000000000000000000000000000000..76756293201b7528258e39a64683d6c0227e976f --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8.csv b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8.csv new file mode 100644 index 0000000000000000000000000000000000000000..acd251a05f828dde1039fa51b50aa61527e221f7 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8.csv @@ -0,0 +1,10 @@ +x,f(x) +0,0 +1,1 +2,1 +3,2 +4,3 +5,5 +6,8 +7,13 +8,21 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8bad.csv b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8bad.csv new file mode 100644 index 0000000000000000000000000000000000000000..e27ca4b0be1e9cea5fdc08b295a11a4f6b194df4 --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/RemoteSystemsTempFiles/fib8bad.csv @@ -0,0 +1,10 @@ +x,f(x) +0,0 +1,1 +2,1 +3,2 +4, +5,5 +6,8 +7,13 +8,21 diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java index fcf8aaa591024ab1f02f3addb44b17c00d52905c..d27b082a8458d2795edd730b38cfbbe2b2352b1d 100644 --- a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java @@ -30,6 +30,7 @@ import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MenuListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; /** * This class implements the IPlot interface to provide access to a basic CSV @@ -366,7 +367,7 @@ public class CSVPlot implements IPlot { * The {@code Composite} in which to draw the CSV plot * editor. */ - public DrawnPlot(Composite parent) throws Exception { + public DrawnPlot(final Composite parent) throws Exception { // Create the editor and all required providers. editor = new CSVPlotEditor(); dataProvider = baseProvider; @@ -443,12 +444,19 @@ public class CSVPlot implements IPlot { @Override public void menuShown(MenuEvent e) { + // Rebuild the menu. Menu menu = (Menu) e.widget; + if (parent.getMenu() == null) { + for (MenuItem item : menu.getItems()) { + item.dispose(); + } + } addSeriesTree.getContributionItem().fill(menu, -1); removeSeriesTree.getContributionItem().fill(menu, -1); separator.fill(menu, -1); clearAction.getContributionItem().fill(menu, -1); + } }); diff --git a/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/internal/VizServiceFactoryHolder.java b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/internal/VizServiceFactoryHolder.java new file mode 100644 index 0000000000000000000000000000000000000000..147de596bfb6b953640c2c0642457cc47874c90c --- /dev/null +++ b/src/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/internal/VizServiceFactoryHolder.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Robert Smith + *******************************************************************************/ +package org.eclipse.ice.viz.service.internal; + +import org.eclipse.ice.viz.service.IVizServiceFactory; + +/** + * Holder class for a VizServiceFactory. + * + * @author Robert Smith + * + */ + +public class VizServiceFactoryHolder { + //The VizServiceFactory held by the VizServiceFactory + private static IVizServiceFactory factory; + + /** + * Setter for the VizServiceFactory. + * + * @param input + * the VizServiceFactory to hold + */ + public static void setVizServiceFactory(IVizServiceFactory input) { + VizServiceFactoryHolder.factory = input; + return; + } + + /** + * Remove the given VizServiceFactory if it is held by the VizServiceFactoryHolder. + * + * @input A VizServiceFactory to remove. + */ + public static void unsetVizServiceFactory(IVizServiceFactory input) { + if(input == factory){ + factory = null; + } + return; + } + + /** + * Getter for the held VizServiceFactory. + * + * @return the held VizServiceFactory + */ + public static IVizServiceFactory getFactory() { + return factory; + } + +} diff --git a/src/org.eclipse.ice.viz/plugin.xml b/src/org.eclipse.ice.viz/plugin.xml index 43737d701f0201489f055a30e7b8001a5066fca9..64e4944d7a6230e73519910a92350c46222bf48c 100644 --- a/src/org.eclipse.ice.viz/plugin.xml +++ b/src/org.eclipse.ice.viz/plugin.xml @@ -1,5 +1,3 @@ - - - + \ No newline at end of file diff --git a/tests/org.eclipse.ice.viz.service.test/.classpath b/tests/org.eclipse.ice.viz.service.test/.classpath index 098194ca4b7d8f45177f94e735506ae3a26b5c94..b1dabee38291b97f08cc3a18bee4e65b1e550530 100644 --- a/tests/org.eclipse.ice.viz.service.test/.classpath +++ b/tests/org.eclipse.ice.viz.service.test/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/tests/org.eclipse.ice.viz.service.test/META-INF/MANIFEST.MF b/tests/org.eclipse.ice.viz.service.test/META-INF/MANIFEST.MF index c0a8978ad8b88a33a97481284fe1ead5e99680db..b342a6a9db42cc5791216d6d11057fb1451d58c0 100644 --- a/tests/org.eclipse.ice.viz.service.test/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.ice.viz.service.test/META-INF/MANIFEST.MF @@ -5,15 +5,22 @@ Bundle-SymbolicName: org.eclipse.ice.viz.service.test Bundle-Version: 2.0.0 Bundle-Vendor: Oak Ridge National Laboratory Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: org.eclipse.ice.datastructures.ICEObject, +Import-Package: org.eclipse.core.filesystem, + org.eclipse.core.resources, + org.eclipse.emf.common.util, + org.eclipse.ice.datastructures.ICEObject, org.eclipse.ice.datastructures.form, org.eclipse.ice.viz.service, org.eclipse.ice.viz.service.connections, org.eclipse.ice.viz.service.csv, - org.eclipse.swt.widgets + org.eclipse.ice.viz.service.internal, + org.eclipse.swt.widgets, + org.eclipse.ui.ide Require-Bundle: org.junit, org.eclipse.swtbot.eclipse.core;bundle-version="2.2.1", org.eclipse.swtbot.go;bundle-version="2.2.1", org.eclipse.swtbot.junit4_x;bundle-version="2.2.1", org.eclipse.swtbot.swt.finder;bundle-version="2.2.1", - org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.2.1" + org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.2.1", + org.eclipse.ui.workbench, + org.eclipse.ui.ide diff --git a/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java new file mode 100644 index 0000000000000000000000000000000000000000..fc1cd4ad023ce35d0b14dfe0923acc52f4170bf5 --- /dev/null +++ b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Robert Smith + *******************************************************************************/ +package org.eclipse.ice.viz.service.internal.test; + +import static org.junit.Assert.*; + +import org.eclipse.ice.viz.service.BasicVizServiceFactory; +import org.eclipse.ice.viz.service.IVizService; +import org.eclipse.ice.viz.service.IVizServiceFactory; +import org.eclipse.ice.viz.service.internal.VizServiceFactoryHolder; +import org.eclipse.ice.viz.service.test.FakeVizService; +import org.junit.Test; + +public class VizServiceFactoryHolderTester { + + /** + * Checks that the factory holder's methods for registering, getting, and + * removing a factory are functioning. + * + */ + @Test + public void checkFactorySetting() { + + // Create a test factory with a test service. + IVizServiceFactory factory = new FakeVizServiceFactory(); + String serviceName = "TestService"; + IVizService service = new FakeVizService(serviceName); + factory.register(service); + + // Test that the factory has been registered + VizServiceFactoryHolder.setVizServiceFactory(factory); + assertNotNull(VizServiceFactoryHolder.getFactory()); + + // Test that the factory in the holder is the same factory registered. + assertEquals("TestService", VizServiceFactoryHolder.getFactory().getServiceNames()[0]); + + // Test that the holder is empty after removing the factory. + VizServiceFactoryHolder.unsetVizServiceFactory(factory); + assertNull(VizServiceFactoryHolder.getFactory()); + + } + + /** + * Creates a basic VizServiceFactory for testing purposes. + * + * @author Robert Smith + * + */ + private class FakeVizServiceFactory implements IVizServiceFactory { + private IVizService service; + + @Override + public void register(IVizService newService) { + // TODO Auto-generated method stub + service = newService; + } + + @Override + public void unregister(IVizService service) { + // TODO Auto-generated method stub + + } + + @Override + public String[] getServiceNames() { + // TODO Auto-generated method stub + String[] serviceNames = new String[1]; + serviceNames[0] = service.getName(); + return serviceNames; + } + + @Override + public IVizService get(String serviceName) { + // TODO Auto-generated method stub + return null; + } + + @Override + public IVizService get() { + // TODO Auto-generated method stub + return null; + } + + } + +} diff --git a/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorInputTester.java b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorInputTester.java new file mode 100644 index 0000000000000000000000000000000000000000..66b483e19d7938ecbaf01fa066b2a7184d07bb21 --- /dev/null +++ b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorInputTester.java @@ -0,0 +1,84 @@ +package org.eclipse.ice.viz.service.test; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.util.Map; + +import org.eclipse.ice.viz.service.IPlot; +import org.eclipse.ice.viz.service.PlotEditorInput; +import org.eclipse.swt.widgets.Composite; +import org.junit.Test; + +public class PlotEditorInputTester { + + /** + * Dummy IPlot implementation for testing purposes. + * + * @author Robert Smith + * + */ + class FakePlot implements IPlot { + private URI source; + + public FakePlot(URI newSource) { + source = newSource; + } + + @Override + public Map getPlotTypes() throws Exception { + return null; + } + + @Override + public Composite draw(String category, String plotType, Composite parent) + throws Exception { + return null; + } + + @Override + public int getNumberOfAxes() { + return 0; + } + + @Override + public Map getProperties() { + return null; + } + + @Override + public void setProperties(Map props) throws Exception { + } + + @Override + public URI getDataSource() { + return null; + } + + @Override + public String getSourceHost() { + return null; + } + + @Override + public boolean isSourceRemote() { + return false; + } + + @Test + public void checkInput() { + // Create plot + URI testURI = null; + try { + testURI = new URI("test.silo"); + } catch (Exception e) { + } + IPlot testPlot = new FakePlot(testURI); + + // Check that the input has the correct URI + PlotEditorInput testInput = new PlotEditorInput(testPlot); + assertEquals(testInput.getName(), "test.silo"); + + } + } +} diff --git a/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorTester.java b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorTester.java new file mode 100644 index 0000000000000000000000000000000000000000..507bdb625c3c4e29badb2124b49927c7a66ba8ea --- /dev/null +++ b/tests/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/PlotEditorTester.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2014 UT-Battelle, LLC. + * 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: + * Initial API and implementation and/or initial documentation - + * Robert Smith + *******************************************************************************/ +package org.eclipse.ice.viz.service.test; + +import static org.junit.Assert.*; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.bindings.keys.ParseException; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +import java.io.File; + +/** + * This class is responsible for testing the PlotEditor class. + * + * @author Robert Smith + * + */ + +@RunWith(SWTBotJunit4ClassRunner.class) +public class PlotEditorTester { + /* + * The SWTBot used in testing. + */ + private static SWTWorkbenchBot bot; + + /* + * Creates the bot before running tests. + */ + @BeforeClass + public static void beforeClass() throws Exception { + bot = new SWTWorkbenchBot(); + } + + /* + * Tests that the plot editor can open a file correctly, and display the + * necessary menus. + */ + @Test + public void testPlotEditor() { + + // Set up the workspace + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + + // The OS's file path separator + String separator = System.getProperty("file.separator"); + String projectName = "CSVVizService"; + java.net.URI defaultProjectLocation = null; + + // Setup the project + try { + // Get the project handle + IProject project = workspaceRoot.getProject(projectName); + // If the project does not exist, create it + if (!project.exists()) { + // Set the location as + // ${workspace_loc}/CAEBATModelTesterWorkspace + defaultProjectLocation = (new File( + System.getProperty("user.home") + separator + + "ICETests" + separator + projectName)) + .toURI(); + // Create the project description + IProjectDescription desc = ResourcesPlugin.getWorkspace() + .newProjectDescription(projectName); + // Set the location of the project + desc.setLocationURI(defaultProjectLocation); + // Create the project + project.create(desc, null); + } + // Open the project if it is not already open + if (project.exists() && !project.isOpen()) { + project.open(null); + } + // Refresh the workspace + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // Catch exception for creating the project + e.printStackTrace(); + fail(); + } + + // Close the initial eclipse welcome window + bot.viewByTitle("Welcome").close(); + + // Open the project explorer + bot.menu("Window").menu("Show View").menu("Project Explorer").click(); + + // Open the fib8.csv file in the plot editor. + SWTBotTreeItem node = bot.tree().getTreeItem("CSVVizService"); + node.expand(); + node.getNode("fib8.csv").select(); + node.getNode("fib8.csv").doubleClick(); + + // Test the plot category selection menu + SWTBotToolbarDropDownButton button = bot.activeEditor().bot() + .toolbarDropDownButton(); + button.menuItem("Plot Categories").menu("Bar").menu("x vs. f(x)") + .click(); + + // Close the menu before testing the next item + try { + button.pressShortcut(KeyStroke.getInstance("ESC")); + } catch (ParseException e1) { + e1.printStackTrace(); + fail(); + } + + // Test the editor closing menu option. + button.menuItem("Close").click(); + + } +}