@Test
  public void testUdpPort() throws Exception {
    byte[] md1 = m1.getData();
    byte[] md2 = m2.getData();

    MemberImpl a1 = MemberImpl.getMember(md1);
    MemberImpl a2 = MemberImpl.getMember(md2);

    assertTrue(a1.getUdpPort() == a2.getUdpPort());
    assertTrue(a1.getUdpPort() == udpPort);
  }
Beispiel #2
0
 @Override
 public void setPayload(byte[] payload) {
   this.payload = payload;
   if (localMember != null) {
     localMember.setPayload(payload);
     localMember.getData(true, true);
     try {
       if (impl != null) impl.send(false);
     } catch (Exception x) {
       log.error(sm.getString("McastService.payload"), x);
     }
   }
 }
Beispiel #3
0
 @Override
 public void setDomain(byte[] domain) {
   this.domain = domain;
   if (localMember != null) {
     localMember.setDomain(domain);
     localMember.getData(true, true);
     try {
       if (impl != null) impl.send(false);
     } catch (Exception x) {
       log.error(sm.getString("McastService.domain"), x);
     }
   }
 }
Beispiel #4
0
 /** Sets the local member properties for broadcasting */
 @Override
 public void setLocalMemberProperties(
     String listenHost, int listenPort, int securePort, int udpPort) {
   properties.setProperty("tcpListenHost", listenHost);
   properties.setProperty("tcpListenPort", String.valueOf(listenPort));
   properties.setProperty("udpListenPort", String.valueOf(udpPort));
   properties.setProperty("tcpSecurePort", String.valueOf(securePort));
   try {
     if (localMember != null) {
       localMember.setHostname(listenHost);
       localMember.setPort(listenPort);
     } else {
       localMember = new MemberImpl(listenHost, listenPort, 0);
       localMember.setUniqueId(UUIDGenerator.randomUUID(true));
       localMember.setPayload(getPayload());
       localMember.setDomain(getDomain());
     }
     localMember.setSecurePort(securePort);
     localMember.setUdpPort(udpPort);
     localMember.getData(true, true);
   } catch (IOException x) {
     throw new IllegalArgumentException(x);
   }
 }
  @Test
  public void testSerializationOne() throws Exception {
    MemberImpl m = m1;
    byte[] md1 = m.getData(false, true);
    byte[] mda1 = m.getData(false, false);
    assertTrue(Arrays.equals(md1, mda1));
    assertTrue(md1 == mda1);
    mda1 = m.getData(true, true);
    MemberImpl ma1 = MemberImpl.getMember(mda1);
    assertTrue(compareMembers(m, ma1));
    mda1 = p1.getData(false);
    assertFalse(Arrays.equals(md1, mda1));
    ma1 = MemberImpl.getMember(mda1);
    assertTrue(compareMembers(p1, ma1));

    md1 = m.getData(true, true);
    Thread.sleep(50);
    mda1 = m.getData(true, true);
    MemberImpl a1 = MemberImpl.getMember(md1);
    MemberImpl a2 = MemberImpl.getMember(mda1);
    assertTrue(a1.equals(a2));
    assertFalse(Arrays.equals(md1, mda1));
  }