1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*-
* ============LICENSE_START=======================================================
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.dmaap.dbcapi.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MRClientTest {
ReflectionHarness rh = new ReflectionHarness();
String d, t, f, c, m;
@Before
public void setUp() throws Exception {
System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
d = "central-onap";
t = "org.onap.dmaap.interestingTopic";
f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
c = "publisher";
m = "m12345";
}
@Test
public void test1() {
// can't use simple reflection to test for null since null constructor
// initializes some fields.
// rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
// so brute force instead...
String[] a = { "put", "view" };
MR_Client m = new MR_Client();
assertTrue(null == m.getDcaeLocationName());
assertTrue(null == m.getFqtn());
assertTrue(null == m.getClientRole());
assertTrue(null == m.getAction());
}
@Test
public void test2() {
String[] a = { "put", "view" };
MR_Client m = new MR_Client(d, f, c, a);
assertTrue(d.equals(m.getDcaeLocationName()));
assertTrue(f.equals(m.getFqtn()));
assertTrue(c.equals(m.getClientRole()));
String[] ma = m.getAction();
assertTrue(a.length == ma.length);
for (int i = 0; i < a.length; i++) {
assertTrue(a[i].equals(ma[i]));
}
}
@Test
public void test3() {
String v = "Validate";
rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
}
@Test
public void test4() {
MR_Client mrClient = new MR_Client();
String stringArray[] = { "test" };
mrClient.setAction(stringArray);
mrClient.hasAction("");
mrClient.setMrClientId("mrClientId");
mrClient.setTopicURL("testTopicURL");
mrClient.setClientIdentity("clientIdentity");
assertEquals("clientIdentity", mrClient.getClientIdentity());
assertEquals("testTopicURL", mrClient.getTopicURL());
assertEquals("mrClientId", mrClient.getMrClientId());
assertEquals(false, mrClient.isPublisher());
assertEquals(false, mrClient.isSubscriber());
assertEquals("test", mrClient.getAction()[0]);
}
}
|