java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions
--- java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions/ConditionsDriverTest.java 2013-12-03 21:39:46 UTC (rev 63)
+++ java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions/ConditionsDriverTest.java 2013-12-03 21:43:44 UTC (rev 64)
@@ -1,97 +0,0 @@
-package org.lcsim.hps.conditions;
-
-import java.io.File;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.lcsim.detector.tracker.silicon.HpsSiSensor;
-import org.lcsim.event.EventHeader;
-import org.lcsim.geometry.Detector;
-import org.lcsim.util.Driver;
-import org.lcsim.util.cache.FileCache;
-import org.lcsim.util.loop.LCSimLoop;
-
-/**
- * This class tests that {@link org.lcsim.hps.conditions.ConditionsDriver} works correctly.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class ConditionsDriverTest extends TestCase {
-
- /** This test file has a few events from the "good runs" of the Test Run. */
- private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
-
- /** Answer key for number of bad channels by run. */
- static Map<Integer,Integer> badChannelAnswerKey = new HashMap<Integer,Integer>();
-
- /** Setup the bad channel answer key by run. */
- static {
- badChannelAnswerKey.put(1351, 441);
- badChannelAnswerKey.put(1353, 473);
- badChannelAnswerKey.put(1354, 474);
- badChannelAnswerKey.put(1358, 344);
- badChannelAnswerKey.put(1359, 468);
- badChannelAnswerKey.put(1360, 468);
- }
-
- /** This is the number of bad channels in the QA set for all runs. */
- static int BAD_CHANNELS_QA_ANSWER = 50;
-
- /**
- * Run the test.
- * @throws Exception
- */
- public void test() throws Exception {
-
- // Cache file locally from URL.
- FileCache cache = new FileCache();
- File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
-
- // Run the ConditionsDriver over test data containing multiple runs from the Test Run.
- LCSimLoop loop = new LCSimLoop();
- loop.setLCIORecordSource(testFile);
- loop.add(new ConditionsDriver());
- loop.add(new SvtBadChannelChecker());
- loop.loop(-1, null);
- }
-
- /**
- * This Driver will check the number of bad channels for a run against the answer key.
- * @author Jeremy McCormick <[log in to unmask]>
- */
- class SvtBadChannelChecker extends Driver {
-
- int currentRun = Integer.MIN_VALUE;
-
- /**
- * This method will check the number of bad channels against the answer key
- * for the first event of a new run.
- */
- public void process(EventHeader event) {
- int run = event.getRunNumber();
- if (run != currentRun) {
- currentRun = run;
- Detector detector = event.getDetector();
- int badChannels = 0;
- List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
- for (HpsSiSensor sensor : sensors) {
- int nchannels = sensor.getNumberOfChannels();
- for (int i=0; i<nchannels; i++) {
- if (sensor.isBadChannel(i))
- ++badChannels;
- }
- }
- System.out.println("Run " + currentRun + " has " + badChannels + " SVT bad channels.");
- Integer badChannelAnswer = badChannelAnswerKey.get(run);
- if (badChannelAnswer != null) {
- TestCase.assertEquals("Wrong number of bad channels found.", (int)badChannelAnswer, (int)badChannels);
- } else {
- TestCase.assertEquals("Wrong number of bad channels found.", (int)BAD_CHANNELS_QA_ANSWER, (int)badChannels);
- }
- }
- }
- }
-}
\ No newline at end of file
java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions
--- java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions/DatabaseConditionsReaderTest.java 2013-12-03 21:39:46 UTC (rev 63)
+++ java/trunk/hps-java/src/test/java/org/lcsim/hps/conditions/DatabaseConditionsReaderTest.java 2013-12-03 21:43:44 UTC (rev 64)
@@ -1,46 +0,0 @@
-package org.lcsim.hps.conditions;
-
-import java.io.PrintStream;
-
-import junit.framework.TestCase;
-
-import org.lcsim.conditions.CachedConditions;
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
-
-/**
- * This class tests the DatabaseConditionsReader on dummy data.
- *
- * @author jeremym
- */
-public class DatabaseConditionsReaderTest extends TestCase {
-
- /** Example detector from hps-detectors. */
- private final String detectorName = "HPS-conditions-test";
-
- /** Run number of conditions set. */
- private final int runNumber = 777;
-
- /** Print output. */
- private final PrintStream ps = System.out;
-
- /**
- * Create the manager, load the detector, and then get the conditions meta-data
- * for the selected conditions set. Finally, use the sample converter to create
- * an SvtCalibrationConstants object from the database rows.
- */
- public void test() {
- ConditionsManager manager = ConditionsManager.defaultInstance();
- try {
- manager.setDetector(detectorName, runNumber);
- } catch (ConditionsNotFoundException e) {
- throw new RuntimeException(e);
- }
-
- CachedConditions<ConditionsRecordCollection> c2 = manager.getCachedConditions(ConditionsRecordCollection.class, "conditions_records");
- ConditionsRecordCollection rc = c2.getCachedData();
- for (ConditionsRecord r : rc) {
- ps.println(r.toString());
- }
- }
-}