View Javadoc

1   /**
2    * Copyright 2010-2013 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.common.util.config.service;
17  
18  import java.io.File;
19  import java.util.ArrayList;
20  import java.util.Arrays;
21  import java.util.List;
22  import java.util.Properties;
23  
24  import org.junit.Ignore;
25  import org.junit.Test;
26  
27  @Deprecated
28  public class DefaultProjectConfigServiceTest {
29  
30  	@Test
31  	public void testIt() {
32  
33  		try {
34  			String groupId = "org.kuali.common";
35  			String artifactId = "kuali-util";
36  			String contextId = "scm";
37  			String configId = org.kuali.common.util.config.ConfigUtils.getConfigId(groupId, artifactId, contextId);
38  			org.kuali.common.util.Project project = org.kuali.common.util.ProjectUtils.loadProject(groupId, artifactId);
39  			ConfigService service = new DefaultConfigService();
40  			Properties properties = service.getProperties(configId, project.getProperties());
41  			System.out.println("scm.service=" + properties.getProperty("scm.service"));
42  		} catch (Exception e) {
43  			e.printStackTrace();
44  		}
45  	}
46  
47  	@Test
48  	@Ignore
49  	public void test() {
50  
51  		try {
52  			org.kuali.common.util.config.ContextConfig mpx = new org.kuali.common.util.config.ContextConfig("mpx", Arrays.asList(new org.kuali.common.util.config.Location("${metainf.common}/mpx.properties")));
53  			org.kuali.common.util.config.ContextConfig sql = new org.kuali.common.util.config.ContextConfig("sql", Arrays.asList(new org.kuali.common.util.config.Location("${metainf.common}/sql.properties")));
54  			org.kuali.common.util.config.ContextConfig metainf = new org.kuali.common.util.config.ContextConfig("metainf");
55  			metainf.setContexts(Arrays.asList(mpx, sql));
56  			List<org.kuali.common.util.config.ContextConfig> contexts = new ArrayList<org.kuali.common.util.config.ContextConfig>();
57  			contexts.add(metainf);
58  
59  			List<org.kuali.common.util.config.Location> locations = new ArrayList<org.kuali.common.util.config.Location>();
60  			locations.add(new org.kuali.common.util.config.Location("${classpath.prefix}/sql.xml"));
61  			org.kuali.common.util.config.ProjectConfigContainer config = new org.kuali.common.util.config.ProjectConfigContainer();
62  			config.setGroupId("org.kuali.common");
63  			config.setArtifactId("kuali-util");
64  			config.setLocations(locations);
65  			config.setContexts(contexts);
66  			DefaultConfigService service = new DefaultConfigService();
67  			File file = new File("/tmp/metadata.xml");
68  			service.store(file, config);
69  		} catch (Exception e) {
70  			e.printStackTrace();
71  		}
72  	}
73  
74  }