### Question:
XmlConfig extends Config { @Override public <U> U getComponent(Class<U> baseInterface) throws BadConfigException { return getComponent(null, baseInterface); } XmlConfig();  XmlConfig(XmlConfig parent, HierarchicalConfiguration config);  XmlConfig(File file); @Override String getProperty(String key); @Override boolean getBoolean(String key, boolean defaultValue); @Override int getInt(String key, int defaultValue); @Override void setProperty(String key, String value); @Override boolean hasProperty(String key); @Override Config getSubconfig(String key); @Override U getComponent(Class<U> baseInterface); @Override U getComponent(String key, Class<U> baseInterface); @Override InputStream getNestedInputStream(String key); @Override OutputStream getNestedOutputStream(String key); @Override Collection<String> getCollection(String key); @Override void saveTo(OutputStream output);  }### Answer:
@Test public void testXmlComponents() throws BadConfigException, FileNotFoundException { assertTrue(mConfig.hasComponent("filter1")); MethodFilter filter1 = mConfig.getComponent("filter1", MethodFilter.class); assertNotNull(filter1); MethodFilter filter2 = mConfig.getComponentAndInit("filter2", MethodFilter.class); assertNotNull(filter2); MethodFilter filter3 = mConfig.getComponentAndInit("not-in-xml", MethodFilter.class, null); assertNull(filter3); }
@Test(expected = BadConfigException.class) public void testInvalidXmlComponents() throws BadConfigException, FileNotFoundException { MethodFilter filter3 = mConfig.getComponent("filter3", MethodFilter.class); }
@Test(expected = BadConfigException.class) public void testInvalidXmlComponents2() throws BadConfigException, FileNotFoundException { MethodFilter filter3 = mConfig.getComponent("filter3", MethodFilter.class, null); }