@Test public void fail_to_resolve_file() { RuntimeException realError = new RuntimeException("BOOM"); mockery.checking(new Expectations() { { oneOf(fileHandleResolver).resolve(filename); will(throwException(realError)); } }); try { loader.load(filename); fail(); } catch (Exception e) { assertEquals("Failed to load UI file: " + filename, e.getMessage()); assertSame(e.getCause(), realError); } }
public <T extends UiElement> T load(String filename) { try { Reader reader = fileHandleResolver.resolve(filename).reader(); XmlReader xmlReader = new XmlReader(); XmlReader.Element root = xmlReader.parse(reader); return (T) processXmlTag(root); } catch (Exception e) { throw new MdxException("Failed to load UI file: " + filename, e); } }
UiXmlLoader { public <T extends UiElement> T load(String filename) { try { Reader reader = fileHandleResolver.resolve(filename).reader(); XmlReader xmlReader = new XmlReader(); XmlReader.Element root = xmlReader.parse(reader); return (T) processXmlTag(root); } catch (Exception e) { throw new MdxException("Failed to load UI file: " + filename, e); } } }
UiXmlLoader { public <T extends UiElement> T load(String filename) { try { Reader reader = fileHandleResolver.resolve(filename).reader(); XmlReader xmlReader = new XmlReader(); XmlReader.Element root = xmlReader.parse(reader); return (T) processXmlTag(root); } catch (Exception e) { throw new MdxException("Failed to load UI file: " + filename, e); } } UiXmlLoader(FileHandleResolver fileHandleResolver); }
UiXmlLoader { public <T extends UiElement> T load(String filename) { try { Reader reader = fileHandleResolver.resolve(filename).reader(); XmlReader xmlReader = new XmlReader(); XmlReader.Element root = xmlReader.parse(reader); return (T) processXmlTag(root); } catch (Exception e) { throw new MdxException("Failed to load UI file: " + filename, e); } } UiXmlLoader(FileHandleResolver fileHandleResolver); void addTagHandler(String tagName, UiElementFactory factory, UiElementPopulator... populators); T load(String filename); T load(String filename, Class<T> model); T load(String filename, T model); }
UiXmlLoader { public <T extends UiElement> T load(String filename) { try { Reader reader = fileHandleResolver.resolve(filename).reader(); XmlReader xmlReader = new XmlReader(); XmlReader.Element root = xmlReader.parse(reader); return (T) processXmlTag(root); } catch (Exception e) { throw new MdxException("Failed to load UI file: " + filename, e); } } UiXmlLoader(FileHandleResolver fileHandleResolver); void addTagHandler(String tagName, UiElementFactory factory, UiElementPopulator... populators); T load(String filename); T load(String filename, Class<T> model); T load(String filename, T model);  }