public AttributeList getAttributeList(Element e) throws ConfigurationException { AttributeList attributeList = new AttributeList(); List childs = e.getChildren("attr"); for (Object child : childs) { Element childElement = (Element) child; String name = childElement.getAttributeValue("name"); name = getAttributeName(name); Attribute attr = new Attribute(name, getObject(childElement)); attributeList.add(attr); } return attributeList; }
/** Creats a collection from a definition element with the format. * <PRE> * <{attr|item} type="..."> * <item [type="..."]>...</item> * ... * </attr> * </PRE> * @param type class type * @param e the Element * @throws ConfigurationException * @return the object collection */ @SuppressWarnings("unchecked") protected Collection getCollection(Class type, Element e) throws ConfigurationException { try{ Collection<Object> col = (Collection<Object>) type.newInstance(); for (Object o : e.getChildren("item")) { col.add(getObject((Element) o)); } return col; }catch(Exception e1){ throw new ConfigurationException(e1); } } /**
@Test public void testGetObjectThrowsNullPointerException() throws Throwable { QFactory qFactory = new QFactory(new ObjectName(""), null); try { qFactory.getObject(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testGetObject() throws Throwable { QFactory qFactory = new QFactory(new ObjectName(""), null); String result = (String) qFactory.getObject(new Element("testQFactoryName", "testQFactoryPrefix", "testQFactoryUri")); assertEquals("result", "", result); }