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 MR_ClusterServiceTest {
35 private static final String fmt = "%24s: %s%n";
37 ReflectionHarness rh = new ReflectionHarness();
42 public void setUp() throws Exception {
43 ns = new MR_ClusterService();
47 public void tearDown() throws Exception {
55 rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "get", null );
61 String v = "Validate";
62 rh.reflect( "org.onap.dmaap.dbcapi.service.MR_ClusterService", "set", v );
68 String f = "mrsn01.onap.org";
69 String locname = "central-demo";
71 DcaeLocationService dls = new DcaeLocationService();
72 DcaeLocation loc = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" );
73 dls.addDcaeLocation( loc );
75 ApiError err = new ApiError();
76 String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" };
77 MR_Cluster node = new MR_Cluster( locname, f, "http", "3904");
78 MR_Cluster n2 = ns.addMr_Cluster( node, err );
81 n2 = ns.getMr_Cluster( f, err );
84 List<MR_Cluster> l = ns.getAllMr_Clusters();
86 n2 = ns.updateMr_Cluster( n2, err );
89 n2 = ns.removeMr_Cluster( f, err );
97 List<MR_Client> l = cls.getAllMr_Clients();
99 ArrayList<MR_Client> al = cls.getAllMrClients( "foo" );
101 ArrayList<MR_Client> al2 = cls.getClientsByLocation( "central" );
105 public void test5() {
106 Topic topic = new Topic();
107 ApiError err = new ApiError();
108 topic.setTopicName( "test3" );
109 topic.setFqtnStyle( FqtnType.Validator("none") );
111 Topic nTopic = ts.addTopic( topic, err );
112 if ( nTopic != null ) {
113 assertTrue( nTopic.getTopicName().equals( topic.getTopicName() ));
115 String[] actions = { "pub", "view" };
116 MR_Client c = new MR_Client( "central-onap", "org.onap.dmaap.demo.interestingTopic2", "org.onap.clientApp.publisher", actions );
118 c = cls.addMr_Client( c, topic, err );
121 c.setAction( actions );
122 c = cls.updateMr_Client( c, err );
123 assertTrue( err.getCode() == 200 );