1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.data.provider;
17
18 import org.apache.log4j.BasicConfigurator;
19 import org.apache.log4j.Level;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.kuali.rice.krad.data.metadata.DataObjectMetadata;
25 import org.kuali.rice.krad.data.jpa.testbo.TestDataObject;
26 import org.kuali.rice.krad.data.provider.spring.SpringMetadataProviderImpl;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31 public class SpringMetadataProviderImplTest {
32
33 SpringMetadataProviderImpl provider;
34
35 @BeforeClass
36 public static void setUpBeforeClass() throws Exception {
37 BasicConfigurator.configure();
38 org.apache.log4j.Logger.getLogger(SpringMetadataProviderImpl.class).setLevel(Level.DEBUG);
39 }
40
41 @Before
42 public void setUp() throws Exception {
43 provider = new SpringMetadataProviderImpl();
44 }
45
46 @Test
47 public void testInitializeMetadata() {
48 List<String> springFileLocations = new ArrayList<String>();
49 springFileLocations.add("classpath:org/kuali/rice/krad/data/provider/spring/krad-metadata-parent-beans.xml");
50 springFileLocations.add("classpath:org/kuali/rice/krad/data/provider/spring/*");
51 provider.setResourceLocations(springFileLocations);
52 provider.initializeMetadata(null);
53 Assert.assertNotNull("Metadata map should not be null", provider.provideMetadata());
54 Assert.assertFalse("Metadata map should not have been empty", provider.provideMetadata().isEmpty());
55 DataObjectMetadata metadata = provider.provideMetadata().get(TestDataObject.class);
56 Assert.assertNotNull("Metadata should have been retrieved for TestDataObject", metadata);
57 Assert.assertEquals("Label not read properly from metadata provider", "A Spring-Provided Label",
58 metadata.getLabel());
59 Assert.assertEquals("backing object name not read properly from metadata provider", "ANOTHER_TABLE_NAME_T",
60 metadata.getBackingObjectName());
61 }
62
63 }