/
ServiceEventClientConfigurationTest.java
91 lines (80 loc) · 5.64 KB
/
ServiceEventClientConfigurationTest.java
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
/*******************************************************************************
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.event;
import org.eclipse.kapua.event.ServiceEventBusListener;
import org.eclipse.kapua.qa.markers.junit.JUnitTests;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category(JUnitTests.class)
public class ServiceEventClientConfigurationTest extends Assert {
ServiceEventBusListener serviceEventBusListener;
@Test
public void constructorRegularTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration("address", "subscriberName", serviceEventBusListener);
assertEquals("Expected and actual values are not equals!", "address", serviceEventClientConfiguration.getAddress());
assertEquals("Expected and actual values are not equals!", "subscriberName", serviceEventClientConfiguration.getClientName());
assertEquals("Expected and actual values are not equals!", serviceEventBusListener, serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration(null , null, null);
assertNull("Null expected!", serviceEventClientConfiguration.getAddress());
assertNull("Null expected!", serviceEventClientConfiguration.getClientName());
assertNull("Null expected!", serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorAddressNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration(null , "subscriberName", serviceEventBusListener);
assertNull("Null expected!", serviceEventClientConfiguration.getAddress());
assertEquals("Expected and actual values are not equals!", "subscriberName", serviceEventClientConfiguration.getClientName());
assertEquals("Expected and actual values are not equals!", serviceEventBusListener, serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorClientNameNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration("address", null, serviceEventBusListener);
assertEquals("Expected and actual values are not equals!", "address", serviceEventClientConfiguration.getAddress());
assertNull("Null expected!", serviceEventClientConfiguration.getClientName());
assertEquals("Expected and actual values are not equals!", serviceEventBusListener, serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorServiceEventNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration("address", "subscriberName", null);
assertEquals("Expected and actual values are not equals!", "address", serviceEventClientConfiguration.getAddress());
assertEquals("Expected and actual values are not equals!", "subscriberName", serviceEventClientConfiguration.getClientName());
assertNull("Null expected!", serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorAddressAndNameNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration(null, null, serviceEventBusListener);
assertNull("Null expected!", serviceEventClientConfiguration.getAddress());
assertNull("Null expected!", serviceEventClientConfiguration.getClientName());
assertEquals("Expected and actual values are not equals!", serviceEventBusListener, serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorNameAndServiceEventNullTest() {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration("address", null, null);
assertEquals("Expected and actual values are not equals!", "address", serviceEventClientConfiguration.getAddress());
assertNull("Null expected!", serviceEventClientConfiguration.getClientName());
assertNull("Null expected!", serviceEventClientConfiguration.getEventListener());
}
@Test
public void constructorAddressAndNameCharCheckTest() {
String[] permittedValues = {"", "!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", "regularNaming", "regular Naming", "49", "regularNaming49", "NAMING", "246465494135646120009090049684646496468456468496846464968496844"};
for (String value : permittedValues) {
ServiceEventClientConfiguration serviceEventClientConfiguration = new ServiceEventClientConfiguration(value, value, serviceEventBusListener);
assertEquals("Expected and actual values are not equals!", value, serviceEventClientConfiguration.getAddress());
assertEquals("Expected and actual values are not equals!", value, serviceEventClientConfiguration.getClientName());
assertEquals("Expected and actual values are not equals!", serviceEventBusListener, serviceEventClientConfiguration.getEventListener());
}
}
}