Commit in hps-java/src/test/java/org/lcsim/hps/conditions on MAIN | |||
DatabaseConditionsReaderTest.java | +52 | added 1.1 |
simplistic test of Dima's sample DatabaseConditionsReader class; this functions as an example of how to use this class to load and create conditions using a MySQL database
diff -N DatabaseConditionsReaderTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DatabaseConditionsReaderTest.java 17 Sep 2013 23:25:49 -0000 1.1 @@ -0,0 +1,52 @@
+package org.lcsim.hps.conditions; + +import java.io.PrintStream; + +import junit.framework.TestCase; + +import org.lcsim.conditions.ConditionsManager; +import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; +import org.lcsim.conditions.ConditionsSet; + +/** + * This class tests that the example DatabaseConditionsReader authored by Dima + * actually works with a test detector. + * @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 = 0; + + /* Name of conditions set. */ + private final String conditionsSetName = "calibration"; + + /* 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 + * a Calibration object from the database rows. + */ + public void test() { + ConditionsManager manager = ConditionsManager.defaultInstance(); + try { + manager.setDetector(detectorName, runNumber); + } catch (ConditionsNotFoundException e) { + throw new RuntimeException(e); + } + ConditionsSet conditions = manager.getConditions(conditionsSetName); + ps.println("Got conditions " + conditionsSetName + " of size " + conditions.size()); + ps.println("table: " + conditions.getString("table")); + ps.println("column: " + conditions.getString("column")); + ps.println("id: " + conditions.getString("id")); + CalibrationConverter calibrationConverter = new CalibrationConverter(); + Calibration calibration = calibrationConverter.getData(manager, null); + ps.println("Fetched calibration conditions: "); + ps.println(calibration.toString()); + } +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1