ffc007a068c8ffccd0089f7d117aeb35584e6cf8
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk feature sdnr wt
4  *  ================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  ******************************************************************************/
21 package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeConnector.test;
22
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeMessages;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeSenderImpl;
26
27 public class DcaeTestClient {
28
29     private static final boolean TESTCOLLECTOR_YES = true;
30
31     public static void main(String[] args) {
32
33         System.out.println("Test program to verify DCAE https connectivity");
34
35         //Get configuration
36         DcaeConfig configuration = DcaeConfig.getDefaultConfiguration();
37
38         if (configuration != null) {
39
40             //Start services
41             System.out.println("Configuration: "+configuration);
42
43             DcaeSenderImpl dcaeClient = new DcaeSenderImpl(configuration.getEventReveicerUrl(), configuration.getUserCredentials());
44
45             if (TESTCOLLECTOR_YES) {
46                 System.out.println("Connect to testclient and send notifications");
47
48                 DcaeMessages dcaeMessages = new DcaeMessages(dcaeClient, "ControllerName", 31, null);
49
50                 for (int t=0; t < 2; t++) {
51                     try {
52                         Thread.sleep(1000);                 //1000 milliseconds is one second.
53                     } catch(InterruptedException ex) {
54                         Thread.currentThread().interrupt();
55                     }
56                     System.out.println(t+". Send notification and receive answer message");
57                     System.out.println("Heartbeat message: "+dcaeMessages.postHeartBeat());
58                     System.out.println("Status of ECOMP Client: "+dcaeClient.getStatusAsString());
59                 }
60
61             } else {
62
63                 System.out.println("Connect to server and receive initial answer.");
64                 System.out.println("Message: "+dcaeClient.testConnectServer());
65
66             }
67
68         }
69    }
70
71 }