blob: 242a26338d6e88a92a58a2e5c882ac9abbb3ee6a [file] [log] [blame]
Brian Stanke9bf8d7c2016-02-11 10:17:23 -05001/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.incubator.net.key;
18
19import org.junit.Test;
20
21import static org.junit.Assert.*;
22import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23
24/**
25 * Test class for UsernamePassword.
26 */
27public class UsernamePasswordTest {
28 final String username = "username";
29 final String password = "password";
30
31 /**
32 * Checks that the UsernamePassword class is immutable.
33 */
34 @Test
35 public void testImmutability() {
36 assertThatClassIsImmutable(UsernamePassword.class);
37 }
38
39 /**
40 * Checks the construction of a username / password object with null
41 * values passed into it.
42 */
43 @Test
44 public void testUsernamePasswordNull() {
45 UsernamePassword usernamePassword = UsernamePassword.usernamePassword(null, null);
46
47 assertNotNull("The UsernamePassword should not be null.", usernamePassword);
48 assertNull("The username should be null.", usernamePassword.username());
49 assertNull("The password should be null.", usernamePassword.password());
50 }
51
52 /**
53 * Checks the construction of a username / password object with non-null
54 * values passed into it.
55 */
56 @Test
57 public void testUsernamePassword() {
58 UsernamePassword usernamePassword = UsernamePassword.usernamePassword(username, password);
59
60 assertNotNull("The usernamePassword should not be null.", usernamePassword);
61 assertEquals("The username should match the expected value.", username, usernamePassword.username());
62 assertEquals("The password should match the expected value.", password, usernamePassword.password());
63 }
64}