Exemplo n.º 1
0
  protected int streamThroughFailing(XMLInputFactory f, String contents, String msg)
      throws XMLStreamException {
    int result = 0;
    try {
      XMLStreamReader sr = constructStreamReader(f, contents);
      result = streamThrough(sr);
    } catch (XMLStreamException ex) { // good
      if (PRINT_EXP_EXCEPTION) {
        System.out.println(
            "Expected failure: '" + ex.getMessage() + "' " + "(matching message: '" + msg + "')");
      }
      return 0;
    } catch (RuntimeException ex2) { // ok
      if (PRINT_EXP_EXCEPTION) {
        System.out.println(
            "Expected failure: '" + ex2.getMessage() + "' " + "(matching message: '" + msg + "')");
      }
      return 0;
    } catch (Throwable t) { // not so good
      fail("Expected an XMLStreamException or RuntimeException for " + msg + ", got: " + t);
    }

    fail("Expected an exception for " + msg);
    return result; // never gets here
  }