782858d73fc48e91f82fc76e2724b7de0a0b3d4d
[appc.git] / appc-event-listener / 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 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.listener.LCM.impl;
26
27 import static org.junit.Assert.fail;
28
29 import java.util.Properties;
30 import org.junit.Before;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.onap.appc.listener.Listener;
34 import org.onap.appc.listener.ListenerProperties;
35 import org.onap.appc.listener.demo.impl.ListenerImpl;
36
37 @Ignore
38 public class ListenerImplTest {
39
40     private static final String PROP_FILE = "/org/onap/appc/default.properties";
41
42     private Listener listener;
43     private Properties props;
44
45     @Before
46     public void setup() {
47         props = new Properties();
48         try {
49             props.load(getClass().getResourceAsStream(PROP_FILE));
50             props.setProperty("topic.read", "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM");
51         } catch (Exception e) {
52             e.printStackTrace();
53             fail("Failed to setup test: " + e.getMessage());
54         }
55         listener = new ListenerImpl(new ListenerProperties("appc.ClosedLoop", props));
56     }
57
58     @Test
59     public void testRun() {
60         try {
61             Thread t = new Thread(listener);
62             t.start();
63
64             Thread.sleep(5000);
65
66             listener.stopNow();
67
68             System.out.println(listener.getBenchmark());
69
70         } catch (Exception e) {
71             e.printStackTrace();
72             fail(e.getMessage());
73         }
74     }
75
76     @Test
77     public void printSampleData() {
78         try {
79             props.setProperty("threads.queuesize.min", "1");
80             props.setProperty("threads.queuesize.max", "1");
81             props.setProperty("threads.poolsize.min", "1");
82             props.setProperty("threads.poolsize.max", "1");
83
84             Thread t = new Thread(listener);
85             t.start();
86
87             Thread.sleep(2000);
88
89             listener.stop();
90
91             System.out.println(listener.getBenchmark());
92
93         } catch (Exception e) {
94             e.printStackTrace();
95             fail(e.getMessage());
96         }
97     }
98 }