View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    * 
7    * http://www.osedu.org/licenses/ECL-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
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   * @author Joe Swanson <joseswan@umich.edu>
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       * @return the applicationContext
38       */
39      public static ApplicationContext getApplicationContext() {
40          return applicationContext;
41      }
42  
43      /**
44       * @param aApplicationContext the applicationContext to set
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  }