[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / common / openecomp-common-configuration-management / openecomp-configuration-management-test / src / test / java / org / openecomp / config / test / ModeAsConfigPropTest.java
1 package org.openecomp.config.test;
2
3 import org.openecomp.config.ConfigurationUtils;
4 import org.openecomp.config.api.Configuration;
5 import org.openecomp.config.api.ConfigurationManager;
6 import org.openecomp.config.util.ConfigTestConstant;
7 import org.openecomp.config.util.TestUtil;
8 import org.junit.After;
9 import org.junit.Assert;
10 import org.junit.Before;
11 import org.junit.Test;
12
13 import java.io.IOException;
14 import java.util.ArrayList;
15 import java.util.List;
16
17 /**
18  * Scenario 8
19  * Validate configuration with mode specified as a configuration property
20  */
21
22 public class ModeAsConfigPropTest {
23
24         String newValue = null;
25         
26         public final static String NAMESPACE = "ModeAsConfigProp";
27         
28         @Before
29         public void setUp() throws IOException {
30                 String data = "{name:\"SCM\"}";
31                 TestUtil.writeFile(data);
32         }
33
34         @Test
35         public void testMergeStrategyInConfig() throws IOException, InterruptedException {
36                 Configuration config = ConfigurationManager.lookup();
37
38                 Assert.assertEquals("14",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
39
40                 Assert.assertEquals("1048",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE));
41
42                 List<String> expectedExtList = new ArrayList<String>();
43                 expectedExtList.add("pdf");
44                 expectedExtList.add("zip");
45                 expectedExtList.add("xml");
46                 expectedExtList.add("pdf");
47                 expectedExtList.add("tgz");
48                 expectedExtList.add("xls");
49                 List<String> extList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_EXT);
50                 Assert.assertEquals(expectedExtList, extList);
51
52                 List<String> expectedEncList = new ArrayList<String>();
53                 expectedEncList.add("Base64");
54                 expectedEncList.add("MD5");
55                 List<String> encList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_ENC);
56                 Assert.assertEquals(expectedEncList, encList);
57
58                 String newValue = config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA);
59                 Assert.assertEquals("{name:\"SCM\"}",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA));
60
61                 Assert.assertEquals("a-zA-Z_0-9",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER ));
62
63                 Assert.assertEquals("Deleted",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS) );
64
65                 List<String> expectedLocList = new ArrayList<String>();
66                 expectedLocList.add("/opt/spool");
67                 expectedLocList.add(System.getProperty("user.home")+"/asdc");
68                 List<String> locList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_LOC);
69                 Assert.assertEquals(expectedLocList, locList);
70
71                 Assert.assertEquals("@"+System.getenv("Path")+"/myschema.json",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_XML_SCHEMA));
72
73                 List<String> artifactConsumer = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER );
74                 Assert.assertEquals(config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER_APPC ), artifactConsumer);
75
76                 Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_MANDATORY_NAME ), true);
77
78                 Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH ), "6");
79
80                 Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_ENCODED ), true);
81         }
82
83         @After
84         public void tearDown() throws Exception {
85                 TestUtil.cleanUp();
86         }
87
88 }