Cleanup of dmaap adapter
[appc.git] / appc-adapters / appc-dmaap-adapter / appc-dmaap-adapter-bundle / src / test / java / org / onap / appc / adapter / messaging / dmaap / TestDmaapConsuming.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.adapter.messaging.dmaap;
25
26
27 import org.junit.Assert;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.onap.appc.adapter.message.Consumer;
31 import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
32 import org.onap.appc.configuration.Configuration;
33 import org.onap.appc.configuration.ConfigurationFactory;
34 import org.junit.Ignore;
35
36 import java.util.Arrays;
37 import java.util.List;
38
39 /**
40  * Must have a DMaaP cluster or simulator up and running
41  * Update the hostname, topic, client properties in
42  * resources/org/onap/appc/default.properties
43  *
44  */
45 public class TestDmaapConsuming {
46
47     private static Consumer httpConsumer;
48
49     @BeforeClass
50     public static void setUp() {
51
52         Configuration configuration = ConfigurationFactory.getConfiguration();
53
54         List<String> hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
55         String topic = configuration.getProperty("topic.read");
56         String consumerName = configuration.getProperty("client.name");
57         String consumerId = configuration.getProperty("client.name.id");
58         String msgFilter = configuration.getProperty("message.filter");
59         String user = configuration.getProperty("dmaap.appc.username");
60         String password = configuration.getProperty("dmaap.appc.password");
61
62         httpConsumer = new HttpDmaapConsumerImpl(hosts, topic, consumerName, consumerId, msgFilter);
63     }
64
65     @Test
66     @Ignore
67     public void testHttpFetchMessages() {
68         testFetchMessages(httpConsumer);
69     }
70
71      @Test
72      @Ignore
73     public void testFetchMessages() {
74         testFetchMessages(httpConsumer);
75     }
76
77     private void testFetchMessages(Consumer consumer) {
78         List<String> messages = consumer.fetch(1000, 100);
79         Assert.assertNotNull(messages);
80         Assert.assertFalse(messages.isEmpty());
81     }
82
83 }