2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.listener.impl;
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.fail;
30 import java.util.Properties;
32 import org.junit.Before;
33 import org.junit.Ignore;
34 import org.junit.Test;
35 import org.onap.appc.listener.Listener;
36 import org.onap.appc.listener.ListenerProperties;
37 import org.onap.appc.listener.demo.impl.ListenerImpl;
40 public class TestListener {
42 private static final String PROP_FILE = "/org/onap/appc/default.properties";
44 private Listener listener;
46 private Properties props;
50 props = new Properties();
52 props.load(getClass().getResourceAsStream(PROP_FILE));
53 props.setProperty("topic.read", "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM");
54 } catch (Exception e) {
56 fail("Failed to setup test: " + e.getMessage());
58 listener = new ListenerImpl(new ListenerProperties("appc.ClosedLoop", props));
62 public void testListenerId() {
63 String originalId = listener.getListenerId();
64 String newId = originalId + "-new";
66 listener.setListenerId(newId);
67 assertEquals(newId, listener.getListenerId());
71 public void testRun() {
73 Thread t = new Thread(listener);
80 System.out.println(listener.getBenchmark());
82 } catch (Exception e) {
89 public void testUpdateProperties() {
94 public void printSampleData() {
96 props.setProperty("threads.queuesize.min", "1");
97 props.setProperty("threads.queuesize.max", "1");
98 props.setProperty("threads.poolsize.min", "1");
99 props.setProperty("threads.poolsize.max", "1");
101 Thread t = new Thread(listener);
108 System.out.println(listener.getBenchmark());
110 } catch (Exception e) {
112 fail(e.getMessage());