View Javadoc

1   /*
2    * MultiInteractor_Test.java
3    *
4    * Created on July 24, 2007, 12:11 PM
5    *
6    * $Id: MultiInteractor_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfbase;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  import junit.framework.TestCase;
14  import org.lcsim.recon.tracking.trfutil.Assert;
15  
16  /**
17   *
18   * @author Norman Graf
19   */
20  public class MultiInteractor_Test extends TestCase
21  {
22      private boolean debug;
23      /** Creates a new instance of MultiInteractor_Test */
24      public void testMultiInteractor()
25      {
26          String component = "MultiInteractor";
27          String ok_prefix = component + " (I): ";
28          String error_prefix = component + " test (E): ";
29          
30          if(debug) System.out.println( ok_prefix
31                  + "---------- Testing component " + component
32                  + ". ----------" );
33          
34          //********************************************************************
35          
36          List multi_int = new ArrayList();
37          
38          Interactor inter1 = new InteractorTest(5.0);
39          Interactor inter2 = new InteractorTest(5.0);
40          
41          multi_int.add(inter1);
42          multi_int.add(inter2);
43          
44          if(debug) System.out.println("Test constructor."  );
45          
46          MultiInteractor mint = new MultiInteractor(multi_int);
47          
48          if(debug) System.out.println(mint);
49          
50          if(debug) System.out.println("Fetch the interactors..."  );
51          List ints = mint.getInteractors();
52          Assert.assertTrue( ints.size()==2);
53          Assert.assertTrue( ints.get(0).equals(inter1));
54          Assert.assertTrue( ints.get(1).equals(inter2));
55          
56          //**********************************************************************
57          
58          if(debug) System.out.println("Interact some tracks..."  );
59          // first... refer to tracks passed through MultiInteractor
60          // second... refer to tracks passed through inter1 and inter2
61          // finally, i should have err1(0,0)=err2(0,0)=25.
62          
63          TrackError firstError = new TrackError();
64          TrackError secondError = new TrackError();
65          
66          ETrack firstTrack = new ETrack();
67          ETrack secondTrack = new ETrack();
68          TrackError err = new TrackError();
69          
70          err.set(0,0 , 1.0);
71          firstTrack.setError(err);
72          secondTrack.setError(err);
73          
74          mint.interact(firstTrack);
75          
76          inter1.interact(secondTrack);
77          inter2.interact(secondTrack);
78          
79          Assert.assertTrue(firstTrack.error(0,0) == 25);
80          Assert.assertTrue(secondTrack.error(0,0) == 25);
81          
82          //**********************************************************
83          
84          if(debug) System.out.println(ok_prefix
85                  + "------------- All tests passed. -------------" );        
86      }
87      
88  }