1 16 package org.apache.cocoon; 17 18 import java.net.URLEncoder ; 19 20 25 public class WebdavStep3TestCase 26 extends HtmlUnitTestCase 27 { 28 static final String pageurl = "/samples/blocks/webdav/"; 29 32 public void testTraversableGenerator() 33 throws Exception 34 { 35 loadXmlPage(pageurl+"step1/repo/"); 36 addNamespace("collection", "http://apache.org/cocoon/collection/1.0"); 37 38 40 final String xpathName = "/collection:collection/collection:resource/@name"; 41 String name = evalXPath(xpathName); 42 if( name.length() != 0 ) { 43 logger.info("Good, XPath namespaces finally working"); 44 assertXPath(xpathName, "contentA.xml"); 45 } 46 else { 47 logger.info("Damnit, XPath namespaces still not working"); 48 assertXPath("/*[name(.)='collection:collection']/*[name(.)='collection:resource']/@name", "contentA.xml"); 49 } 50 } 51 52 public void testContentB() 53 throws Exception 54 { 55 final String step3url = pageurl+"step3/repo/dir2/contentB.xml"; 56 57 final String xpathTitle = "/html/body/form/p/input[@name='title']/@value"; 58 final String xpathPara1 = "(/html/body/form/p/textarea)[1]"; 59 final String xpathPara2 = "(/html/body/form/p/textarea)[2]"; 60 final String xpathAction = "/html/body/form/@action"; 61 62 final String xpathSuccess = "/page/sourceResult/execution"; 63 final String valueSuccess = "success"; 64 65 final String oldTitle = "Content B"; 66 final String oldPara1 = "First Paragraph"; 67 final String oldPara2 = "Second Paragraph"; 68 69 final String newTitle = "Title changed by WebdavStep3TestCase"; 70 final String newPara1 = "test1"; 71 final String newPara2 = "test2"; 72 73 75 loadHtmlPage(step3url); 76 String action1 = evalXPath(xpathAction); 80 81 83 loadXmlPage(action1+"?title="+URLEncoder.encode(newTitle)+"¶="+URLEncoder.encode(newPara1)+"¶="+URLEncoder.encode(newPara2)); 84 assertXPath(xpathSuccess, valueSuccess); 85 86 88 Thread.sleep(1000); 89 loadHtmlPage(step3url); 90 assertXPath(xpathTitle, newTitle); 91 assertXPath(xpathPara1, newPara1); 92 assertXPath(xpathPara2, newPara2); 93 String action2 = evalXPath(xpathAction); 94 95 97 loadXmlPage(action2+"?title="+URLEncoder.encode(oldTitle)+"¶="+URLEncoder.encode(oldPara1)+"¶="+URLEncoder.encode(oldPara2)); 98 assertXPath(xpathSuccess, valueSuccess); 99 100 102 Thread.sleep(1000); 103 loadHtmlPage(step3url); 104 assertXPath(xpathTitle, oldTitle); 105 assertXPath(xpathPara1, oldPara1); 106 assertXPath(xpathPara2, oldPara2); 107 } 108 } 109 | Popular Tags |