コード例 #1
0
  /** Test method for {@link org.jboss.ha.framework.server.SimpleMarshalledValue#hashCode()}. */
  @Test
  public void testHashCode() throws Exception {
    GUID guid = new GUID();
    SimpleMarshalledValue<GUID> mv = this.factory.createMarshalledValue(guid);
    assertEquals(guid.hashCode(), mv.hashCode());

    SimpleMarshalledValue<GUID> copy = replicate(mv);
    this.validateHashCode(guid, copy);

    mv = this.factory.createMarshalledValue(null);
    assertEquals(0, mv.hashCode());
  }
コード例 #2
0
  /**
   * Test method for {@link
   * org.jboss.ha.framework.server.SimpleMarshalledValue#equals(java.lang.Object)}.
   */
  @Test
  public void equals() throws Exception {
    GUID guid = new GUID();
    SimpleMarshalledValue<GUID> mv = this.factory.createMarshalledValue(guid);

    assertTrue(mv.equals(mv));
    assertFalse(mv.equals(null));

    SimpleMarshalledValue<GUID> dup = this.factory.createMarshalledValue(guid);
    assertTrue(mv.equals(dup));
    assertTrue(dup.equals(mv));

    SimpleMarshalledValue<GUID> replica = replicate(mv);
    assertTrue(mv.equals(replica));
    assertTrue(replica.equals(mv));

    SimpleMarshalledValue<GUID> nulled = this.factory.createMarshalledValue(null);
    assertFalse(mv.equals(nulled));
    assertFalse(nulled.equals(mv));
    assertFalse(replica.equals(nulled));
    assertFalse(nulled.equals(replica));
    assertTrue(nulled.equals(nulled));
    assertFalse(nulled.equals(null));
    assertTrue(nulled.equals(this.factory.createMarshalledValue(null)));
  }
コード例 #3
0
  /** Test method for {@link org.jboss.ha.framework.server.SimpleMarshalledValue#get()}. */
  @Test
  public void get() throws Exception {
    GUID guid = new GUID();
    SimpleMarshalledValue<GUID> mv = this.factory.createMarshalledValue(guid);

    assertNotNull(mv.peek());
    assertSame(guid, mv.peek());
    assertSame(guid, mv.get(this.context));

    SimpleMarshalledValue<GUID> copy = replicate(mv);

    assertNull(copy.peek());

    GUID guid2 = copy.get(this.context);
    assertNotSame(guid, guid2);
    assertEquals(guid, guid2);

    copy = replicate(copy);
    guid2 = copy.get(this.context);
    assertEquals(guid, guid2);

    mv = this.factory.createMarshalledValue(null);
    assertNull(mv.peek());
    assertNull(mv.getBytes());
    assertNull(mv.get(this.context));
  }
コード例 #4
0
 <T> void validateHashCode(T original, SimpleMarshalledValue<T> copy) {
   assertEquals(0, copy.hashCode());
 }