[Batchserver-cvs] batchserver/test/org/jmonks/batchserver/framework/common FrameworkUtilTest.java,1.
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-06 23:54:24
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv661 Modified Files: FrameworkUtilTest.java Log Message: no message Index: FrameworkUtilTest.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/common/FrameworkUtilTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FrameworkUtilTest.java 4 Mar 2006 04:20:34 -0000 1.2 --- FrameworkUtilTest.java 6 Mar 2006 23:54:21 -0000 1.3 *************** *** 1,7 **** --- 1,15 ---- package org.jmonks.batchserver.framework.common; + import java.util.HashMap; + import java.util.Map; + import javax.xml.parsers.DocumentBuilder; + import javax.xml.parsers.DocumentBuilderFactory; + import javax.xml.parsers.ParserConfigurationException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; + import org.w3c.dom.Document; + import org.w3c.dom.Element; + import org.w3c.dom.Node; public class FrameworkUtilTest extends TestCase *************** *** 35,38 **** --- 43,112 ---- } + public void testLoadPropertiesFromElementToMap() throws Exception + { + Element configElement=null; + Map propertyMap=null; + try + { + FrameworkUtil.loadPropertiesFromElementToMap(configElement,propertyMap); + fail("Accepting the null valuse as input parameters."); + } + catch(IllegalArgumentException exception) + { + /** + * This is as expected. + */ + } + + try + { + FrameworkUtil.loadPropertiesFromElementToMap(configElement,new HashMap()); + fail("Accepting the null element as input parameter "); + } + catch(IllegalArgumentException exception) + { + /** + * This is as expected. + */ + } + + DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder=builderFactory.newDocumentBuilder(); + Document document=documentBuilder.newDocument(); + + configElement=document.createElement("some-config"); + + Element propertyElement1=document.createElement("property"); + propertyElement1.setAttribute("key","config-key1"); + Node textNode1=document.createTextNode("config-value1"); + propertyElement1.appendChild(textNode1); + + Element propertyElement2=document.createElement("property"); + propertyElement1.setAttribute("key","config-key2"); + Node textNode2=document.createCDATASection("This is CDATA section"); + propertyElement2.appendChild(textNode2); + + configElement.appendChild(propertyElement1); + configElement.appendChild(propertyElement2); + + + try + { + FrameworkUtil.loadPropertiesFromElementToMap(configElement,propertyMap); + fail("Accepting the property map uninitialized."); + } + catch(IllegalArgumentException exception) + { + /** + * This is expected. + */ + } + propertyMap=new HashMap(); + FrameworkUtil.loadPropertiesFromElementToMap(configElement, propertyMap); + assertEquals(2,propertyMap.size()); + System.out.println(propertyMap); + System.out.println(configElement); + } + protected void tearDown() throws Exception { |