...
Accessing Test Data
Class Resources
Test data can be embedded into the test classes package directory and then accessed as a stream. (This is built-in Java functionality.)
For example, here is an example of accessing an XML file as a stream, based on org.lcsim.geometry.GeometryReaderTest in the GeomConverter package.
No Format |
---|
InputStream in = GeometryReaderTest.class.getResourceAsStream("GeometryReaderTest.xml");
GeometryReader reader = new GeometryReader();
detector = reader.read(in);
|
This technique should be used for data that is small (< 1 MB). Generally, we only embed text files such as XML into the jar files.
File Cache
For data that is too large to embed into the org.lcsim jar file, the file cache can be used to download and access files.
...
No Format |
---|
LCSimLoop loop = new LCSimLoop(); loop.setLCIORecordSource(file); loop.add(new MyTestDriver()); loop.loop(maxEvents-1); loop.dispose(); |
Replace "MyTestDriver" with an actual driver you are trying to test.
Passing -1 to the loop command will process all the events in the Lcio file.
A Real Example
...
For an example test case, look at HitPositionTest in the org.lcsim package. It illustrates a number of the concepts covered in this document.