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 java.lang.reflect.Constructor;
25 import java.lang.reflect.InvocationTargetException;
26 import java.lang.reflect.Method;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
32 public class MR_ClusterTest {
33 String d, fqdn, repGrp, p1, p2, prot, p0;
35 ReflectionHarness rh = new ReflectionHarness();
38 public void setUp() throws Exception {
52 public void tearDown() throws Exception {
57 public void testMR_ClusterClassDefaultConstructor() {
59 MR_Cluster t = new MR_Cluster();
61 assertTrue( t.getDcaeLocationName() == null );
62 assertTrue( t.getFqdn() == null );
67 public void testMR_ClusterClassConstructor() {
69 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0);
71 assertTrue( t.getDcaeLocationName() == d );
72 assertTrue( t.getFqdn() == fqdn );
73 assertTrue( t.getTopicProtocol() == prot );
74 assertTrue( t.getTopicPort() == p0 );
76 // pass null params to trigger default settings
77 t = new MR_Cluster( d, fqdn, null, null );
79 assertTrue( t.getDcaeLocationName() == d );
80 assertTrue( t.getFqdn() == fqdn );
81 assertTrue( t.getTopicProtocol() != null );
82 assertTrue( t.getTopicPort() != null );
86 public void testMR_ClusterManyArgsClassConstructor() {
88 MR_Cluster t = new MR_Cluster( d, fqdn, prot, p0, repGrp, p1, p2 );
90 assertTrue( t.getDcaeLocationName() == d );
91 assertTrue( t.getFqdn() == fqdn );
92 assertTrue( t.getTopicProtocol() == prot );
93 assertTrue( t.getTopicPort() == p0 );
94 assertTrue( t.getReplicationGroup() == repGrp );
95 assertTrue( t.getSourceReplicationPort() == p1 );
96 assertTrue( t.getTargetReplicationPort() == p2 );
98 // pass null params to trigger default settings
99 t = new MR_Cluster( d, fqdn, null, null, null, null, null );
101 assertTrue( t.getDcaeLocationName() == d );
102 assertTrue( t.getFqdn() == fqdn );
103 assertTrue( t.getTopicProtocol() != null );
104 assertTrue( t.getTopicPort() != null );
105 assertTrue( t.getReplicationGroup() != null );
106 assertTrue( t.getSourceReplicationPort() != null );
107 assertTrue( t.getTargetReplicationPort() != null );
111 public void testw3() {
113 MR_Cluster t = new MR_Cluster();
115 assertTrue( t.getDcaeLocationName() == null );
116 assertTrue( t.getFqdn() == null );
118 String override = "cluster2.onap.org";
119 String topic2 = "org.onap.topic2";
120 String fqtn = t.genTopicURL( override, topic2 );
121 assertTrue( fqtn.contains( override) && fqtn.contains(topic2));
123 fqtn = t.genTopicURL( null, "org.onap.topic2" );
124 assertTrue(fqtn.contains(topic2));
130 public void testsetter() {
132 String v = "validate";
135 rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Cluster", "set", v );