1 package org.kuali.common.jdbc.service.spring;
2
3 import java.util.Arrays;
4
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.kuali.common.jdbc.vendor.model.VendorDefault;
8 import org.kuali.common.jdbc.vendor.spring.DatabaseVendorConfig;
9 import org.kuali.common.util.CollectionUtils;
10 import org.kuali.common.util.spring.SpringExecUtils;
11 import org.kuali.common.util.spring.service.SpringContext;
12 import org.kuali.common.util.spring.service.SpringService;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.core.env.PropertySource;
15 import org.springframework.test.context.ContextConfiguration;
16 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
17
18 @RunWith(SpringJUnit4ClassRunner.class)
19 @ContextConfiguration(classes = DatabaseVendorsPropertySourceConfig.class)
20 public class DatabaseVendorsConfigTest {
21
22 @Autowired
23 PropertySource<?> source;
24
25 @Autowired
26 SpringService service;
27
28 @Test
29 public void test() {
30 try {
31 String vendorString = (String) source.getProperty("db.vendor");
32 VendorDefault vendor = VendorDefault.valueOf(vendorString.toUpperCase());
33 String profile = vendor.getCode();
34 SpringContext context = SpringExecUtils.getSinglePropertySourceContext(source);
35 context.setAnnotatedClasses(CollectionUtils.asList(DatabaseVendorConfig.class));
36 context.setActiveProfiles(Arrays.asList(profile));
37 service.load(context);
38 } catch (Exception e) {
39 e.printStackTrace();
40 }
41 }
42
43 }