コード例 #1
0
ファイル: Utilities.java プロジェクト: artragis/zest-writer
 public static void sleep(int secs) {
   try {
     Thread.sleep(secs * 1000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
コード例 #2
0
 {
   URL url;
   // Load the image icons
   url = Thread.currentThread().getContextClassLoader().getResource("images/nav_left_blue.png");
   if (url != null) {
     packetReceivedIcon = new ImageIcon(url);
   }
   url = Thread.currentThread().getContextClassLoader().getResource("images/nav_right_red.png");
   if (url != null) {
     packetSentIcon = new ImageIcon(url);
   }
   url = Thread.currentThread().getContextClassLoader().getResource("images/photo_portrait.png");
   if (url != null) {
     presencePacketIcon = new ImageIcon(url);
   }
   url =
       Thread.currentThread()
           .getContextClassLoader()
           .getResource("images/question_and_answer.png");
   if (url != null) {
     iqPacketIcon = new ImageIcon(url);
   }
   url = Thread.currentThread().getContextClassLoader().getResource("images/message.png");
   if (url != null) {
     messagePacketIcon = new ImageIcon(url);
   }
   url = Thread.currentThread().getContextClassLoader().getResource("images/unknown.png");
   if (url != null) {
     unknownPacketTypeIcon = new ImageIcon(url);
   }
 }
 public String doCommand(String cmd, String args[]) {
   if (cmd.equals("store")) {
     cmd += "Expression";
   } else if (cmd.equals("assertSelected") || cmd.equals("verifySelected")) {
     if (args[1].startsWith(INDEX_SPECIFIER)) {
       cmd += "Index";
       args[1] = args[1].substring(INDEX_SPECIFIER.length());
     } else if (args[1].startsWith(ID_SPECIFIER)) {
       cmd += "Id";
       args[1] = args[1].substring(ID_SPECIFIER.length());
     } else if (args[1].startsWith(LABEL_SPECIFIER)) {
       cmd += "Label";
       args[1] = args[1].substring(LABEL_SPECIFIER.length());
     } else if (args[1].startsWith(VALUE_SPECIFIER)) {
       cmd += "Value";
       args[1] = args[1].substring(VALUE_SPECIFIER.length());
     } else {
       cmd += "Label";
     }
   } else if (cmd.endsWith("ErrorOnNext") || cmd.endsWith("FailureOnNext")) {
     expectError = true;
     return "OK";
   } else if (cmd.equals("echo")) {
     return "OK," + args[0];
   } else if (cmd.equals("pause")) {
     try {
       Thread.sleep(Integer.parseInt(args[0]));
       return "OK";
     } catch (InterruptedException e) {
       return "ERROR: pause interrupted";
     }
   }
   try {
     String result = super.doCommand(cmd, args);
     if (expectError) {
       throw new SeleniumException("ERROR: Error expected");
     } else {
       return result;
     }
   } catch (SeleniumException e) {
     if (expectError) {
       expectError = false;
       return "OK";
     } else {
       throw e;
     }
   }
 }