1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  package org.kuali.mobility.bus.dao;
16  
17  import org.apache.log4j.Logger;
18  import org.junit.AfterClass;
19  import org.junit.Test;
20  import static org.junit.Assert.*;
21  import org.junit.BeforeClass;
22  import org.kuali.mobility.bus.entity.Bus;
23  import org.springframework.context.ApplicationContext;
24  import org.springframework.context.support.FileSystemXmlApplicationContext;
25  
26  
27  
28  
29  
30  public class BusDaoUMImplTest {
31      
32  	private static final Logger LOG = Logger.getLogger( BusDaoUMImplTest.class );
33  	
34  	private static ApplicationContext applicationContext;
35  
36      
37  
38  
39      public static ApplicationContext getApplicationContext() {
40          return applicationContext;
41      }
42  
43      
44  
45  
46      public static void setApplicationContext(ApplicationContext aApplicationContext) {
47          applicationContext = aApplicationContext;
48      }
49  	
50      public BusDaoUMImplTest() {
51      }
52  
53      @BeforeClass
54      public static void setUpClass() throws Exception {
55      	BusDaoUMImplTest.setApplicationContext(new FileSystemXmlApplicationContext(getConfigLocations()));
56      }
57  
58      private static String[] getConfigLocations() {
59          return new String[] { "classpath:/BusSpringBeans.xml" };
60      }
61  
62      @AfterClass
63      public static void tearDownClass() throws Exception {
64      }
65  
66      @Test
67      public void testLoadRoutes() {
68  		BusDaoUMImpl dao = (BusDaoUMImpl)getApplicationContext().getBean("busDao");
69          dao.loadRoutes();
70          
71  		assertTrue( "Failed to find bus routes.", dao.getBusRoutes() != null );
72      }
73      
74      @Test
75      public void testLoadBusLocations() {
76  		BusDaoUMImpl dao = (BusDaoUMImpl)getApplicationContext().getBean("busDao");
77          dao.loadBusLocations();
78          
79          if( dao.getBuses() != null ) {
80              for( Bus b : dao.getBuses() ) {
81                  LOG.debug( "Bus: "+b.getId()+" : "+b.getRouteName()+" loaded.");
82              }
83          }
84          
85  		assertTrue( "Failed to find bus routes.", dao.getBuses() != null );
86      }
87  }