1 /*******************************************************************************
\r
2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
17 * ============LICENSE_END=========================================================
\r
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
21 *******************************************************************************/
\r
23 package com.att.nsa.mr.client.impl;
\r
25 import java.io.File;
\r
26 import java.io.FileOutputStream;
\r
27 import java.io.IOException;
\r
28 import java.util.List;
\r
29 import java.util.Properties;
\r
30 import java.util.concurrent.TimeUnit;
\r
32 import org.json.JSONObject;
\r
33 import org.junit.After;
\r
34 import org.junit.Assert;
\r
35 import org.junit.Before;
\r
36 import org.junit.Test;
\r
38 import com.att.nsa.mr.client.MRClientFactory;
\r
39 import com.att.nsa.mr.client.MRConsumer;
\r
40 import com.att.nsa.mr.client.MRPublisher.message;
\r
41 import com.att.nsa.mr.client.response.MRPublisherResponse;
\r
43 public class MRSimplerBatchConsumerTest {
\r
47 public void setUp() throws Exception {
\r
48 Properties properties = new Properties();
\r
49 properties.load(MRSimplerBatchConsumerTest.class.getClassLoader().getResourceAsStream("dme2/consumer.properties"));
\r
51 String routeFilePath="dme2/preferredRoute.txt";
\r
53 File file = new File(MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
\r
54 properties.put("DME2preferredRouterFilePath", MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
\r
56 outFile = new File(file.getParent() + "/consumer_tmp.properties");
\r
57 properties.store(new FileOutputStream(outFile), "");
\r
61 public void testSend() throws IOException, InterruptedException {
\r
63 final MRConsumer cc = MRClientFactory.createConsumer(outFile.getPath());
\r
66 for(String msg : cc.fetch()){
\r
67 System.out.println(msg);
\r
69 } catch (Exception e) {
\r
70 System.err.println ( e.getClass().getName () + ": " + e.getMessage () );
\r