2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.mr.cambria.resources;
23 import static org.junit.Assert.*;
25 import java.io.IOException;
27 import org.json.JSONException;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
32 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
33 import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
34 import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
35 import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream.operation;
37 public class CambriaOutboundEventStreamTest {
39 private CambriaOutboundEventStream coes = null;
42 public void setUp() throws Exception {
43 coes = new CambriaOutboundEventStream.Builder(null).timeout(10).limit(1).filter(CambriaConstants.kNoFilter)
44 .pretty(false).withMeta(true).build();
45 DMaaPContext ctx = new DMaaPContext();
47 coes.setDmaapContext(ctx);
49 coes.setTransEnabled(true);
50 coes.setTopicStyle(true);
54 public void tearDown() throws Exception {
58 public void testGetSentCount() {
59 int sentCount = coes.getSentCount();
60 assertTrue("Doesn't match, got " + sentCount, sentCount==0);;
64 public void testWrite() {
65 //fail("Not yet implemented");
69 public void testForEachMessage() {
71 coes.forEachMessage(new operation(){
74 public void onWait() throws IOException {
75 // TODO Auto-generated method stub
80 public void onMessage(int count, String msg, String transId, long offSet)
81 throws IOException, JSONException {
82 // TODO Auto-generated method stub
87 } catch (Exception e) {
88 // TODO Auto-generated catch block
93 public void testGetDmaapContext() {
94 DMaaPContext ctx = coes.getDmaapContext();
100 public void testSetDmaapContext() {
101 DMaaPContext ctx = new DMaaPContext();
102 coes.setDmaapContext(ctx);
103 assertTrue(ctx.equals(coes.getDmaapContext()));
107 public void testGetTopic() {
113 public void testSetTopic() {
114 //fail("Not yet implemented");
118 public void testSetTopicStyle() {
119 coes.setTopicStyle(true);
124 public void testSetTransEnabled() {
125 coes.setTransEnabled(true);