Exemplo n.º 1
0
 @Test
 public void testSetHeaderTwice() {
   final HeaderCheck check = new HeaderCheck();
   check.setHeader("Header");
   try {
     check.setHeader("Header2");
     fail("ConversionException is expected");
   } catch (ConversionException ex) {
     assertEquals(
         "header has already been set - " + "set either header or headerFile, not both",
         ex.getMessage());
   }
 }
Exemplo n.º 2
0
  @Test
  public void testIoExceptionWhenLoadingHeader() throws Exception {
    final HeaderCheck check = PowerMockito.spy(new HeaderCheck());
    PowerMockito.doThrow(new IOException("expected exception"))
        .when(check, "loadHeader", anyObject());

    try {
      check.setHeader("header");
      fail("Exception expected");
    } catch (ConversionException ex) {
      assertTrue(ex.getCause() instanceof IOException);
      assertEquals("unable to load header", ex.getMessage());
    }
  }