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");