1 16 package org.apache.cocoon; 17 18 24 public class CalcTestCase 25 extends HtmlUnitTestCase 26 { 27 final String pageurl = "/samples/flow/jxcalc/"; 28 final String submitXPath = "html/body//form/@action"; 29 final String resultXPath = "html/body//form/p[contains(text(),'Result')]/strong"; 30 31 public void testCalc() 32 throws Exception 33 { 34 loadHtmlPage(pageurl); 35 final String cont1 = evalXPath(submitXPath); 36 assertNotNull("cont1", cont1); 37 38 loadHtmlPage(pageurl+cont1+"?a=1"); 39 final String cont2 = evalXPath(submitXPath); 40 assertNotNull("cont2", cont2); 41 42 loadHtmlPage(pageurl+cont2+"?b=2"); 43 final String cont3 = evalXPath(submitXPath); 44 assertNotNull("cont3", cont3); 45 46 loadHtmlPage(pageurl+cont3+"?operator=plus"); 47 final String result1 = evalXPath(resultXPath); 48 assertEquals("result1", "3.0", result1); 49 50 52 loadHtmlPage(pageurl+cont2+"?b=4"); 53 final String cont4 = evalXPath(submitXPath); 54 assertNotNull("cont4", cont4); 55 56 loadHtmlPage(pageurl+cont4+"?operator=minus"); 57 final String result2 = evalXPath(resultXPath); 58 assertEquals("result2", "-3.0", result2); 59 60 62 loadHtmlPage(pageurl+cont4+"?operator=divide"); 63 final String result3 = evalXPath(resultXPath); 64 assertEquals("result3", "0.25", result3); 65 } 66 } 67 | Popular Tags |