Print

Print


Commit in lcsim/test/org/lcsim/conditions on MAIN
ConditionsManagerTest.java+37-341.7 -> 1.8
Fix broken test.  Only check the conditions for sidaug05 detectors that are known to have them.

lcsim/test/org/lcsim/conditions
ConditionsManagerTest.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- ConditionsManagerTest.java	2 Aug 2005 17:18:08 -0000	1.7
+++ ConditionsManagerTest.java	26 Sep 2005 22:40:50 -0000	1.8
@@ -23,90 +23,93 @@
 {
     private ConditionsManager _mgr;
     public List<String> testDets;
-    public final static String[] condNames =  {"TrackParameters","ClusterParameters","HitSmearing"};
+    public final static String[] condNames =  {"TrackParameters","ClusterParameters", "SamplingFractions/EMBarrel"/*,"HitSmearing","SamplingFractions"*/};
     
     /** Creates a new instance of ConditionsReaderTest */
-    public ConditionsManagerTest (String testName)
+    public ConditionsManagerTest(String testName)
     {
-        super (testName);
+        super(testName);
     }
     
-    public static Test suite ()
+    public static Test suite()
     {
-        return new TestSuite (ConditionsManagerTest.class);
+        return new TestSuite(ConditionsManagerTest.class);
     }
     
-    protected void setUp () throws Exception
+    protected void setUp() throws Exception
     {
-        _mgr = ConditionsManager.defaultInstance ();
+        _mgr = ConditionsManager.defaultInstance();
         
-        FileCache cache = new FileCache ();
-        File file = cache.getCachedFile (new URL ("http://lcsim.org/detectors/taglist.txt"));
-        BufferedReader reader = new BufferedReader (new FileReader (file));
+        FileCache cache = new FileCache();
+        File file = cache.getCachedFile(new URL("http://lcsim.org/detectors/taglist.txt"));
+        BufferedReader reader = new BufferedReader(new FileReader(file));
         testDets = new ArrayList<String>();
         for (;;)
         {
-            String line = reader.readLine ();
+            String line = reader.readLine();
             if (line == null) break;
-            testDets.add (line.trim ());
+                 
+            /* Only check the sidaug05 detectors that should have conditions. --JM */
+            if ( line.contains("sidaug05") && 
+                    !line.contains("_polyhedra") && 
+                    !line.contains("_gemhcal") )
+            {
+                testDets.add(line.trim());
+            }
         }
-        reader.close ();
+        reader.close();
     }
     
-    public void test_files () throws Exception
+    public void test_files() throws Exception
     {
         for (String detName : testDets )
         {
-            _mgr.setDetector (detName,0);
+            System.out.println("Checking conditions for detector " + detName + " ...");
+            
+            _mgr.setDetector(detName,0);
             
             // First check we have a compact description
             
-            RawConditions conditions = _mgr.getRawConditions ("compact.xml");
-            InputStream in = conditions.getInputStream ();
-            GeometryReader reader = new GeometryReader ();
-            Detector detector = (Detector) reader.read (in);
+            RawConditions conditions = _mgr.getRawConditions("compact.xml");
+            InputStream in = conditions.getInputStream();
+            GeometryReader reader = new GeometryReader();
+            Detector detector = (Detector) reader.read(in);
             
             for ( String s : condNames )
             {
                 try
                 {
-                    ConditionsSet cs = _mgr.getConditions (s);
+                    ConditionsSet cs = _mgr.getConditions(s);
                     if ( cs == null )
                     {
-                        throw new RuntimeException ("ConditionSet not found: " + s);
+                        throw new RuntimeException("ConditionSet not found: " + s);
                     }
                     else
                     {
-                        for ( Object o : cs.keySet () )
+                        for ( Object o : cs.keySet() )
                         {
-                            String k = o.toString ();
+                            String k = o.toString();
                             
-                            Class typ = cs.getType (k);
+                            Class typ = cs.getType(k);
                             if ( typ == double.class )
                             {
-                                double dblVal = cs.getDouble (k);
+                                double dblVal = cs.getDouble(k);
                             }
                             if ( typ == int.class )
                             {
-                                int intVal = cs.getInt (k);
+                                int intVal = cs.getInt(k);
                             }
                             else if ( typ == java.lang.String.class )
                             {
-                                String strVal = cs.getString (k);
+                                String strVal = cs.getString(k);
                             }
                             
                         }
                     }
                 }
-                catch (ConditionsSetNotFoundException csnf)
-                {
-                    // Currently we only demand that sdjan03 has valid parameters
-                    if ("sdjan03".equals (detName)) throw csnf;
-                    //System.err.println("Warning: "+detName+" has no "+s);
-                }
                 catch (IllegalArgumentException iae)
                 {
-                    throw new RuntimeException ("Bad key to ConditionsSet.getX() function.", iae);
+                    throw new RuntimeException("Bad key to ConditionsSet.getX() function.", iae);
                 }
             }
         }
CVSspam 0.2.8