1 19 20 package org.netbeans.test.gui.web.extbrowser.execution; 21 22 import org.netbeans.jellytools.JellyTestCase; 23 import org.netbeans.jellytools.Bundle; 24 import org.netbeans.jellytools.ExplorerOperator; 25 import org.netbeans.jellytools.NbFrameOperator; 26 27 28 29 import org.netbeans.jellytools.nodes.FolderNode; 30 import org.netbeans.jellytools.nodes.JavaNode; 31 import org.netbeans.jellytools.nodes.HTMLNode; 32 33 34 import org.netbeans.jellytools.actions.ExecuteAction; 35 36 import org.netbeans.junit.NbTestSuite; 37 38 import org.netbeans.jemmy.Timeouts; 39 40 import org.netbeans.jemmy.Waiter; 41 42 import org.netbeans.web.test.nodes.JSPNode; 43 import org.netbeans.web.test.nodes.ServletNode; 44 import org.netbeans.test.gui.web.util.JSPServletResponseWaitable; 45 import org.netbeans.test.gui.web.util.HttpRequestWaitable; 46 import org.netbeans.test.gui.web.util.BrowserUtils; 47 import org.netbeans.web.test.util.Utils; 48 49 import java.io.File ; 50 51 import org.netbeans.jemmy.operators.JTextFieldOperator; 52 import org.netbeans.jemmy.operators.JTextComponentOperator; 53 54 public class ExecuteCLFullPathBrowser extends JellyTestCase { 55 private static String workDir = null; 56 private static String webModule = null; 57 private static String wmName = "wm1"; 58 private static String fSep = System.getProperty("file.separator"); 59 private static Timeouts tm = null; 60 private static String iSep = "|"; 61 private static String classes = "Classes"; 62 private static String servletForExecution = "ServletForExecution"; 63 private static String htmlForExecution = null;; 64 private static String wmForExecution = "wmForExecution"; 65 private static String urlToRedirectFromHTML = "RedirectFromHtmlForExecution.html"; 66 private static String jspForExecution = null; 67 private static String pkg = "execution"; 68 private static ExplorerOperator explorer = null; 69 private static String netscape = null; 70 private static boolean first = true; 71 private String servletId = "cebde3e2-e8f1-4421-8a1c-df11dcc6e79a"; 72 private String jspId = "c78eae2b-39f2-4b41-b2be-032e5373d7f4"; 73 private String wmId = "9bc4ac0b-0a21-452a-9e51-ca9df3c2fa04"; 74 private int defaultPort = 1357; 75 private int port = 2468; 76 private String defaultAnswer = "HTTP/1.0 200 OK\nServer: FFJ Automated Tests SimpleServ\nLast-Modified: Fri, 12 Jul 2002 09:53:56 GMT\nContent-Length: 281\nConnection: close\nContent-Type: text/html\n\n<html>\n<head>\n <title>Tests passed</title>\n</head>\n<body>\n<center><H1>Request Accepted</H1></center>\n</body>\n</html>"; 77 78 79 80 public ExecuteCLFullPathBrowser(java.lang.String testName) { 81 super(testName); 82 } 83 84 public static void main(java.lang.String [] args) { 85 junit.textui.TestRunner.run(suite()); 86 } 87 88 public static junit.framework.Test suite() { 90 workDir = System.getProperty("extbrowser.workdir").replace('/', fSep.charAt(0)); 91 webModule = workDir + fSep + wmName; 92 htmlForExecution = webModule + iSep + "html" + iSep + "HtmlFileForExecution"; 93 jspForExecution = webModule + iSep + "jsp" + iSep + "JSPForExecution"; 94 pkg = webModule + iSep + "WEB-INF" + iSep + classes + iSep + pkg; 95 String wmc = System.getProperty("extbrowser.mountcount"); 96 int count = 0; 97 if(wmc != null) { 98 count = new Integer (wmc).intValue(); 99 } 100 if(first) { 101 while(count >0) { 102 Utils.handleDialogAfterNewWebModule(); 103 count--; 104 } 105 first = false; 106 } 107 netscape = fullPathCommand(); 108 tm = new Timeouts(); 109 tm.initTimeout("Waiter.WaitingTime", 300000); BrowserUtils.setCLBrowser(); 111 BrowserUtils.setCLBrowserCommand(netscape); 112 return new NbTestSuite(ExecuteCLFullPathBrowser.class); 113 } 114 115 public void testExecuteHtml() { 116 NbFrameOperator fo = null; 117 HTMLNode node1 = null; 118 119 try { 120 node1 = new HTMLNode(htmlForExecution); 121 }catch(Exception e) { 122 fail("Not found: " + htmlForExecution); 123 } 124 new ExecuteAction().perform(node1); 125 HttpRequestWaitable hrw = new HttpRequestWaitable(urlToRedirectFromHTML, defaultAnswer, defaultPort); 126 Waiter w = new Waiter(hrw); 127 w.setTimeouts(tm); 128 try { 129 w.waitAction(hrw); 130 } catch (Exception e) { 131 e.printStackTrace(); 132 fail("Looks like browser not started or URL not loaded"); 133 } 134 } 135 136 public void testExecuteSevlet() { 137 ServletNode node1 = null; 138 139 try { 140 node1 = new ServletNode(pkg + iSep + servletForExecution); 141 }catch(Exception e) { 142 fail("Not found: " + servletForExecution); 143 } 144 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(servletId, defaultAnswer, port); 145 node1.execute(); 146 Waiter w = new Waiter(jsrw); 147 w.setTimeouts(tm); 148 try { 149 w.waitAction(jsrw); 150 } catch (Exception e) { 151 e.printStackTrace(); 152 fail("Looks like browser not started or URL not loaded"); 153 } 154 } 155 156 public void testExecuteJSP() { 157 JSPNode node1 = null; 158 159 try { 160 node1 = new JSPNode(jspForExecution); 161 }catch(Exception e) { 162 fail("Not found: " + jspForExecution); 163 } 164 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(jspId, defaultAnswer, port); 165 node1.execute(); 166 Waiter w = new Waiter(jsrw); 167 w.setTimeouts(tm); 168 try { 169 w.waitAction(jsrw); 170 } catch (Exception e) { 171 e.printStackTrace(); 172 fail("Looks like browser not started or URL not loaded"); 173 } 174 } 175 176 public void testExecuteWebModule() { 177 FolderNode node1 = null; 178 179 try { 180 node1 = new FolderNode(workDir + fSep + wmForExecution + iSep + "WEB-INF"); 181 }catch(Exception e) { 182 fail("Web Module for execution not found"); 183 } 184 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(wmId, defaultAnswer, port); 185 new ExecuteAction().perform(node1); 186 Waiter w = new Waiter(jsrw); 187 w.setTimeouts(tm); 188 try { 189 w.waitAction(jsrw); 190 } catch (Exception e) { 191 e.printStackTrace(); 192 fail("Looks like browser not started or URL not loaded"); 193 } 194 } 195 196 private static String fullPathCommand() { 197 String [] paths = null; 198 String command = null; 199 if(System.getProperty("os.name").indexOf("Windows")!=-1) { 200 fail("This test must be extended for Windows platform"); 201 }else { 202 String defBr = System.getProperty("extbrowser.default"); 203 if(defBr.equals("ns4")) 204 paths = new String [] {"/usr/bin/netscape","/usr/local/bin/netscape","/bin/netscape"}; 205 if(defBr.equals("ns6")) 206 paths = new String [] {"/usr/local/netscape6/netscape", "/usr/dt/bin/netscape6","/usr/dt/appconfig/SUNWns6/netscape"}; 207 if(defBr.equals("ns7")) 208 paths = new String [] {"/usr/local/netscape/netscape", "/usr/dt/bin/netscape7","/usr/dt/appconfig/SUNWns7/netscape"}; if(defBr.equals("ie6")) 210 paths = null; } 212 for(int i=0;i<paths.length;i++) { 213 if((new File (paths[i])).exists()) { 214 command = paths[i] + " {URL}"; 215 i = paths.length; 216 } 217 } 218 if(command == null) { 219 StringBuffer reason = new StringBuffer ("Nothing of following commands found on your system : "); 220 for(int i=0;i<paths.length;i++) { 221 reason.append(paths[i] + ";"); 222 } 223 fail(reason.toString()); 224 } 225 return command; 226 } 227 } 228 | Popular Tags |