コード例 #1
0
 @Test
 public void testPublishJsonObject() {
   JsonObject obj = new JsonObject();
   obj.put(TestUtils.randomUnicodeString(100), TestUtils.randomUnicodeString(100))
       .put(TestUtils.randomUnicodeString(100), TestUtils.randomInt());
   testPublish(
       obj,
       (received) -> {
         assertEquals(obj, received);
         assertFalse(obj == received); // Make sure it's copied
       });
 }
コード例 #2
0
 @Test
 public void testPublishJsonArray() {
   JsonArray arr = new JsonArray();
   arr.add(TestUtils.randomUnicodeString(100))
       .add(TestUtils.randomInt())
       .add(TestUtils.randomBoolean());
   testPublish(
       arr,
       (received) -> {
         assertEquals(arr, received);
         assertFalse(arr == received); // Make sure it's copied
       });
 }
コード例 #3
0
ファイル: DatagramTest.java プロジェクト: redhat-italy/vert.x
  @Test
  public void testOptions() {
    DatagramSocketOptions options = new DatagramSocketOptions();
    assertEquals(NetworkOptions.DEFAULT_SEND_BUFFER_SIZE, options.getSendBufferSize());
    int rand = TestUtils.randomPositiveInt();
    assertEquals(options, options.setSendBufferSize(rand));
    assertEquals(rand, options.getSendBufferSize());
    try {
      options.setSendBufferSize(0);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }
    try {
      options.setSendBufferSize(-123);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }

    assertEquals(NetworkOptions.DEFAULT_RECEIVE_BUFFER_SIZE, options.getReceiveBufferSize());
    rand = TestUtils.randomPositiveInt();
    assertEquals(options, options.setReceiveBufferSize(rand));
    assertEquals(rand, options.getReceiveBufferSize());
    try {
      options.setReceiveBufferSize(0);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }
    try {
      options.setReceiveBufferSize(-123);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }

    assertFalse(options.isReuseAddress());
    assertEquals(options, options.setReuseAddress(true));
    assertTrue(options.isReuseAddress());

    assertEquals(NetworkOptions.DEFAULT_TRAFFIC_CLASS, options.getTrafficClass());
    rand = 23;
    assertEquals(options, options.setTrafficClass(rand));
    assertEquals(rand, options.getTrafficClass());
    try {
      options.setTrafficClass(-1);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }
    try {
      options.setTrafficClass(256);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }

    assertFalse(options.isBroadcast());
    assertEquals(options, options.setBroadcast(true));
    assertTrue(options.isBroadcast());

    assertTrue(options.isLoopbackModeDisabled());
    assertEquals(options, options.setLoopbackModeDisabled(false));
    assertFalse(options.isLoopbackModeDisabled());

    assertEquals(-1, options.getMulticastTimeToLive());
    rand = TestUtils.randomPositiveInt();
    assertEquals(options, options.setMulticastTimeToLive(rand));
    assertEquals(rand, options.getMulticastTimeToLive());
    try {
      options.setMulticastTimeToLive(-1);
      fail("Should throw exception");
    } catch (IllegalArgumentException e) {
      // OK
    }

    assertNull(options.getMulticastNetworkInterface());
    String randString = TestUtils.randomUnicodeString(100);
    assertEquals(options, options.setMulticastNetworkInterface(randString));
    assertEquals(randString, options.getMulticastNetworkInterface());

    assertFalse(options.isIpV6());
    assertEquals(options, options.setIpV6(true));
    assertTrue(options.isIpV6());

    testComplete();
  }
コード例 #4
0
 @Test
 public void testPublishString() {
   String str = TestUtils.randomUnicodeString(100);
   testPublish(str);
 }
コード例 #5
0
 @Test
 public void testReplyString() {
   String str = TestUtils.randomUnicodeString(100);
   testReply(str);
 }
コード例 #6
0
 @Test
 public void testSendString() {
   String str = TestUtils.randomUnicodeString(100);
   testSend(str);
 }