| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  | package org.kuali.student.core.web; | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  | import static org.junit.Assert.assertNotNull; | 
            
  
    | 19 |  |  | 
            
  
    | 20 |  | import java.io.IOException; | 
            
  
    | 21 |  | import java.net.MalformedURLException; | 
            
  
    | 22 |  | import java.net.URL; | 
            
  
    | 23 |  |  | 
            
  
    | 24 |  | import org.junit.Test; | 
            
  
    | 25 |  |  | 
            
  
    | 26 |  | import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; | 
            
  
    | 27 |  | import com.gargoylesoftware.htmlunit.WebClient; | 
            
  
    | 28 |  | import com.gargoylesoftware.htmlunit.html.HtmlForm; | 
            
  
    | 29 |  | import com.gargoylesoftware.htmlunit.html.HtmlInput; | 
            
  
    | 30 |  | import com.gargoylesoftware.htmlunit.html.HtmlPage; | 
            
  
    | 31 |  | import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; | 
            
  
    | 32 |  | import com.gargoylesoftware.htmlunit.html.HtmlTextInput; | 
            
  
    | 33 |  |  | 
            
  
    | 34 |  |  | 
            
  
    | 35 |  |  | 
            
  
    | 36 |  |  | 
            
  
    | 37 |  |  | 
            
  
    | 38 |  |  | 
            
  
    | 39 |  |  | 
            
  
    | 40 |  |  | 
            
  
    | 41 |  |  | 
            
  
    | 42 |  |  | 
            
  
    | 43 |  |  | 
            
  
    | 44 |  |  | 
            
  
    | 45 |  |  | 
            
  
    | 46 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 33 (33) | Complexity: 11 | Complexity Density: 0.5 |  | 
  
  
    | 47 |  | public class Page { | 
            
  
    | 48 |  |  | 
            
  
    | 49 |  | private WebClient webClient = new WebClient(); | 
            
  
    | 50 |  | private HtmlPage page; | 
            
  
    | 51 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 1 | Complexity Density: - |  | 
  
  
    | 52 | 0 |  public Page(){... | 
            
  
    | 53 |  | } | 
            
  
    | 54 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 2 (2) | Complexity: 1 | Complexity Density: 0.5 |  | 
  
  
    | 55 | 0 |  public Page(String url) throws FailingHttpStatusCodeException, MalformedURLException, IOException{... | 
            
  
    | 56 | 0 | page = webClient.getPage(url); | 
            
  
    | 57 | 0 | webClient.waitForBackgroundJavaScript(10000); | 
            
  
    | 58 |  | } | 
            
  
    | 59 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 2 (2) | Complexity: 1 | Complexity Density: 0.5 |  | 
  
  
    | 60 | 0 |  public Page(URL url) throws FailingHttpStatusCodeException, IOException{... | 
            
  
    | 61 | 0 | page = webClient.getPage(url); | 
            
  
    | 62 | 0 | webClient.waitForBackgroundJavaScript(10000); | 
            
  
    | 63 |  | } | 
            
  
    | 64 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 2 (2) | Complexity: 1 | Complexity Density: 0.5 |  | 
  
  
    | 65 | 0 |  public void setPage(String url) throws FailingHttpStatusCodeException, MalformedURLException, IOException{... | 
            
  
    | 66 | 0 | page = webClient.getPage(url); | 
            
  
    | 67 | 0 | webClient.waitForBackgroundJavaScript(10000); | 
            
  
    | 68 |  | } | 
            
  
    | 69 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 2 (2) | Complexity: 1 | Complexity Density: 0.5 |  | 
  
  
    | 70 | 0 |  public void setPage(URL url) throws FailingHttpStatusCodeException, IOException{... | 
            
  
    | 71 | 0 | page = webClient.getPage(url); | 
            
  
    | 72 | 0 | webClient.waitForBackgroundJavaScript(10000); | 
            
  
    | 73 |  | } | 
            
  
    | 74 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 75 | 0 |  public HtmlPage getPage(){... | 
            
  
    | 76 | 0 | return page; | 
            
  
    | 77 |  | } | 
            
  
    | 78 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 79 | 0 |  public void setWebClient(WebClient webClient){... | 
            
  
    | 80 | 0 | this.webClient = webClient; | 
            
  
    | 81 |  | } | 
            
  
    | 82 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 83 | 0 |  public WebClient getWebClient(){... | 
            
  
    | 84 | 0 | return webClient; | 
            
  
    | 85 |  | } | 
            
  
    | 86 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 9 (9) | Complexity: 1 | Complexity Density: 0.11 |  | 
  
  
    | 87 | 0 |  public HtmlPage logIn(String user, String password) throws IOException{... | 
            
  
    | 88 | 0 | HtmlForm form = page.getElementByName("f"); | 
            
  
    | 89 | 0 | HtmlTextInput userInput = form.getInputByName("j_username"); | 
            
  
    | 90 | 0 | HtmlPasswordInput passwordInput = form.getInputByName("j_password"); | 
            
  
    | 91 | 0 | HtmlInput submit = form.getInputByName("submit"); | 
            
  
    | 92 |  |  | 
            
  
    | 93 | 0 | userInput.setValueAttribute(user); | 
            
  
    | 94 | 0 | passwordInput.setValueAttribute(password); | 
            
  
    | 95 |  |  | 
            
  
    | 96 | 0 | page = submit.click(); | 
            
  
    | 97 |  |  | 
            
  
    | 98 | 0 | webClient.waitForBackgroundJavaScript(10000); | 
            
  
    | 99 |  |  | 
            
  
    | 100 | 0 | return page; | 
            
  
    | 101 |  | } | 
            
  
    | 102 |  |  | 
            
  
    | 103 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 104 | 0 |  public HtmlPage bypass() throws IOException{... | 
            
  
    | 105 | 0 | return this.logIn("a", "a"); | 
            
  
    | 106 |  | } | 
            
  
    | 107 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 108 | 0 |  @Test... | 
            
  
    | 109 |  | public void defaultTest(){ | 
            
  
    | 110 | 0 | assertNotNull(this.webClient); | 
            
  
    | 111 |  | } | 
            
  
    | 112 |  |  | 
            
  
    | 113 |  | } | 
            
  
    | 114 |  |  |