LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  September 2015

HPS-SVN September 2015

Subject:

r3534 - /java/trunk/conditions/src/test/java/org/hps/conditions/database/DatabaseConditionsManagerTest.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Sat, 5 Sep 2015 00:11:33 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (140 lines)

Author: [log in to unmask]
Date: Fri Sep  4 17:11:30 2015
New Revision: 3534

Log:
Add a test that performs sanity checks on the DatabaseConditionsManager.

Added:
    java/trunk/conditions/src/test/java/org/hps/conditions/database/DatabaseConditionsManagerTest.java

Added: java/trunk/conditions/src/test/java/org/hps/conditions/database/DatabaseConditionsManagerTest.java
 =============================================================================
--- java/trunk/conditions/src/test/java/org/hps/conditions/database/DatabaseConditionsManagerTest.java	(added)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/database/DatabaseConditionsManagerTest.java	Fri Sep  4 17:11:30 2015
@@ -0,0 +1,124 @@
+package org.hps.conditions.database;
+
+import java.util.logging.Level;
+
+import junit.framework.TestCase;
+
+import org.hps.conditions.api.ConditionsRecord.ConditionsRecordCollection;
+import org.hps.conditions.api.ConditionsSeries;
+import org.hps.conditions.ecal.EcalCalibration.EcalCalibrationCollection;
+import org.hps.conditions.svt.SvtTimingConstants.SvtTimingConstantsCollection;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.geometry.Detector;
+
+/**
+ * General test of the {@link DatabaseConditionsManager} class.
+ * 
+ * @author Jeremy McCormick, SLAC
+ * @see DatabaseConditionsManager
+ */
+public class DatabaseConditionsManagerTest extends TestCase {
+    
+    /**
+     * Perform basic tests of the database conditions manager.
+     * 
+     * @throws Exception if any error is thrown
+     */
+    public void testDatabaseConditionsManager() throws Exception {
+        
+        DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance();
+        manager.setLogLevel(Level.ALL);
+        
+        // Check initial state.
+        TestCase.assertTrue("The conditions manager instance is null.", manager != null);        
+        TestCase.assertFalse("The manager should not be connected.", manager.isConnected());        
+        TestCase.assertFalse("The manager should not be initialized.", manager.isInitialized());        
+        TestCase.assertFalse("The manager should not be frozen.", manager.isFrozen());        
+        TestCase.assertTrue("The manager should be setup.", ConditionsManager.isSetup());
+        
+        // Open database connection.
+        manager.openConnection();
+        
+        // Check that a new collection can be created.
+        EcalCalibrationCollection newCollection = manager.newCollection(EcalCalibrationCollection.class, "ecal_calibrations");
+        TestCase.assertNotNull("New collection should have metadata.", newCollection.getTableMetaData());
+                
+        // Check connection state.
+        TestCase.assertTrue("The manager should be connected.", manager.isConnected());        
+        TestCase.assertNotNull("The connection is null.", manager.getConnection());
+        
+        // Turn of SVT detector setup becaues some classes are not available from this module.
+        manager.setXmlConfig("/org/hps/conditions/config/conditions_database_no_svt.xml");    
+        
+        // Initialize the conditions system.
+        manager.setDetector("HPS-EngRun2015-Nominal-v2", 5772);
+        
+        // Check basic state after initialization.
+        TestCase.assertFalse("Manager should not be configured for test run.", manager.isTestRun());        
+        TestCase.assertTrue("The manager should be initialized.", manager.isInitialized());
+        
+        // Make sure that freezing the conditions system works properly.
+        manager.freeze();        
+        TestCase.assertTrue("The manager should be frozen.", manager.isFrozen());                
+        manager.setDetector("HPS-EngRun2015-Nominal-v2", 1234);        
+        TestCase.assertEquals("The run number should be the same because system was frozen.", 5772, manager.getRun());
+        
+        // Check detector object state.
+        Detector detector = manager.getDetectorObject();
+        TestCase.assertNotNull("The detector is null.", detector);
+        TestCase.assertNotNull("The ECal conditions are null.", manager.getEcalConditions());        
+        TestCase.assertNotNull("The ECal name is null.", manager.getEcalName());        
+        TestCase.assertNotNull("The ECal subdetector is null.", manager.getEcalSubdetector());        
+        TestCase.assertNotNull("The SVT conditions are null.", manager.getSvtConditions());        
+        
+        // Load a test collection.
+        EcalCalibrationCollection testCollection = manager.getCachedConditions(EcalCalibrationCollection.class, "ecal_calibrations").getCachedData();
+        TestCase.assertTrue("The test collection should not be empty.", testCollection.size() > 0);
+        
+        // Load a conditions series.
+        ConditionsSeries<?, ?> series = manager.getConditionsSeries(EcalCalibrationCollection.class, "ecal_calibrations");
+        TestCase.assertTrue("The conditions series should not be empty.", !series.isEmpty());
+                                               
+        // Set a tag and check that it seems to work properly (not very detailed).
+        TestCase.assertFalse("There should be available tags.", manager.getAvailableTags().isEmpty());
+        TestCase.assertTrue("The pass1 tag should be available.", manager.getAvailableTags().contains("pass1"));        
+        manager.addTag("pass1");
+        TestCase.assertFalse("There should be an active tag.", manager.getActiveTags().isEmpty());
+        manager.setDetector("HPS-EngRun2015-Nominal-v2", 5772);
+        SvtTimingConstantsCollection testTagCollection = manager.getCachedConditions(SvtTimingConstantsCollection.class, "svt_timing_constants").getCachedData();
+        TestCase.assertTrue("The collection should not be empty.", testTagCollection.size() > 0);                        
+        manager.clearTags();
+        TestCase.assertTrue("The tags should be cleared.", manager.getActiveTags().isEmpty());
+        
+        // See that some conditions records are available.
+        ConditionsRecordCollection conditionsRecords = manager.getConditionsRecords();
+        TestCase.assertTrue("Conditions records should have been found.", conditionsRecords.size() > 0);               
+        conditionsRecords = manager.findConditionsRecords("ecal_calibrations");
+        TestCase.assertTrue("A conditions record should have been found.", conditionsRecords.size() > 0);        
+        TestCase.assertTrue("A conditions record should exist.", manager.hasConditionsRecord("ecal_calibrations"));
+        TestCase.assertNotNull("Table meta data should exist for collection.", manager.findTableMetaData("ecal_calibrations"));
+        
+        // Un-freeze the conditions system.
+        manager.unfreeze();
+        TestCase.assertFalse("Manager should not be frozen.", manager.isFrozen());
+        
+        // Load Test Run setup.
+        manager.setDetector("HPS-TestRun-v8-5", 1365);
+        TestCase.assertEquals("Run number should have changed.", manager.getRun(), 1365);        
+        TestCase.assertTrue("Manager should be configured for test run.", manager.isTestRun());
+                       
+        // Check SLAC connection setup.
+        manager.closeConnection();
+        manager.setConnectionResource("/org/hps/conditions/config/slac_connection.prop");
+        manager.openConnection();
+        TestCase.assertTrue("Connection should be slac host.", manager.getConnection().getMetaData().getURL().contains("slac"));
+        
+        // Check JLAB connection setup.
+        manager.closeConnection();
+        manager.setConnectionResource("/org/hps/conditions/config/jlab_connection.prop");
+        manager.openConnection();
+        TestCase.assertTrue("Connection should be slac host.", manager.getConnection().getMetaData().getURL().contains("jlab"));
+        
+        manager.closeConnection();
+    }
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use