2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.appc.listener.impl;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.fail;
27 import java.util.Properties;
29 import org.junit.Before;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.openecomp.appc.listener.Listener;
33 import org.openecomp.appc.listener.ListenerProperties;
34 import org.openecomp.appc.listener.CL.impl.ListenerImpl;
37 public class TestListener {
39 private static final String PROP_FILE = "/org/openecomp/appc/default.properties";
41 private Listener listener;
43 private Properties props;
47 props = new Properties();
49 props.load(getClass().getResourceAsStream(PROP_FILE));
50 props.setProperty("topic.read", "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM");
51 } catch (Exception e) {
53 fail("Failed to setup test: " + e.getMessage());
55 listener = new ListenerImpl(new ListenerProperties("appc.ClosedLoop", props));
59 public void testListenerId() {
60 String originalId = listener.getListenerId();
61 String newId = originalId + "-new";
63 listener.setListenerId(newId);
64 assertEquals(newId, listener.getListenerId());
68 public void testRun() {
70 Thread t = new Thread(listener);
77 System.out.println(listener.getBenchmark());
79 } catch (Exception e) {
86 public void testUpdateProperties() {
91 public void printSampleData() {
93 props.setProperty("threads.queuesize.min", "1");
94 props.setProperty("threads.queuesize.max", "1");
95 props.setProperty("threads.poolsize.min", "1");
96 props.setProperty("threads.poolsize.max", "1");
98 Thread t = new Thread(listener);
105 System.out.println(listener.getBenchmark());
107 } catch (Exception e) {
109 fail(e.getMessage());