1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright © 2021 Orange.
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 * 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=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 *******************************************************************************/
25 package org.onap.dmaap.mr.client.impl;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.dmaap.mr.client.MRClientFactory;
30 import org.onap.dmaap.mr.client.MRConsumer;
33 import java.io.FileOutputStream;
34 import java.io.IOException;
35 import java.util.Properties;
37 import static org.junit.Assert.assertNotNull;
39 public class MRSimplerBatchConsumerTest {
44 public void setUp() throws Exception {
45 Properties properties = new Properties();
46 properties.load(MRSimplerBatchConsumerTest.class.getClassLoader().getResourceAsStream("dme2/consumer.properties"));
48 String routeFilePath = "dme2/preferredRoute.txt";
50 File file = new File(MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
51 properties.put("DME2preferredRouterFilePath", MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
53 outFile = new File(file.getParent() + "/consumer_tmp.properties");
54 properties.store(new FileOutputStream(outFile), "");
58 public void testSend() throws IOException, InterruptedException {
60 final MRConsumer cc = MRClientFactory.createConsumer(outFile.getPath());
63 for (String msg : cc.fetch()) {
64 System.out.println(msg);
66 } catch (Exception e) {
67 System.err.println(e.getClass().getName() + ": " + e.getMessage());