Brian Stanke | 9bf8d7c | 2016-02-11 10:17:23 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Brian Stanke | 9bf8d7c | 2016-02-11 10:17:23 -0500 | [diff] [blame] | 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 | |
Claudine Chiu | 31ad527 | 2016-02-17 20:56:24 +0000 | [diff] [blame] | 17 | package org.onosproject.net.key; |
Brian Stanke | 9bf8d7c | 2016-02-11 10:17:23 -0500 | [diff] [blame] | 18 | |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.junit.Assert.*; |
| 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 23 | |
| 24 | /** |
| 25 | * Test class for UsernamePassword. |
| 26 | */ |
| 27 | public 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 | } |