View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }