-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/24429/
-----------------------------------------------------------
Review request for oodt, brian Foster, Lewis McGibbney, Chris Mattmann, Paul
Ramirez, and Rishi Verma.
Bugs: OODT-741
https://issues.apache.org/jira/browse/OODT-741
Repository: oodt
Description
-------
The XMLValidationLayer class has a HashMap<String, Element> called elementMap.
This is used to store details about elements from the File Manager's
elements.xml configuration file.
Currently this field is static, i.e. a class variable, meaning that only one
element map is created for the class and this is shared by all
XMLValidationLayer objects.
This characteristic (being a static/class variable) is causing one of the File
Manager unit tests to fail, as detailed below:
*****
The TestXMLValidationLayer#testGetElements test currently fails when doing a
full build/test of the File Manager component, with the following result:
Failed tests:
testGetElements(org.apache.oodt.cas.filemgr.validation.TestXMLValidationLayer):
There aren't exactly 4 elements in the test samples! expected:<4> but was:<11>
*****
This happens because the elementMap field in the XMLValidationLayer class is
static (i.e. a class variable), so any data assigned to it persists between
objects. When new data is written to the elementMap it is added or overwritten
depending on the value of the String key, but data isn't removed from it when
new XMLValidationLayer objects are created and all XMLValidationLayer objects
currently access the same elementMap. Earlier tests in the test sequence write
to elementMap from other elements.xml files (e.g.
src/test/resources/examples/core/elements.xml), and this data hangs around in
the class variable, so that when testGetElements is executed, there are already
11 elements present in elementMap.
I've experimented by removing the 'static' modifier from the elementMap,
subToSuperMap and productTypeElementMap fields. This causes each
XMLValidationLayer object to have its own elementMap. All
TestXMLValidationLayer tests now pass. Additionally, this change does not seem
to affect any other File Manager tests (all other tests pass).
Diffs
-----
trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/validation/XMLValidationLayer.java
1616362
Diff: https://reviews.apache.org/r/24429/diff/
Testing
-------
The individual test TestXMLValidationLayer#testGetElements was run and passed.
The full set of tests from TestXMLValidationLayer were run and passed. The
full set of tests from File Manager were run and passed. All of these steps
were carried out both at module level and top-level of the project.
Finally, a full build of OODT was carried out and completed successfully (all
tests passed).
Thanks,
Ross Laidlaw