1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.jdbc.supplier;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
21
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.test.context.ContextConfiguration;
28 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
29
30 import static junit.framework.Assert.assertEquals;
31 import static junit.framework.Assert.assertTrue;
32
33 @RunWith(SpringJUnit4ClassRunner.class)
34 @ContextConfiguration(locations = { "classpath:org/kuali/common/jdbc/location-supplier-test-context.xml" })
35 public class LocationSupplierFactoryBeanTest {
36
37 private static final Logger logger = LoggerFactory.getLogger(LocationSupplierFactoryBeanTest.class);
38
39 @Autowired
40 LocationSuppliersFactoryBean factoryBean;
41
42 @Test
43 public void test() throws Exception {
44 logger.info("Context loaded");
45
46 List<LocationSupplier> suppliers = factoryBean.getObject();
47
48 assertEquals(2, suppliers.size());
49
50 Collection<String> expectedLocations = new ArrayList<String>(2);
51 expectedLocations.add("classpath:org/kuali/common/jdbc/test1.sql");
52 expectedLocations.add("classpath:org/kuali/common/jdbc/test2.sql");
53
54 for(LocationSupplier supplier : suppliers) {
55 expectedLocations.remove(supplier.getLocation());
56 }
57
58 assertTrue("All expected locations were not accounted for", expectedLocations.isEmpty());
59 }
60 }