@@ -0,0 +1,2586 @@
+/*%0A * Copyright 2015 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.kuujo.copycat.cluster;%0A%0Aimport net.kuujo.copycat.cluster.internal.MemberInfo;%0Aimport org.testng.annotations.Test;%0A%0Aimport static org.testng.Assert.*;%0A%0A/**%0A * Cluster member info test.%0A *%0A * @author %3Ca href=%22http://github.com/kuujo%22%3EJordan Halterman%3C/a%3E%0A */%0A@Test%0Apublic class MemberInfoTest %7B%0A%0A  /**%0A   * Tests updating a member state.%0A   */%0A  public void testUpdateState() %7B%0A    MemberInfo member = new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.ALIVE, 5);%0A    member.update(new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.SUSPICIOUS, 6));%0A    assertEquals(member.state(), Member.State.SUSPICIOUS);%0A  %7D%0A%0A  /**%0A   * Tests rejecting an old state.%0A   */%0A  public void testRejectOldState() %7B%0A    MemberInfo member = new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.ALIVE, 5);%0A    member.update(new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.SUSPICIOUS, 4));%0A    assertEquals(member.state(), Member.State.ALIVE);%0A  %7D%0A%0A  /**%0A   * Tests failing a member.%0A   */%0A  public void testFailures() %7B%0A    MemberInfo member = new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.ALIVE, 5);%0A    member.fail(%22foo%22);%0A    assertEquals(member.state(), Member.State.SUSPICIOUS);%0A    member.fail(%22bar%22);%0A    assertEquals(member.state(), Member.State.SUSPICIOUS);%0A    member.fail(%22bar%22);%0A    assertEquals(member.state(), Member.State.SUSPICIOUS);%0A    member.fail(%22baz%22);%0A    assertEquals(member.state(), Member.State.DEAD);%0A  %7D%0A%0A  /**%0A   * Tests that failures are reset when the state is updated.%0A   */%0A  public void testResetFailuresOnStateUpdate() %7B%0A    MemberInfo member = new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.ALIVE, 5);%0A    member.fail(%22foo%22);%0A    member.fail(%22bar%22);%0A    assertEquals(member.failures().size(), 2);%0A    assertEquals(member.state(), Member.State.SUSPICIOUS);%0A    member.update(new MemberInfo(%22test%22, Member.Type.PASSIVE, Member.State.ALIVE, 6));%0A    assertEquals(member.state(), Member.State.ALIVE);%0A  %7D%0A%0A%7D%0A

Add member info tests.