//
//  TestAcceleratorSeq.java
//  xal
//
//  Created by Tom Pelaia on 8/24/2011.
//  Copyright 2011 Oak Ridge National Lab. All rights reserved.
//

package xal.smf;

import xal.smf.data.XMLDataManager;
import xal.smf.impl.*;
import xal.smf.impl.qualify.*;

import java.util.*;
import java.net.URL;
import org.junit.*;


/** test the AcceleratorSeq class */
public class TestAcceleratorSeq {
    /** default accelerator */
    final private Accelerator DEFAULT_ACCELERATOR;
    
    
    /** Constructor */
    public TestAcceleratorSeq() {
        final URL opticsURL = getClass().getResource( "/xal/config/main.xal" );
        DEFAULT_ACCELERATOR = opticsURL != null ? XMLDataManager.getInstance( opticsURL ).getAccelerator() : null;
    }
    
    
    @Test
    /** test that we got a default accelerator */
    public void testForDefaultAccelerator() {
        Assert.assertTrue( DEFAULT_ACCELERATOR != null );
    }
    
    
    @Test
    /** test fetching nodes by type and verify that we got just that type */
    public void testNodeFetchingByType() {
        final AcceleratorSeq ring = DEFAULT_ACCELERATOR.findSequence( "Ring" );
        final List<AcceleratorNode> nodes = ring.getNodesOfType( "BPM" );
        Assert.assertTrue( nodes.size() > 0 );
        for ( final AcceleratorNode node : nodes ) {
            Assert.assertTrue( node instanceof BPM );
        }
    }
    
    
    @Test
    /** test fetching nodes by qualifier using a strong typing during the fetch */
    public void testNodeFetchingByStrongType() {
        final AcceleratorSeq ring = DEFAULT_ACCELERATOR.findSequence( "Ring" );
        final List<BPM> nodes = ring.getNodesOfClassWithStatus( BPM.class, true );
        Assert.assertTrue( nodes.size() > 0 );
        for ( final BPM node : nodes ) {
            Assert.assertTrue( node instanceof BPM );
        }
    }
}
@@ -421,21 +421,22 @@
  */%0A    
-final
+static
  private
@@ -487,56 +487,55 @@
     
-/** Constructor */%0A    public TestAcceleratorSeq
+@BeforeClass%0A    public static void commonSetup
 () %7B
@@ -569,18 +569,32 @@
 L = 
-getC
+TestAcceleratorSeq.c
 lass
-()
 .get
@@ -752,32 +752,141 @@
     %7D%0A    %0A    %0A
+    @AfterClass%0A    public static void commonCleanup() %7B%0A        DEFAULT_ACCELERATOR = null;%0A    %7D%0A    %0A    %0A
     @Test%0A    /*

Load the accelerator once for the Accelerator sequence test suite.