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.assertTrue;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
27 public class MR_ClusterTest {
28 String d, fqdn, repGrp, p1, p2, prot, p0;
30 ReflectionHarness rh = new ReflectionHarness();
33 public void setUp() throws Exception {
34 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
48 public void testMR_ClusterClassDefaultConstructor() {
49 MR_Cluster t = new MR_Cluster();
51 assertTrue( t.getDcaeLocationName() == null );
52 assertTrue( t.getFqdn() == null );
57 public void testMR_ClusterClassConstructor() {
59 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0);
61 assertTrue( t.getDcaeLocationName() == d );
62 assertTrue( t.getFqdn() == fqdn );
63 assertTrue( t.getTopicProtocol() == prot );
64 assertTrue( t.getTopicPort() == p0 );
66 // pass null params to trigger default settings
67 t = new MR_Cluster( d, fqdn, null, null );
69 assertTrue( t.getDcaeLocationName() == d );
70 assertTrue( t.getFqdn() == fqdn );
71 assertTrue( t.getTopicProtocol() != null );
72 assertTrue( t.getTopicPort() != null );
76 public void testMR_ClusterManyArgsClassConstructor() {
78 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 );
80 assertTrue( t.getDcaeLocationName() == d );
81 assertTrue( t.getFqdn() == fqdn );
82 assertTrue( t.getTopicProtocol() == prot );
83 assertTrue( t.getTopicPort() == p0 );
84 assertTrue( t.getReplicationGroup() == repGrp );
85 assertTrue( t.getSourceReplicationPort() == p1 );
86 assertTrue( t.getTargetReplicationPort() == p2 );
88 // pass null params to trigger default settings
89 t = new MR_Cluster( d, fqdn, null, null, null, null, null );
91 assertTrue( t.getDcaeLocationName() == d );
92 assertTrue( t.getFqdn() == fqdn );
93 assertTrue( t.getTopicProtocol() != null );
94 assertTrue( t.getTopicPort() != null );
95 assertTrue( t.getReplicationGroup() != null );
96 assertTrue( t.getSourceReplicationPort() != null );
97 assertTrue( t.getTargetReplicationPort() != null );
101 public void testw3() {
103 MR_Cluster t = new MR_Cluster();
105 assertTrue( t.getDcaeLocationName() == null );
106 assertTrue( t.getFqdn() == null );
108 String override = "cluster2.onap.org";
109 String topic2 = "org.onap.topic2";
110 String fqtn = t.genTopicURL( override, topic2 );
111 assertTrue( fqtn.contains( override) && fqtn.contains(topic2));
113 fqtn = t.genTopicURL( null, "org.onap.topic2" );
114 assertTrue(fqtn.contains(topic2));
118 public void testsetter() {
119 String v = "validate";
120 rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );