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;
21 import org.onap.dmaap.dbcapi.model.*;
23 import static org.junit.Assert.*;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import java.util.List;
29 import java.util.ArrayList;
31 public class MR_ClientServiceTest {
33 private static final String fmt = "%24s: %s%n";
35 private static DmaapObjectFactory factory = new DmaapObjectFactory();
37 ReflectionHarness rh = new ReflectionHarness();
39 private TopicService ts;
40 private MR_ClusterService mcs;
41 private MR_ClientService cls;
42 private DcaeLocationService dls;
45 private String locname;
48 public void setUp() throws Exception {
49 ts = new TopicService();
50 mcs = new MR_ClusterService();
51 cls = new MR_ClientService();
52 f = "mrsn01.onap.org";
53 locname = "central-demo";
55 dls = new DcaeLocationService();
56 DcaeLocation loc = factory.genDcaeLocation( "central" );
57 dls.addDcaeLocation( loc );
59 ApiError err = new ApiError();
60 String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" };
61 MR_Cluster node = factory.genMR_Cluster( "central" );
62 MR_Cluster n2 = mcs.addMr_Cluster( node, err );
66 public void tearDown() throws Exception {
74 rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "get", null );
80 String v = "Validate";
81 rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClientService", "set", v );
87 Topic topic = factory.genSimpleTopic( "test3" );
88 ApiError err = new ApiError();
89 Topic nTopic = ts.addTopic( topic, err );
90 if ( nTopic != null ) {
91 assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
93 String[] actions = { "pub", "view" };
94 MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
96 c = cls.addMr_Client( c, topic, err );
101 public void test4() {
102 List<MR_Client> l = cls.getAllMr_Clients();
104 ArrayList<MR_Client> al = cls.getAllMrClients( "foo" );
106 ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" );
110 public void test5() {
111 Topic topic = factory.genSimpleTopic( "test5" );
112 ApiError err = new ApiError();
113 Topic nTopic = ts.addTopic( topic, err );
114 if ( nTopic != null ) {
115 assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
117 MR_Client c = factory.genPublisher( "edge", topic.getFqtn() );
119 c = cls.addMr_Client( c, topic, err );
121 c = factory.genSubscriber( "edge", topic.getFqtn() );
122 c = cls.updateMr_Client( c, err );
123 assertTrue( err.getCode() == 200 );