900e9c5fcb2f5c1284313c5bdc1b5851439bfe0d
[appc.git] / services / appc-dmaap-service / appc-event-listener-bundle / src / test / java / org / onap / appc / listener / LCM / impl / ListenerImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.listener.LCM.impl;
25
26 import static org.junit.Assert.fail;
27
28 import java.util.Properties;
29 import org.junit.Before;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.onap.appc.listener.Listener;
33 import org.onap.appc.listener.ListenerProperties;
34 import org.onap.appc.listener.demo.impl.ListenerImpl;
35
36 @Ignore
37 public class ListenerImplTest {
38
39     private static final String PROP_FILE = "/org/onap/appc/default.properties";
40
41     private Listener listener;
42     private Properties props;
43
44     @Before
45     public void setup() {
46         props = new Properties();
47         try {
48             props.load(getClass().getResourceAsStream(PROP_FILE));
49             props.setProperty("topic.read", "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM");
50         } catch (Exception e) {
51             e.printStackTrace();
52             fail("Failed to setup test: " + e.getMessage());
53         }
54         listener = new ListenerImpl(new ListenerProperties("appc.ClosedLoop", props));
55     }
56
57     @Test
58     public void testRun() {
59         try {
60             Thread t = new Thread(listener);
61             t.start();
62
63             Thread.sleep(5000);
64
65             listener.stopNow();
66
67             System.out.println(listener.getBenchmark());
68
69         } catch (Exception e) {
70             e.printStackTrace();
71             fail(e.getMessage());
72         }
73     }
74
75     @Test
76     public void printSampleData() {
77         try {
78             props.setProperty("threads.queuesize.min", "1");
79             props.setProperty("threads.queuesize.max", "1");
80             props.setProperty("threads.poolsize.min", "1");
81             props.setProperty("threads.poolsize.max", "1");
82
83             Thread t = new Thread(listener);
84             t.start();
85
86             Thread.sleep(2000);
87
88             listener.stop();
89
90             System.out.println(listener.getBenchmark());
91
92         } catch (Exception e) {
93             e.printStackTrace();
94             fail(e.getMessage());
95         }
96     }
97 }