View Javadoc

1   /**
2    * Copyright 2004-2012 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.db;
17  
18  import java.util.HashSet;
19  import java.util.List;
20  import java.util.Set;
21  
22  import org.springframework.context.ApplicationContext;
23  import org.springframework.context.support.ClassPathXmlApplicationContext;
24  
25  import junit.framework.TestCase;
26  import junit.textui.TestRunner;
27  
28  public class DatabaseUtilsTest extends TestCase {
29  	public static void main(String[] args) {
30  		TestRunner.run(DatabaseUtilsTest.class);
31  	}
32  
33  	@SuppressWarnings("unchecked")
34  	public void test1() {
35  		ApplicationContext ctx = new ClassPathXmlApplicationContext(JDBCUtils.JDBC_CONTEXT);
36  		List<JDBCConfiguration> databaseConfigs = (List<JDBCConfiguration>) ctx.getBean(JDBCUtils.JDBC_CONFIGURATIONS);
37  		assertNotNull(databaseConfigs);
38  	}
39  
40  	@SuppressWarnings("unchecked")
41  	public void test2() {
42  		ApplicationContext ctx = new ClassPathXmlApplicationContext(JDBCUtils.JDBC_CONTEXT);
43  		List<JDBCConfiguration> databaseConfigs = (List<JDBCConfiguration>) ctx.getBean(JDBCUtils.JDBC_CONFIGURATIONS);
44  		assertNotNull(databaseConfigs);
45  		DatabaseType[] typesArray = DatabaseType.values();
46  
47  		Set<DatabaseType> types = new HashSet<DatabaseType>();
48  		for (DatabaseType type : typesArray) {
49  			types.add(type);
50  		}
51  
52  		for (JDBCConfiguration databaseConfig : databaseConfigs) {
53  			assertTrue(types.contains(databaseConfig.getType()));
54  		}
55  
56  	}
57  }