Beispiel #1
0
 public String execRecognizer() {
   try {
     String inputFile = new File(tmpdir, "input").getAbsolutePath();
     String[] args =
         new String[] {"java", "-classpath", tmpdir + pathSep + CLASSPATH, "Test", inputFile};
     // String cmdLine = "java -classpath "+CLASSPATH+pathSep+tmpdir+" Test " + new File(tmpdir,
     // "input").getAbsolutePath();
     // System.out.println("execParser: "+cmdLine);
     Process process = Runtime.getRuntime().exec(args, null, new File(tmpdir));
     StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
     StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
     stdoutVacuum.start();
     stderrVacuum.start();
     process.waitFor();
     stdoutVacuum.join();
     stderrVacuum.join();
     String output = null;
     output = stdoutVacuum.toString();
     if (stderrVacuum.toString().length() > 0) {
       this.stderrDuringParse = stderrVacuum.toString();
       System.err.println("exec stderrVacuum: " + stderrVacuum);
     }
     return output;
   } catch (Exception e) {
     System.err.println("can't exec recognizer");
     e.printStackTrace(System.err);
   }
   return null;
 }
 public void execute(WorkerProcessContext workerProcessContext) {
   TestListenerInterface sender =
       workerProcessContext.getServerConnection().addOutgoing(TestListenerInterface.class);
   sender.send("message 1", 1);
   sender.send("message 2", 2);
   // crash
   Runtime.getRuntime().halt(1);
 }
 private static boolean isAaptPresent() throws Exception {
   boolean result = true;
   try {
     Process proc = Runtime.getRuntime().exec("aapt");
     BufferedReader br = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
     String line = null;
     while ((line = br.readLine()) != null) {}
   } catch (Exception ex) {
     result = false;
   }
   return result;
 }
Beispiel #4
0
  public String execClass(String className) {
    /* HOW TO GET STDOUT?
    try {
    	ClassLoader cl_new = new DirectoryLoader(new File(tmpdir));
    	Class compiledClass = cl_new.loadClass(className);
    	Method m = compiledClass.getMethod("main");
    	m.invoke(null);
    } catch (Exception ex) {
    	ex.printStackTrace(System.err);
    }
    */

    try {
      String[] args =
          new String[] {
            "java",
            "-classpath",
            tmpdir + pathSep + CLASSPATH,
            className,
            new File(tmpdir, "input").getAbsolutePath()
          };
      // String cmdLine = "java -classpath "+CLASSPATH+pathSep+tmpdir+" Test " + new File(tmpdir,
      // "input").getAbsolutePath();
      // System.out.println("execParser: "+cmdLine);
      Process process = Runtime.getRuntime().exec(args, null, new File(tmpdir));
      StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
      StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
      stdoutVacuum.start();
      stderrVacuum.start();
      process.waitFor();
      stdoutVacuum.join();
      stderrVacuum.join();
      String output = null;
      output = stdoutVacuum.toString();
      if (stderrVacuum.toString().length() > 0) {
        this.stderrDuringParse = stderrVacuum.toString();
        System.err.println("exec stderrVacuum: " + stderrVacuum);
      }
      return output;
    } catch (Exception e) {
      System.err.println("can't exec recognizer");
      e.printStackTrace(System.err);
    }
    return null;
  }
  @Test
  public void testMachine() throws Exception {
    if (!isUnix()) return;

    Process p = Runtime.getRuntime().exec(new String[] {"uname", "-m"});
    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));

    String uname = r.readLine().trim();
    String m = uname;
    assertTrue(m.length() > 0);

    if (m.matches("i\\d86")) m = "i386";
    else if (m.matches("i86pc")) m = "x86";

    if (m.equals("i386") && Platform.is64Bits()) m = "x86_64";

    assertEquals(
        "uname = " + uname + ", Platform.getMachine = " + Platform.getMachine(),
        m,
        Platform.getMachine());
  }
Beispiel #6
0
  @Test
  public void LFTMain() throws Exception {
    JavascriptExecutor js = (JavascriptExecutor) webDriver;
    selenium.open(baseUrl);
    selenium.type("id=id_username", sender);
    selenium.type("id=id_password", "123abc");
    selenium.click("css=input[type=\"submit\"]");

    selenium.waitForPageToLoad("2000");

    System.out.println("First: The page title is " + selenium.getTitle());
    // code to upload file

    driver.findElement(By.linkText("Compose")).click();

    selenium.waitForPageToLoad("3000");

    // Runtime.getRuntime().exec("C:\\Users\\Sneha\\Desktop\\IE.exe");
    Runtime.getRuntime().exec("C:\\Users\\Sneha\\Desktop\\silver_autoit.exe");

    Functions.MyWaitfunc(driver, "//*[@id='uploader_browse']");
    WebElement ele = driver.findElement(By.xpath("//*[@id='uploader_browse']"));
    ele.click();

    // ele.sendKeys("C:\\Users\\Sneha\\Desktop\\Lighthouse.jpg");

    // send secure mail
    // driver.findElement(By.id("secure")).click();

    driver.findElement(By.id("addrin")).sendKeys(recipient);

    driver.findElement(By.id("id_subject")).sendKeys(stringToTest_tc001);

    String torun = "document.getElementById('tinymce').innerHTML='Hi there!'";

    driver.findElement(By.id("addrsubmit")).click();

    /*selenium.waitForPageToLoad("3000");

    		Thread.sleep(100);
    		js.executeScript(torun);

    		System.out.println((String)js.executeScript("return document.title"));

    */

    driver.switchTo().frame("id_body_ifr");

    selenium.typeKeys("//body[@id='tinymce']", "Finally wohoooo!!");
    driver.switchTo().defaultContent();

    driver.findElement(By.id("submitter")).click();

    /* code only if it is LFT

    String per_done="//html/body/div/div[2]/div[4]/form/fieldset/div[9]/div/div/div/div[2]/table[2]/tbody/tr/td[3]/span";
    NoSuchElementException e1 = null;

    // code to wait for file to be uploaded
    for (int second = 0;; second++) {

    	if (second >= 60) {fail("timeout");}
    	try { if (driver.findElement(By.xpath(per_done)).getText().equalsIgnoreCase("548 KB")) break; } catch (Exception e) {}
    	Thread.sleep(1000);


    }
    */
    // mail body

    /* code to run if LFT
    //System.out.println((String)js.
    if((this.doesWebElementExist(driver,By.xpath(per_done))) && (driver.findElement(By.xpath(per_done)).getText().equalsIgnoreCase("548 KB")))

    	{//driver.findElement(By.id("submitter")).click();
    	}

    else
    	throw e1;

    */

    /* this section if confirm dialog pops up!

    this.MyWaitfunc("//html/body/div[4]/div[11]/div/button/span");

          if(driver.findElement(By.xpath("//html/body/div[4]/div[11]/div/button/span")).isDisplayed())

    	driver.findElement(By.xpath("//html/body/div[4]/div[11]/div/button/span")).click();
    else
    	System.out.println("Confirm dialog not up yet!");
    */

    // to check if mail was sent successfully

    String success_str_xpath = "//html/body/div/div[2]/div[3]/ul/li";

    Functions.MyWaitfunc(driver, success_str_xpath);
    if ((Functions.doesWebElementExist(driver, By.xpath(success_str_xpath)))
        && (driver
            .findElement(By.xpath(success_str_xpath))
            .getText()
            .contains("Successfully sent the email")))
      System.out.println("SUCCESS:Mail successfully sent !");
    else {
      System.out.println("FAIL:Mail NOT SENT !");
      System.out.println(driver.findElement(By.xpath(success_str_xpath)).getText());
      Exception e1 = null;
      throw e1;
    }
  }