Author: [log in to unmask]
Date: Tue Mar 24 15:23:22 2015
New Revision: 2526
Log:
Use file cache to make test portable.
Modified:
java/trunk/evio/pom.xml
java/trunk/evio/src/test/java/org/hps/evio/EpicsScalarDataTest.java
Modified: java/trunk/evio/pom.xml
=============================================================================
--- java/trunk/evio/pom.xml (original)
+++ java/trunk/evio/pom.xml Tue Mar 24 15:23:22 2015
@@ -35,7 +35,6 @@
<exclude>org/hps/evio/LCSimEngRunEventBuilderTest.java</exclude>
<exclude>org/hps/evio/SvtEvioReaderTest.java</exclude>
<exclude>org/hps/evio/TestRunSvtEvioReaderTest.java</exclude>
- <exclude>org/hps/evio/EpicsScalarDataTest.java</exclude>
</excludes>
<trimStackTrace>true</trimStackTrace>
</configuration>
Modified: java/trunk/evio/src/test/java/org/hps/evio/EpicsScalarDataTest.java
=============================================================================
--- java/trunk/evio/src/test/java/org/hps/evio/EpicsScalarDataTest.java (original)
+++ java/trunk/evio/src/test/java/org/hps/evio/EpicsScalarDataTest.java Tue Mar 24 15:23:22 2015
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import junit.framework.TestCase;
@@ -16,34 +17,50 @@
import org.hps.record.evio.EvioDetectorConditionsProcessor;
import org.lcsim.event.EventHeader;
import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCIODriver;
import org.lcsim.util.loop.LCSimLoop;
+import org.lcsim.util.test.TestUtil.TestOutputFile;
+/**
+ * Test of reading EPICs scalar data from EVIO and writing it out to LCIO.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
public class EpicsScalarDataTest extends TestCase {
+ static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps-java/ScalarsTest/hpsecal_004469_1000_events.evio.0";
+
public void test() throws IOException {
+ // Cache input data file.
+ FileCache cache = new FileCache();
+ File inputFile = cache.getCachedFile(new URL(TEST_FILE_URL));
+
+ // Setup conditions and event building.
DatabaseConditionsManager manager = new DatabaseConditionsManager();
LCSimEventBuilder builder = new LCSimEngRunEventBuilder();
manager.addConditionsListener(builder);
+ // Setup and run the loop to write out LCIO events with the EPICS scalar data.
CompositeLoopConfiguration configuration = new CompositeLoopConfiguration();
configuration.add(new EpicsEvioProcessor());
configuration.setDataSourceType(DataSourceType.EVIO_FILE);
- //configuration.setFilePath("/u1/data/hps/eng_run/hps_004385.evio.0");
configuration.add(new EvioDetectorConditionsProcessor("HPS-ECalCommissioning-v2"));
configuration.setLCSimEventBuilder(builder);
- configuration.setFilePath("/work/data/hps/engrun/hps_004385.evio.0");
+ configuration.setFilePath(inputFile.getPath());
configuration.setProcessingStage(ProcessingStage.LCIO);
configuration.setStopOnEndRun(false);
configuration.setStopOnErrors(false);
- configuration.add(new LCIODriver("EpicsScalarDataTest"));
+ File outputFile = new TestOutputFile("EpicsScalarDataTest.slcio");
+ configuration.add(new LCIODriver(outputFile.getPath()));
CompositeLoop loop = new CompositeLoop();
loop.setConfiguration(configuration);
- loop.loop(100);
+ loop.loop(100);
+ // Read back and print out the scalar data.
LCSimLoop readLoop = new LCSimLoop();
- readLoop.setLCIORecordSource(new File("EpicsScalarDataTest.slcio"));
+ readLoop.setLCIORecordSource(outputFile);
readLoop.add(new Driver() {
public void process(EventHeader event) {
EpicsScalarData data = EpicsScalarData.read(event);
@@ -52,8 +69,7 @@
System.out.println(data.toString());
}
}
- });
-
+ });
readLoop.loop(-1);
}
|