ActivitySpec - Correcting logger messages
[sdc.git] / common / openecomp-common-configuration-management / openecomp-configuration-management-test / src / test / java / org / openecomp / config / test / ConfigSourceLocationTest.java
1 package org.openecomp.config.test;
2
3 import org.openecomp.config.api.Configuration;
4 import org.openecomp.config.api.ConfigurationManager;
5 import org.openecomp.config.util.ConfigTestConstant;
6 import org.openecomp.config.util.TestUtil;
7 import org.junit.After;
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.junit.Assert;
11
12 import java.io.File;
13 import java.io.IOException;
14 import java.util.Properties;
15 import java.io.OutputStream;
16 import java.io.FileOutputStream;
17
18 /**
19  * Created by sheetalm on 10/14/2016.
20  * Scenario 11
21  * Validate conventional and configurational source location
22  *
23  * Pre-requisite - set -Dconfig.location=${"user.home"}/TestResources/ while running test
24  */
25 public class ConfigSourceLocationTest {
26     public final static String NAMESPACE = "SourceLocation";
27
28     @Before
29     public void setUp() throws IOException {
30         String data = "{name:\"SCM\"}";
31         TestUtil.writeFile(data);
32
33         Properties props = new Properties();
34         props.setProperty("maxCachedBufferSize", "1024");
35         props.setProperty("artifact.maxsize", "1024");
36         File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
37         try (OutputStream out = new FileOutputStream(f)) {
38             props.store(out, "Config Property at Conventional Resource");
39         }
40     }
41
42     @Test
43     public void testMergeStrategyInConfig() throws IOException, InterruptedException {
44         Configuration config = ConfigurationManager.lookup();
45         Assert.assertEquals("a-zA-Z_0-9", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER));
46         Assert.assertEquals("1024", config.getAsString(ConfigTestConstant.ARTIFACT_MAXSIZE));
47     }
48
49     @After
50     public void tearDown() throws Exception {
51         TestUtil.cleanUp();
52     }
53 }