コード例 #1
0
 @Test
 public void testNullInputStream() {
   try {
     new CompactMagicEnvelopeDeserializer().deserialize(null);
     Assert.fail("Should have received an IllegalArgumentException");
   } catch (IllegalArgumentException iae) {
     Assert.assertEquals("Cannot deserialize from null input stream.", iae.getMessage());
   } catch (Exception e) {
     Assert.fail("Expecting an IllegalArgumentException not a " + e.getClass().getName());
   }
 }
コード例 #2
0
  @Test
  public void sendShouldFailWithUnmappedName() {
    // Given
    Mapping mapping = partialMapping();
    MappedApi service = service(mapping);

    // When
    String message = null;
    try {
      service.mappedCall("a", 0L);
      fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
      message = e.getMessage();
    }

    // Then
    assertEquals("no mapping for field: s2", message);
  }