View Javadoc
1   /**
2    * Copyright 2005-2015 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.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  }