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.model;
22 import static org.junit.Assert.*;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
28 public class MR_ClusterTest {
29 String d, fqdn, repGrp, p1, p2, prot, p0;
31 ReflectionHarness rh = new ReflectionHarness();
34 public void setUp() throws Exception {
48 public void tearDown() throws Exception {
53 public void testMR_ClusterClassDefaultConstructor() {
55 MR_Cluster t = new MR_Cluster();
57 assertTrue( t.getDcaeLocationName() == null );
58 assertTrue( t.getFqdn() == null );
63 public void testMR_ClusterClassConstructor() {
65 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0);
67 assertTrue( t.getDcaeLocationName() == d );
68 assertTrue( t.getFqdn() == fqdn );
69 assertTrue( t.getTopicProtocol() == prot );
70 assertTrue( t.getTopicPort() == p0 );
72 // pass null params to trigger default settings
73 t = new MR_Cluster( d, fqdn, null, null );
75 assertTrue( t.getDcaeLocationName() == d );
76 assertTrue( t.getFqdn() == fqdn );
77 assertTrue( t.getTopicProtocol() != null );
78 assertTrue( t.getTopicPort() != null );
82 public void testMR_ClusterManyArgsClassConstructor() {
84 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 );
86 assertTrue( t.getDcaeLocationName() == d );
87 assertTrue( t.getFqdn() == fqdn );
88 assertTrue( t.getTopicProtocol() == prot );
89 assertTrue( t.getTopicPort() == p0 );
90 assertTrue( t.getReplicationGroup() == repGrp );
91 assertTrue( t.getSourceReplicationPort() == p1 );
92 assertTrue( t.getTargetReplicationPort() == p2 );
94 // pass null params to trigger default settings
95 t = new MR_Cluster( d, fqdn, null, null, null, null, null );
97 assertTrue( t.getDcaeLocationName() == d );
98 assertTrue( t.getFqdn() == fqdn );
99 assertTrue( t.getTopicProtocol() != null );
100 assertTrue( t.getTopicPort() != null );
101 assertTrue( t.getReplicationGroup() != null );
102 assertTrue( t.getSourceReplicationPort() != null );
103 assertTrue( t.getTargetReplicationPort() != null );
107 public void testw3() {
109 MR_Cluster t = new MR_Cluster();
111 assertTrue( t.getDcaeLocationName() == null );
112 assertTrue( t.getFqdn() == null );
114 String override = "cluster2.onap.org";
115 String topic2 = "org.onap.topic2";
116 String fqtn = t.genTopicURL( override, topic2 );
117 assertTrue( fqtn.contains( override) && fqtn.contains(topic2));
119 fqtn = t.genTopicURL( null, "org.onap.topic2" );
120 assertTrue(fqtn.contains(topic2));
126 public void testsetter() {
128 String v = "validate";
131 rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );