2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Nokia
6 * ================================================================================
7 * Modifications Copyright © 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
24 * @author marcin.migdal@nokia.com
26 package com.att.nsa.mr.tools;
28 import static org.junit.Assert.assertEquals;
30 import java.util.Properties;
32 import org.junit.Test;
34 import com.att.nsa.mr.test.clients.ProtocolTypeConstants;
36 public class ValidatorUtilTest {
39 public void testValidateForDME2WithNullServiceName() {
40 Properties props = new Properties();
41 props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
43 ValidatorUtil.validatePublisher(props);
44 } catch(IllegalArgumentException e) {
45 assertEquals(e.getMessage(), "Servicename is needed");
51 public void testValidateForDME2WithNullTopic() {
52 Properties props = new Properties();
53 props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
54 props.setProperty("ServiceName", "ServiceName");
56 ValidatorUtil.validatePublisher(props);
57 } catch(IllegalArgumentException e) {
58 assertEquals(e.getMessage(), "topic is needed");
64 public void testValidateForDME2WithNullUserName() {
65 Properties props = new Properties();
66 props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
67 props.setProperty("ServiceName", "ServiceName");
68 props.setProperty("topic", "topic");
70 ValidatorUtil.validatePublisher(props);
71 } catch(IllegalArgumentException e) {
72 assertEquals(e.getMessage(), "username is needed");
78 public void testValidateForDME2WithNullPassword() {
79 Properties props = new Properties();
80 props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
81 props.setProperty("ServiceName", "ServiceName");
82 props.setProperty("topic", "topic");
83 props.setProperty("username", "username");
86 ValidatorUtil.validatePublisher(props);
87 } catch(IllegalArgumentException e) {
88 assertEquals(e.getMessage(), "password is needed");
97 public void testValidateForNonDME2WithNullServiceName() {
98 Properties props = new Properties();
99 props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
101 ValidatorUtil.validatePublisher(props);
102 } catch(IllegalArgumentException e) {
103 assertEquals(e.getMessage(), "Servicename is needed");
109 public void testValidateForNonDME2WithNullTopic() {
110 Properties props = new Properties();
111 props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
112 props.setProperty("host", "ServiceName");
114 ValidatorUtil.validatePublisher(props);
115 } catch(IllegalArgumentException e) {
116 assertEquals(e.getMessage(), "topic is needed");
122 public void testValidateForNonDME2WithNullContenttype() {
123 Properties props = new Properties();
124 props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
125 props.setProperty("host", "ServiceName");
126 props.setProperty("topic", "topic");
128 ValidatorUtil.validatePublisher(props);
129 } catch(IllegalArgumentException e) {
130 assertEquals(e.getMessage(), "contenttype is needed");
137 public void testValidateForNonDME2WithNullUserName() {
138 Properties props = new Properties();
139 props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
140 props.setProperty("host", "ServiceName");
141 props.setProperty("topic", "topic");
142 props.setProperty("contenttype", "contenttype");
144 ValidatorUtil.validatePublisher(props);
145 } catch(IllegalArgumentException e) {
146 assertEquals(e.getMessage(), "username is needed");
152 public void testValidateForNonDME2WithNullPassword() {
153 Properties props = new Properties();
154 props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
155 props.setProperty("host", "ServiceName");
156 props.setProperty("topic", "topic");
157 props.setProperty("username", "username");
158 props.setProperty("contenttype", "contenttype");
161 ValidatorUtil.validatePublisher(props);
162 } catch(IllegalArgumentException e) {
163 assertEquals(e.getMessage(), "password is needed");