2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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=========================================================
20 package org.onap.dmaap.dbcapi.service;
22 import org.onap.dmaap.dbcapi.model.*;
23 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
25 import static org.junit.Assert.*;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import java.util.List;
31 import java.util.ArrayList;
33 public class TopicServiceTest {
35 private static final String fmt = "%24s: %s%n";
37 ReflectionHarness rh = new ReflectionHarness();
40 MR_ClusterService mcs;
41 String locname = "central-onap";
44 public void setUp() throws Exception {
45 ts = new TopicService();
46 mcs = new MR_ClusterService();
50 public void tearDown() throws Exception {
58 rh.reflect( "org.onap.dmaap.dbcapi.service.TopicService", "get", null );
64 String v = "Validate";
65 rh.reflect( "org.onap.dmaap.dbcapi.service.TopicService", "set", v );
71 Topic topic = new Topic();
72 ApiError err = new ApiError();
73 topic.setTopicName( "test3" );
74 topic.setFqtnStyle( FqtnType.Validator("none") );
76 Topic nTopic = ts.addTopic( topic, err, false );
77 if ( nTopic != null ) {
78 assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
84 public void test3a() {
85 Topic topic = new Topic();
86 ApiError err = new ApiError();
87 topic.setTopicName( "test3" );
88 topic.setFqtnStyle( FqtnType.Validator("none") );
90 String t = "org.onap.dmaap.interestingTopic";
91 String f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
92 String c = "publisher";
93 String[] a = { "sub", "view" };
94 MR_Client sub = new MR_Client( locname, f, c, a );
95 String[] b = { "pub", "view" };
96 MR_Client pub = new MR_Client( "edge", f, c, b );
97 ArrayList<MR_Client> clients = new ArrayList<MR_Client>();
102 topic.setClients( clients );
104 ts.reviewTopic( topic );
105 ts.checkForBridge( topic, err );
107 Topic nTopic = ts.addTopic( topic, err, false );
108 if ( nTopic != null ) {
109 assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
113 ts.removeTopic( "test3", err );
117 public void test4() {
118 List<Topic> l = ts.getAllTopics();
123 public void test5() {
124 ApiError err = new ApiError();
127 TODO: find a null pointer in here...
128 String[] hl = { "host1", "host2", "host3" };
129 String loc = "central-onap";
130 MR_Cluster cluster = new MR_Cluster( loc, "localhost", "", hl );
131 mcs.addMr_Cluster( cluster, err );
132 Topic topic = new Topic();
133 topic.setTopicName( "test5" );
134 topic.setFqtnStyle( FqtnType.Validator("none") );
135 topic.setReplicationCase( ReplicationType.Validator("none") );
136 String f = topic.getFqtn();
137 Topic nTopic = ts.updateTopic( topic, err );
139 assertTrue( err.getCode() == 0 );