commiting code for test coverage
[dmaap/messagerouter/dmaapclient.git] / src / test / java / com / att / nsa / mr / client / impl / MRSimplerBatchConsumerTest.java
1 /*******************************************************************************\r
2  *  ============LICENSE_START=======================================================\r
3  *  org.onap.dmaap\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
11  *  \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
18  *\r
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
20  *  \r
21  *******************************************************************************/\r
22 \r
23 package com.att.nsa.mr.client.impl;\r
24 \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
31 \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
37 \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
42 \r
43 public class MRSimplerBatchConsumerTest {\r
44         \r
45         File outFile;\r
46         @Before\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
50                 \r
51                 String routeFilePath="dme2/preferredRoute.txt";\r
52                 \r
53                 File file = new File(MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());\r
54                 properties.put("DME2preferredRouterFilePath", MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());\r
55                 \r
56                 outFile = new File(file.getParent() + "/consumer_tmp.properties");\r
57                 properties.store(new FileOutputStream(outFile), "");\r
58         }\r
59 \r
60         @Test\r
61         public void testSend() throws IOException, InterruptedException {\r
62                                 \r
63                 final MRConsumer cc = MRClientFactory.createConsumer(outFile.getPath());        \r
64                 \r
65                 try {\r
66                         for(String msg : cc.fetch()){\r
67                                 System.out.println(msg);\r
68                         }\r
69                 } catch (Exception e) {\r
70                         System.err.println ( e.getClass().getName () + ": " + e.getMessage () );\r
71                 }               \r
72                 \r
73         }\r
74 \r
75 }\r