예제 #1
0
파일: Foo.java 프로젝트: gburgett/XFlat
    @Override
    public Foo convert(Element source) throws ConversionException {

      Foo ret = new Foo();
      ret.id = source.getAttributeValue("id", FooIdNs);

      Element fooInt = source.getChild("fooInt");
      if (fooInt != null) {
        try {
          ret.fooInt = Integer.parseInt(fooInt.getText());
        } catch (NumberFormatException ex) {
          throw new ConversionException("Error parsing fooInt", ex);
        }
      }

      return ret;
    }
예제 #2
0
  @Test
  public void test_private_method() {

    Foo foo = new Foo();

    Method m = null;
    try {
      m = foo.getClass().getDeclaredMethod("op", Foo.Op.class, int.class, int.class);
    } catch (NoSuchMethodException nsme) {
      // nsme.printStackTrace();
      fail("NoSuchMethodException: " + nsme.getMessage());
    }
    int result = 0;
    try {
      m.setAccessible(true);
      result = (int) m.invoke(foo, Foo.Op.PLUS, 1, 2);
    } catch (IllegalAccessException iae) {
      fail("IllegalAccessException: " + iae.getMessage());
    } catch (InvocationTargetException ite) {
      fail("InvocationTargetException: " + ite.getMessage());
    }

    assertEquals(3, result);
  }