### Question:
JDOMExternUtil { public static Object readFromString(String str) throws Exception { Document doc = JDOMUtil.loadDocument(str); Element root = doc.getRootElement(); return readFrom(root); } private  JDOMExternUtil(); static void writeTo(Element root, Object obj); static Object readFrom(Element root); static void readTo(Element root, Object obj); static String writeToString(Object data); static String writeToString(String rootName, Object data); static Object readFromString(String str);  }### Answer:
@Test public void testColorWithNewlines() throws Exception { Color c = (Color) JDOMExternUtil.readFromString(CYAN_XML); assertEquals(Color.CYAN, c); c = (Color) JDOMExternUtil.readFromString(CYAN_XML_NL); assertEquals(Color.CYAN, c); }
@Test public void testReadColorPair() throws Exception { Pair pairCyanNull = (Pair)JDOMExternUtil.readFromString(CYAN_NULL_XML); assertEquals(Color.CYAN, pairCyanNull.first); assertEquals(Color.CYAN, pairCyanNull.second); Pair pairCyanBlack = (Pair)JDOMExternUtil.readFromString(CYAN_RED_XML); assertEquals(Color.CYAN, pairCyanBlack.first); assertEquals(Color.RED, pairCyanBlack.second); Object pairWithNoColors = JDOMExternUtil.readFromString(NULL_NULL_XML); assertNull(pairWithNoColors); Object pairIsNull = JDOMExternUtil.readFromString(NULL_XML); assertNull(pairIsNull); }
@Test public void testNewlines() throws Exception { assertEquals(Color.CYAN, JDOMExternUtil.readFromString("<root class=\"java.awt.Color\"> \n -16711681\n </root>")); assertEquals(2.0d, JDOMExternUtil.readFromString("<root class=\"java.lang.Double\"> \n 2.0\n </root>")); assertEquals(2.0f, JDOMExternUtil.readFromString("<root class=\"java.lang.Float\"> \n 2.0\n </root>")); assertEquals((short)2, JDOMExternUtil.readFromString("<root class=\"java.lang.Short\"> \n 2\n </root>")); assertEquals(2, JDOMExternUtil.readFromString("<root class=\"java.lang.Integer\"> \n 2\n </root>")); assertEquals(2l, JDOMExternUtil.readFromString("<root class=\"java.lang.Long\"> \n 2\n </root>")); assertTrue((Boolean)JDOMExternUtil.readFromString("<root class=\"java.lang.Boolean\"> \n True\n </root>")); assertEquals(SampleEnum.VALUE1, JDOMExternUtil.readFromString("<root class=\"com.atlassian.clover.idea.SampleEnum\"> \n VALUE1\n </root>")); }