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 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 39 import org.netbeans.jemmy.Timeouts; 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.web.test.util.Utils; 45 import org.netbeans.test.gui.web.util.JSPServletResponseWaitable; 46 import org.netbeans.test.gui.web.util.HttpRequestWaitable; 47 import org.netbeans.test.gui.web.util.BrowserUtils; 48 49 public class ExecuteExternalUnixBrowser extends JellyTestCase { 50 private static String workDir = null; 51 private static String webModule = null; 52 private static String wmName = "wm1"; 53 private static String fSep = System.getProperty("file.separator"); 54 private static String iSep = "|"; 55 private static Timeouts tm = null; 56 private static boolean first = true; 57 private static String classes = "Classes"; 58 private static String servletForExecution = "ServletForExecution"; 59 private static String htmlForExecution = null;; 60 private static String wmForExecution = "wmForExecution"; 61 private static String urlToRedirectFromHTML = "RedirectFromHtmlForExecution.html"; 62 private static String jspForExecution = null; 63 private static String pkg = "execution"; 64 private static ExplorerOperator explorer = null; 65 private String servletId = "cebde3e2-e8f1-4421-8a1c-df11dcc6e79a"; 66 private String jspId = "c78eae2b-39f2-4b41-b2be-032e5373d7f4"; 67 private String wmId = "9bc4ac0b-0a21-452a-9e51-ca9df3c2fa04"; 68 private int defaultPort = 1357; 69 private int port = 2468; 70 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>"; 71 72 73 74 public ExecuteExternalUnixBrowser(java.lang.String testName) { 75 super(testName); 76 } 77 78 public static void main(java.lang.String [] args) { 79 junit.textui.TestRunner.run(suite()); 80 } 81 82 public static junit.framework.Test suite() { 84 workDir = System.getProperty("extbrowser.workdir").replace('/', fSep.charAt(0)); 85 webModule = workDir + fSep + wmName; 86 htmlForExecution = webModule + iSep + "html" + iSep + "HtmlFileForExecution"; 87 jspForExecution = webModule + iSep + "jsp" + iSep + "JSPForExecution"; 88 pkg = webModule + iSep + "WEB-INF" + iSep + classes + iSep + pkg; 89 String wmc = System.getProperty("extbrowser.mountcount"); 90 int count = 0; 91 if(wmc != null) { 92 count = new Integer (wmc).intValue(); 93 } 94 if(first) { 95 while(count >0) { 96 Utils.handleDialogAfterNewWebModule(); 97 count--; 98 } 99 first = false; 100 } 101 tm = new Timeouts(); 102 tm.initTimeout("Waiter.WaitingTime", 300000); 104 BrowserUtils.setExternalUnixBrowser(); 105 return new NbTestSuite(ExecuteExternalUnixBrowser.class); 106 } 107 108 public void testExecuteHtml() { 109 HTMLNode node1 = null; 110 111 try { 112 node1 = new HTMLNode(htmlForExecution); 113 }catch(Exception e) { 114 fail("Not found: " + htmlForExecution); 115 } 116 new ExecuteAction().perform(node1); 117 HttpRequestWaitable hrw = new HttpRequestWaitable(urlToRedirectFromHTML, defaultAnswer, defaultPort); 118 Waiter w = new Waiter(hrw); 119 w.setTimeouts(tm); 120 try { 121 w.waitAction(hrw); 122 } catch (Exception e) { 123 e.printStackTrace(); 124 fail("Looks like browser not started or URL not loaded"); 125 } 126 } 127 128 public void testExecuteSevlet() { 129 ServletNode node1 = null; 130 try { 131 node1 = new ServletNode(pkg + iSep + servletForExecution); 132 }catch(Exception e) { 133 fail("Not found: " + servletForExecution); 134 } 135 node1.execute(); 136 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(servletId, defaultAnswer, port); 137 Waiter w = new Waiter(jsrw); 138 w.setTimeouts(tm); 139 try { 140 w.waitAction(jsrw); 141 } catch (Exception e) { 142 e.printStackTrace(); 143 fail("Looks like browser not started or URL not loaded"); 144 } 145 } 146 147 public void testExecuteJSP() { 148 JSPNode node1 = null; 149 try { 150 node1 = new JSPNode(jspForExecution); 151 }catch(Exception e) { 152 fail("Not found: " + jspForExecution); 153 } 154 node1.execute(); 155 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(jspId, defaultAnswer, port); 156 Waiter w = new Waiter(jsrw); 157 w.setTimeouts(tm); 158 try { 159 w.waitAction(jsrw); 160 } catch (Exception e) { 161 e.printStackTrace(); 162 fail("Looks like browser not started or URL not loaded"); 163 } 164 } 165 166 public void testExecuteWebModule() { 167 FolderNode node1 = null; 168 try { 169 node1 = new FolderNode(workDir + fSep + wmForExecution + iSep + "WEB-INF"); 170 }catch(Exception e) { 171 fail("Web Module for execution not found"); 172 } 173 new ExecuteAction().perform(node1); 174 JSPServletResponseWaitable jsrw = new JSPServletResponseWaitable(wmId, defaultAnswer, port); 175 Waiter w = new Waiter(jsrw); 176 w.setTimeouts(tm); 177 try { 178 w.waitAction(jsrw); 179 } catch (Exception e) { 180 e.printStackTrace(); 181 fail("Looks like browser not started or URL not loaded"); 182 } 183 } 184 185 186 } 187 | Popular Tags |