1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }