1 package org.kuali.mobility.maps.service; 2 3 import static org.junit.Assert.*; 4 5 import org.apache.log4j.Logger; 6 import org.junit.Before; 7 import org.junit.Test; 8 import org.kuali.mobility.maps.entity.Location; 9 import org.kuali.mobility.maps.entity.MapsGroup; 10 import org.springframework.context.ApplicationContext; 11 import org.springframework.context.support.FileSystemXmlApplicationContext; 12 13 public class MapsServiceImplTest { 14 private static final Logger LOG = Logger.getLogger(MapsServiceImplTest.class); 15 ApplicationContext applicationContext; 16 17 public ApplicationContext getApplicationContext() { 18 return this.applicationContext; 19 } 20 public void setApplicationContext(ApplicationContext applicationContext) { 21 this.applicationContext = applicationContext; 22 } 23 24 @Before 25 public void setUpClass() throws Exception { 26 setApplicationContext(new FileSystemXmlApplicationContext(getConfigLocations())); 27 } 28 29 private String[] getConfigLocations() { 30 return new String[] { "classpath:/KMESpringBeans.xml" }; 31 } 32 33 @Test 34 public void testGetMapsGroupById() { 35 MapsServiceImpl service = (MapsServiceImpl)getApplicationContext().getBean("mapsService"); 36 MapsGroup mapGroup = service.getMapsGroupById("ZZZZ"); 37 assertTrue("Should not find a map group with ID ZZZZ", mapGroup == null); 38 mapGroup = service.getMapsGroupById("UA"); 39 assertTrue("Should find a map group with ID UA", mapGroup != null); 40 } 41 42 @Test 43 public void testGetLocationById() { 44 MapsServiceImpl service = (MapsServiceImpl)getApplicationContext().getBean("mapsService"); 45 Location location = service.getLocationById("ZZZZ"); 46 assertTrue("Should not find a location with ID ZZZZ", location == null); 47 location = service.getLocationById("SB"); 48 assertTrue("Should find a location with ID SB", location != null); 49 } 50 }