1 25 26 package org.objectweb.jonas.jonasadmin.test.util; 27 28 import org.xml.sax.SAXException ; 29 30 import com.meterware.httpunit.WebConversation; 31 import com.meterware.httpunit.WebImage; 32 import com.meterware.httpunit.WebLink; 33 import com.meterware.httpunit.WebResponse; 34 35 40 public class JonasAdminTree { 41 42 45 private static final String FRAME_TREE = "tree"; 46 47 53 public static boolean treeControlSelected (WebResponse wr, String selectedLink) throws SAXException { 54 boolean isSelected = false; int nbSelectedLink = 0; String attribut; String linkUrl = null; 59 WebLink[] links; 61 try { 62 links = wr.getLinks(); 63 64 for (int i = 0; i < links.length; i++) { 67 attribut = links[i].getAttribute("class"); 68 if (attribut.indexOf("tree-control-selected") != -1) { 69 linkUrl = links[i].getURLString(); 70 nbSelectedLink++; 71 } 72 } 73 74 if (nbSelectedLink == 1) { 75 if (selectedLink.equals(linkUrl)) { 76 isSelected = true; 77 } 78 } 79 } catch (SAXException e) { 80 throw new SAXException ("No link was found : " + e); 81 } 82 83 return isSelected; 84 } 85 86 92 public static WebResponse openTree(WebResponse wr, WebConversation wc) throws Exception { 93 WebImage[] frameTreeImages = wr.getImages(); 94 for (int i = 0; i < frameTreeImages.length; i++) { 95 if (frameTreeImages[i].getSource().indexOf("node_close") != -1) { 96 if (!frameTreeImages[i].getLink().getURLString().endsWith("*mbeans")) { 97 frameTreeImages[i].getLink().click(); 98 wr = wc.getFrameContents(FRAME_TREE); 100 frameTreeImages = wr.getImages(); 102 } 103 } 104 } 105 return wr; 106 } 107 108 } 109 | Popular Tags |