2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package com.commscope.tr069adapter.config;
\r
21 import java.io.BufferedReader;
\r
22 import java.io.FileReader;
\r
23 import java.io.IOException;
\r
25 import org.commscope.tr069adapter.acs.common.dto.ConfigurationData;
\r
26 import org.commscope.tr069adapter.config.model.ConfigFileContent;
\r
27 import org.springframework.web.client.RestTemplate;
\r
29 public class ConfigDataApplicationTests {
\r
31 public static final String SERVER_URI = "http://localhost:9000/";
\r
32 public static final String macId = "mac2";
\r
34 public static void main(String args[]) {
\r
36 testSaveConfigurationFileContent();
\r
37 testGetConfigurationData();
\r
38 System.out.println("SUCCESSFUL");
\r
41 private static void testSaveConfigurationFileContent() {
\r
42 System.out.println("\n*******Strating test testSaveConfigurationFileContent*******\n");
\r
43 RestTemplate restTemplate = new RestTemplate();
\r
45 String fileContent = readFile("ss.xml");
\r
46 ConfigFileContent configFleContent = new ConfigFileContent();
\r
48 configFleContent.setMacId(macId);
\r
49 configFleContent.setFileContent(fileContent);
\r
52 restTemplate.postForObject(SERVER_URI + "/create", configFleContent, String.class);
\r
53 System.out.println("Saved");
\r
54 // printEmpData(response);
\r
55 System.out.println("\n*******Test testGetConfigurationData completed*******\n");
\r
58 private static void testGetConfigurationData() {
\r
59 System.out.println("\n*******Strating test testSaveConfigurationFileContent*******\n");
\r
60 RestTemplate restTemplate = new RestTemplate();
\r
62 ConfigurationData configData =
\r
63 restTemplate.getForObject(SERVER_URI + "/getConfig/" + macId, ConfigurationData.class);
\r
65 if (null == configData) {
\r
66 System.out.println("No configuration data exist for device " + macId);
\r
69 "\n***************Configuration data for device " + macId + "***************\n\n");
\r
70 System.out.println(configData.getParameterMONameValueMap());
\r
72 // printConfigData(configData);
\r
73 System.out.println("\n*******Test testGetConfigurationData completed*******\n");
\r
76 public static String readFile(String completeFilePath) {
\r
77 BufferedReader reader = null;
\r
79 StringBuilder stringBuilder = new StringBuilder();
\r
83 reader = new BufferedReader(new FileReader(completeFilePath));
\r
85 while ((line = reader.readLine()) != null) {
\r
86 stringBuilder.append(line);
\r
87 stringBuilder.append(ls);
\r
90 return stringBuilder.toString();
\r
91 } catch (Exception ex) {
\r
94 if (null != reader) {
\r
97 } catch (IOException e) {
\r