blob: f2308b0142ff8f8e9920286fcd0069795f7c9ec6 [file] [log] [blame]
Ray Milkey96495ca2015-07-07 11:02:10 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey96495ca2015-07-07 11:02:10 -07003 *
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 */
16package org.onosproject.store.cluster.messaging;
17
18import org.junit.Test;
19
20import com.google.common.testing.EqualsTester;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
25
26/**
27 * Unit tests for MessageSubject class.
28 */
29public class MessageSubjectTest {
30 private final MessageSubject subject1 = new MessageSubject("Message 1");
31 private final MessageSubject sameAsSubject1 = new MessageSubject("Message 1");
32 private final MessageSubject subject2 = new MessageSubject("Message 2");
33 private final MessageSubject subject3 = new MessageSubject("Message 3");
34
35 /**
36 * Checks that the MessageSubject class is immutable.
37 */
38 @Test
39 public void testImmutability() {
40 assertThatClassIsImmutable(MessageSubject.class);
41 }
42
43 /**
44 * Checks the operation of equals(), hashCode() and toString() methods.
45 */
46 @Test
47 public void testEquals() {
48 new EqualsTester()
49 .addEqualityGroup(subject1, sameAsSubject1)
50 .addEqualityGroup(subject2)
51 .addEqualityGroup(subject3)
52 .testEquals();
53 }
54
55 /**
56 * Checks the construction of a MessageSubject object.
57 */
58 @Test
59 public void testConstruction() {
60 assertThat(subject3.value(), is("Message 3"));
61 MessageSubject serializerObject = new MessageSubject();
62 assertThat(serializerObject.value(), is(""));
63 }
64}