1 package org.kuali.db;
2
3 import java.util.HashSet;
4 import java.util.List;
5 import java.util.Set;
6
7 import org.springframework.context.ApplicationContext;
8 import org.springframework.context.support.ClassPathXmlApplicationContext;
9
10 import junit.framework.TestCase;
11 import junit.textui.TestRunner;
12
13 public class DatabaseUtilsTest extends TestCase {
14 public static void main(String[] args) {
15 TestRunner.run(DatabaseUtilsTest.class);
16 }
17
18 @SuppressWarnings("unchecked")
19 public void test1() {
20 ApplicationContext ctx = new ClassPathXmlApplicationContext(JDBCUtils.JDBC_CONTEXT);
21 List<JDBCConfiguration> databaseConfigs = (List<JDBCConfiguration>) ctx.getBean(JDBCUtils.JDBC_CONFIGURATIONS);
22 assertNotNull(databaseConfigs);
23 }
24
25 @SuppressWarnings("unchecked")
26 public void test2() {
27 ApplicationContext ctx = new ClassPathXmlApplicationContext(JDBCUtils.JDBC_CONTEXT);
28 List<JDBCConfiguration> databaseConfigs = (List<JDBCConfiguration>) ctx.getBean(JDBCUtils.JDBC_CONFIGURATIONS);
29 assertNotNull(databaseConfigs);
30 DatabaseType[] typesArray = DatabaseType.values();
31
32 Set<DatabaseType> types = new HashSet<DatabaseType>();
33 for (DatabaseType type : typesArray) {
34 types.add(type);
35 }
36
37 for (JDBCConfiguration databaseConfig : databaseConfigs) {
38 assertTrue(types.contains(databaseConfig.getType()));
39 }
40
41 }
42 }