public void connect() {
   ConnectionFactory factory = new ConnectionFactory();
   try {
     factory.setUsername("guest");
     factory.setPassword("guest");
     factory.setVirtualHost("/");
     factory.setHost("localhost");
     factory.setPort(5672);
     conn = factory.newConnection();
     channel = conn.createChannel();
     String exchangeName = "exchange." + Math.abs((new Random()).nextInt());
     String queueName = "queue";
     String routingKey = "route";
     boolean durable = true;
     channel.exchangeDeclare(exchangeName, "topic", durable);
     channel.queueDeclare(queueName, durable, false, false, null);
     channel.queueBind(queueName, exchangeName, routingKey);
     consumer = new QueueingConsumer(channel);
     channel.basicConsume(queueName, false, consumer);
   } catch (IOException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
 }
 /**
  *
  * <!-- begin-custom-doc -->
  * <!-- end-custom-doc -->
  *
  * @generated This method is called when an activity is destroyed. It is called by the
  *     BusinessWorks Engine and the method must be implemented to release or cleanup any resources
  *     held by this activity.
  */
 @Override
 public void destroy() {
   if (this.getActivityLogger().isDebugEnabled()) {
     activityLogger.debug(
         RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_METHOD_CALLED,
         new Object[] {
           "destroy()",
           activityContext.getActivityName(),
           activityContext.getProcessName(),
           activityContext.getDeploymentUnitName(),
           activityContext.getDeploymentUnitVersion()
         });
   }
   // begin-custom-code
   // add your own business code here
   try {
     channel.close();
     connection.close();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (TimeoutException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   // end-custom-code
   super.destroy();
 }
Beispiel #3
0
 // 通过URL发送get请求,返回请求结果
 public static String queryStringForGet(String url) {
   // 获得HttpGet实例
   HttpGet request = HttpUtil.getHttpGet(url);
   System.out.println("HttpGet");
   String result = null;
   try {
     // 获得HttpResponse实例
     HttpResponse response = HttpUtil.getHttpResponse(request);
     System.out.println("HttpResponse");
     // 判断是否请求成功
     if (AppConstant.HS_OK == response.getStatusLine().getStatusCode()) {
       // 获得返回结果
       result = EntityUtils.toString(response.getEntity());
       return result;
     }
   } catch (ClientProtocolException e) {
     e.printStackTrace();
     result = "error";
     return result;
   } catch (IOException e) {
     e.printStackTrace();
     result = "error";
     return result;
   } catch (TimeoutException e) {
     // TODO: handle exception
     e.printStackTrace();
     result = "error";
     return result;
   }
   return null;
 }
Beispiel #4
0
    /**
     * Don't call this method directly. Use "executeWithFAST" instead, as it properly handles
     * resource acquisition and cleanup.
     *
     * @see FASTExecuteFunction#execute(long)
     */
    private Map<String, Collection<DocumentError>> executeInternal(long timeout)
        throws ContentManagerException {
      // IContentManager fast = getContentManager(m_location, m_callback);
      IContentManager fast = getContentManager(m_collectionName, m_location, m_callback);

      try {
        Map<String, Collection<DocumentError>> failures;
        int retries = 0;
        String purpose = m_callback.getPurpose();
        while (true) {
          String batchid;
          try {
            batchid = executeWithFAST(fast);
            m_docs = null;
            s_logCategory.info(
                String.format("%s: batch %s sent. Waiting %dms.", purpose, batchid, timeout));
            try {
              // Batch succeeded, but there may be a small number of
              // failures
              failures = m_callback.waitUntilDone(timeout);
            } catch (java.util.concurrent.TimeoutException e) {
              // Fail whole batch. The error map will contain an entry for each
              // submitted document, and the error message will mention how the
              // batch timed out.
              Set<String> ids = m_callback.getSubmittedIds();
              failures = new HashMap<String, Collection<DocumentError>>();
              String errormsg =
                  String.format("%s: batch %s reaped after %ds.", purpose, batchid, timeout);
              for (String id : ids) {
                DocumentError error =
                    new DocumentError(id, 1, Action.RESUBMIT, e.toString(), "ESPContentManager");
                failures.put(id, Collections.singleton(error));
              }
              s_logCategory.error(errormsg);
            }
            return failures;
          } catch (TimeoutException exception) {
            int maxRetries = getNumBatchRetries();
            retries++;
            if (retries >= maxRetries) {
              throw exception;
            }
            s_logCategory.warn(
                String.format(
                    "%s: timeout submitting batch. Will retry %d more times.",
                    purpose, maxRetries - retries),
                exception);
            try {
              Thread.sleep(getRetryDelayMillis());
            } catch (InterruptedException e) {
              Thread.currentThread().interrupt();
              throw exception;
            }
          }
        }
      } finally {
        fast.deactivate();
        fast.shutdown();
      }
    }
    private HttpResponse executeRequest(
        final Callable<HttpResponse> task, final long timeout, final TimeUnit unit)
        throws TimeoutException, IOException {
      ExecutorService executor = Executors.newSingleThreadExecutor();
      try {
        Throwable lastCause = null;
        long endTime = System.currentTimeMillis() + unit.toMillis(timeout);
        while (System.currentTimeMillis() < endTime) {
          Future<HttpResponse> result = executor.submit(task);
          try {
            return result.get(timeout, unit);
          } catch (InterruptedException ex) {
            throw new IllegalStateException(ex);
          } catch (ExecutionException ex) {
            lastCause = ex.getCause();

            // HttpURLConnection throws FileNotFoundException on 404 so handle this
            if (lastCause instanceof FileNotFoundException) {
              HttpResponse httpResult = new HttpResponse();
              httpResult.setStatusCode(HttpURLConnection.HTTP_NOT_FOUND);
              return httpResult;
            } else {
              continue;
            }
          }
        }
        TimeoutException toex = new TimeoutException();
        if (lastCause != null) {
          toex.initCause(lastCause);
        }
        throw toex;
      } finally {
        executor.shutdownNow();
      }
    }
  @Parameters("browser")
  @Test
  public void RMO_TC384_PricingSummaryExpandedOverlap_QA_Test(@Optional("FF") String BrowserType)
      throws Exception {

    try {
      this.gc.log.logSetup(this);
      this.gc.log.logInfo("/////Execution Started/////");

      gc.browser.BrowserCloseAllBrowsersBeforeRun();
      gc.browser.BrowserGetBrowserType(BrowserType);
      gc.browser.BrowserGet(Global.BaseUrlRMO_QA);
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMO_Login(Global.RMOLoginUsername, Global.RMOLoginPassword);
      Thread.sleep(Global.Max_Wait);

      gc.rmo.RMOPricing_ClickProperty_QA(Global.RMO_PropertyName2);
      gc.browser.BrowserWaitForPageToLoad();
      gc.browser.BrowserClick("RMOPropertyPage_PropertiesLink_QA");
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMOPricing_SelectFutureWeek();

      // UpdateDateStartDate();
      // UpdateDateEndDate();
      gc.rmo.RMOPricing_UpdateDate();
      gc.rmo.RMOPricing_SelectBAR();

      // gc.browser.BrowserClick("RMOAddNewPricing_Override_xp2btn");
      gc.browser.js.executeScript(
          "arguments[0].scrollIntoView(true);",
          gc.browser.driver.findElement(
              By.cssSelector(
                  "form[data-room-master='1BF'] div.data-table__row div.data-table__row-title")));
      gc.browser
          .driver
          .findElement(
              By.cssSelector(
                  "div.room-master-pricing div.summary-edit__data form[data-room-master='1BF'] div.xpu-section div.data-table__submit button.btn.blue-button span.blue-button__icon"))
          .click();

      gc.rmo.RMOPricing_UpdateRoomUpchargeXP2(Global.XP_Upcharge_Positive);
      gc.browser.BrowserClick("RMOAddNewPricing_CreatePricingBtn");
      gc.browser.BrowserWaitForElementPresent("RMOAddNewPricing_ConfimationAlert", 10);
      gc.browser.BrowserVerifyText("You have successfully created a Pricing Strategy for");

    } catch (ParserConfigurationException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (IOException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (TimeoutException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } finally {
      gc.generic.Env_Teardown();
    }
  }
Beispiel #7
0
        public void run() {
          for (int i = 0; i < mMaxIterations; i++)
            try {
              if (Thread.interrupted()) {
                throw new InterruptedException();
              }
              Integer result = (Integer) mQueue.take();

              System.out.println("iteration = " + result);
            } catch (InterruptedException e) {
              System.out.println(
                  "Thread properly interrupted by " + e.toString() + " in consumerRunnable");
              // This isn't an error - it just means that
              // we've been interrupted by the main Thread.
              return;
            } catch (TimeoutException e) {
              System.out.println("Exception " + e.toString() + " occurred in consumerRunnable");
              // Indicate a timeout.
              mConsumerCounter = TIMEOUT_OCCURRED;
              return;
            } catch (Exception e) {
              System.out.println("Exception " + e.toString() + " occurred in consumerRunnable");
              // Indicate a failure.
              mConsumerCounter = FAILURE_OCCURRED;
              return;
            }
        }
  /**
   * This test will tell the launch to clear the environment variables. We will then check that the
   * variable $HOME cannot be found by the program.
   */
  @Test
  public void testClearingEnvironment() throws Throwable {
    setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
    doLaunch();

    SyncUtil.runToLocation("envTest");
    MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);

    // The program has stored the content of $HOME into a variable called 'home'.
    // Let's verify this variable is 0x0 which means $HOME does not exist.
    final IExpressionDMContext exprDmc =
        SyncUtil.createExpression(stoppedEvent.getDMContext(), "home");
    Query<FormattedValueDMData> query =
        new Query<FormattedValueDMData>() {
          @Override
          protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
            fExpService.getFormattedExpressionValue(
                fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
          }
        };
    try {
      fExpService.getExecutor().execute(query);
      FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
      assertTrue(
          "Expected 0x0 but got " + value.getFormattedValue(),
          value.getFormattedValue().equals("0x0"));
    } catch (InterruptedException e) {
      fail(e.getMessage());
    } catch (ExecutionException e) {
      fail(e.getCause().getMessage());
    } catch (TimeoutException e) {
      fail(e.getMessage());
    }
  }
Beispiel #9
0
  public static void main(String[] args) throws IOException {
    MemcachedClientBuilder builder =
        new XMemcachedClientBuilder(AddrUtil.getAddresses("localhost:11211"));
    MemcachedClient memcachedClient = builder.build();
    try {
      memcachedClient.set("hello", 0, "Hello,xmemcached");
      String value = memcachedClient.get("hello");
      System.out.println("hello=" + value);
      memcachedClient.delete("hello");
      value = memcachedClient.get("hello");
      System.out.println("hello=" + value);
    } catch (MemcachedException e) {
      System.err.println("MemcachedClient operation fail");
      e.printStackTrace();
    } catch (TimeoutException e) {
      System.err.println("MemcachedClient operation timeout");
      e.printStackTrace();
    } catch (InterruptedException e) {
      // ignore
    }

    try {
      // close memcached client
      memcachedClient.shutdown();
    } catch (IOException e) {
      System.err.println("Shutdown MemcachedClient fail");
      e.printStackTrace();
    }
  }
 /**
  *
  * <!-- begin-custom-doc -->
  * <!-- end-custom-doc -->
  *
  * @generated This method is called to initialize the activity. It is called by the BusinessWorks
  *     Engine once for a particular activity lifetime.
  * @throws ActivityLifecycleFault Thrown if the activity initialization is unsuccessful or
  *     encounters an error.
  */
 @Override
 public void init() throws ActivityLifecycleFault {
   if (this.getActivityLogger().isDebugEnabled()) {
     activityLogger.debug(
         RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_METHOD_CALLED,
         new Object[] {
           "init()",
           activityContext.getActivityName(),
           activityContext.getProcessName(),
           activityContext.getDeploymentUnitName(),
           activityContext.getDeploymentUnitVersion()
         });
   }
   // begin-custom-code
   ConnectionFactory factory = new ConnectionFactory();
   factory.setHost(activityConfig.getHost());
   try {
     factory.setPort(Integer.parseInt(activityConfig.getPort()));
   } catch (NumberFormatException ex) {
     factory.setPort(5672);
   }
   try {
     connection = factory.newConnection();
     channel = connection.createChannel();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (TimeoutException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   // end-custom-code
   super.init();
 }
Beispiel #11
0
  public void schedule() throws Exception {
    try {
      final int incompleteTaskNum =
          scheduledRequests.leafTaskNum() + scheduledRequests.nonLeafTaskNum();
      if (incompleteTaskNum == 0) {
        needWakeup.set(true);
        // all task is done or tasks is not scheduled
        synchronized (schedulingThread) {
          schedulingThread.wait(1000);
        }
      } else {
        LinkedList<TaskRequestEvent> taskRequests = createTaskRequest(incompleteTaskNum);

        if (taskRequests.size() == 0) {
          synchronized (schedulingThread) {
            schedulingThread.wait(schedulerDelay);
          }
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Get " + taskRequests.size() + " taskRequestEvents ");
          }

          if (isLeaf) {
            scheduledRequests.assignToLeafTasks(taskRequests);
          } else {
            scheduledRequests.assignToNonLeafTasks(taskRequests);
          }
        }
      }
    } catch (TimeoutException e) {
      LOG.error(e.getMessage());
    }
  }
  /**
   * Entry point. All recent finished azkaban jobs' lineage. Will write to database stagging table
   *
   * @param timeFrame in minutes
   * @param endTimeStamp in millisecond
   * @throws Exception
   */
  public void run(int timeFrame, long endTimeStamp) throws Exception {
    // get recent finished job
    AzJobChecker azJobChecker = new AzJobChecker(prop);
    List<AzkabanJobExecRecord> jobExecList =
        azJobChecker.getRecentFinishedJobFromFlow(timeFrame, endTimeStamp);
    azJobChecker.close();
    logger.info("Total number of azkaban jobs : {}", jobExecList.size());

    ActorSystem actorSystem = ActorSystem.create("LineageExtractor");
    int numOfActor = Integer.valueOf(prop.getProperty(Constant.LINEAGE_ACTOR_NUM, "50"));
    ActorRef lineageExtractorActor =
        actorSystem.actorOf(
            Props.create(AzLineageExtractorActor.class)
                .withRouter(new SmallestMailboxRouter(numOfActor)),
            "lineageExtractorActor");

    // initialize
    // AzkabanServiceCommunicator asc = new AzkabanServiceCommunicator(prop);
    HadoopNameNodeExtractor hnne = new HadoopNameNodeExtractor(prop);
    AzDbCommunicator adc = new AzDbCommunicator(prop);

    String wherehowsUrl = prop.getProperty(Constant.WH_DB_URL_KEY);
    String wherehowsUserName = prop.getProperty(Constant.WH_DB_USERNAME_KEY);
    String wherehowsPassWord = prop.getProperty(Constant.WH_DB_PASSWORD_KEY);
    String connUrl =
        wherehowsUrl + "?" + "user="******"&password="******"stg_job_execution_data_lineage");

    AzLogParser.initialize(conn);
    PathAnalyzer.initialize(conn);
    int timeout = 30; // default 30 minutes for one job
    if (prop.containsKey(Constant.LINEAGE_ACTOR_TIMEOUT_KEY))
      timeout = Integer.valueOf(prop.getProperty(Constant.LINEAGE_ACTOR_TIMEOUT_KEY));
    List<Future<Object>> result = new ArrayList<>();
    for (AzkabanJobExecRecord aje : jobExecList) {
      AzExecMessage message = new AzExecMessage(aje, prop);
      message.asc = null;
      message.hnne = hnne;
      message.adc = adc;
      message.databaseWriter = databaseWriter;
      message.connection = conn;
      Timeout t = new Timeout(timeout, TimeUnit.SECONDS);
      Future<Object> fut = Patterns.ask(lineageExtractorActor, message, t);
      result.add(fut);
    }

    // join all threads
    Future<Iterable<Object>> seq = Futures.sequence(result, actorSystem.dispatcher());
    try {
      Await.result(seq, Duration.create(timeout + " seconds"));
    } catch (TimeoutException exception) {
      exception.printStackTrace();
    }

    adc.close();
    hnne.close();
    databaseWriter.close();
    logger.info("All job finished lineage collecting!");
  }
  /**
   * This test will tell the launch to set the working directory to data/launch/bin/ and will verify
   * that we can find the file LaunchConfigurationAndRestartTestApp.cpp. This will confirm that GDB
   * has been properly configured with the working dir.
   */
  @Test
  public void testSettingWorkingDirectory() throws Throwable {
    IPath path = new Path(fFullProgramPath);
    String dir = path.removeLastSegments(4).toPortableString() + "/" + EXEC_PATH;
    setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir);
    setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + EXEC_NAME);

    doLaunch();

    Query<MIInfo> query =
        new Query<MIInfo>() {
          @Override
          protected void execute(DataRequestMonitor<MIInfo> rm) {
            fGdbControl.queueCommand(
                fGdbControl
                    .getCommandFactory()
                    .createMIFileExecFile(fGdbControl.getContext(), EXEC_NAME),
                rm);
          }
        };
    try {
      fExpService.getExecutor().execute(query);
      query.get(500, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      fail(e.getMessage());
    } catch (ExecutionException e) {
      fail(e.getCause().getMessage());
    } catch (TimeoutException e) {
      fail(e.getMessage());
    }
  }
  @Override
  public void onDestroy() {
    super.onDestroy();
    if (timer != null) {
      timer.cancel();
      timer.purge();
    }
    Log.d("Aptoide-RabbitMqService", "RabbitMqService Destroyed!");

    try {

      isRunning = false;

      if (channel != null && channel.isOpen()) {
        channel.close();
      }

      if (connection != null && connection.isOpen()) {
        connection.close();
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (ShutdownSignalException e) {
      e.printStackTrace();
    } catch (TimeoutException e) {
      e.printStackTrace();
    }

    Aptoide.setWebInstallServiceRunning(false);
  }
  @Test
  public void testStormZkRoot() {
    String stormRoot = "/storm-zk-root";

    List<String> children = null;

    try {
      children = zkClient.get().getChildren(stormRoot, null);
    } catch (KeeperException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (TimeoutException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    for (String string : children) {
      System.out.println(string);
    }
  }
  /**
   * This test will tell the launch to set some arguments for the program. We will then check that
   * the program has the same arguments.
   */
  @Test
  public void testSettingArguments() throws Throwable {
    setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "1 2 3\n4 5 6");
    doLaunch();

    MIStoppedEvent stoppedEvent = getInitialStoppedEvent();

    // Check that argc is correct
    final IExpressionDMContext argcDmc =
        SyncUtil.createExpression(stoppedEvent.getDMContext(), "argc");
    Query<FormattedValueDMData> query =
        new Query<FormattedValueDMData>() {
          @Override
          protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
            fExpService.getFormattedExpressionValue(
                fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
          }
        };
    try {
      fExpService.getExecutor().execute(query);
      FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);

      // Argc should be 7: the program name and the six arguments
      assertTrue(
          "Expected 7 but got " + value.getFormattedValue(),
          value.getFormattedValue().trim().equals("7"));
    } catch (InterruptedException e) {
      fail(e.getMessage());
    } catch (ExecutionException e) {
      fail(e.getCause().getMessage());
    } catch (TimeoutException e) {
      fail(e.getMessage());
    }

    // Check that argv is also correct.  For simplicity we only check the last argument
    final IExpressionDMContext argvDmc =
        SyncUtil.createExpression(stoppedEvent.getDMContext(), "argv[argc-1]");
    Query<FormattedValueDMData> query2 =
        new Query<FormattedValueDMData>() {
          @Override
          protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
            fExpService.getFormattedExpressionValue(
                fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
          }
        };
    try {
      fExpService.getExecutor().execute(query2);
      FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
      assertTrue(
          "Expected \"6\" but got " + value.getFormattedValue(),
          value.getFormattedValue().trim().endsWith("\"6\""));
    } catch (InterruptedException e) {
      fail(e.getMessage());
    } catch (ExecutionException e) {
      fail(e.getCause().getMessage());
    } catch (TimeoutException e) {
      fail(e.getMessage());
    }
  }
 @Override
 public T get() throws InterruptedException, ExecutionException {
   try {
     return in.get(timeout, unit);
   } catch (TimeoutException e) {
     throw new ExecutionException(e.getCause());
   }
 }
  @Parameters("browser")
  @Test
  public void ReviewPastWeek_Upcharges(@Optional("FF") String BrowserType) {
    try {
      this.gc.log.logSetup(this);
      this.gc.log.logInfo("/////Execution Started/////");
      gc.browser.BrowserCloseAllBrowser();

      gc.browser.BrowserGetBrowserType(BrowserType);
      gc.browser.BrowserGet(Global.BaseUrlRMO);
      Thread.sleep(5000);

      gc.rmo.RMO_Login(Global.RMOLoginUsername, Global.RMOLoginPassword);
      Thread.sleep(5000);

      gc.rmo.RMOPricing_ClickProperty(Global.RMO_PropertyName1);
      gc.browser.BrowserWaitForPageToLoad();

      /* To Verify Number of days displayed in Calendar */
      int DayCount = gc.generic.findElements("RMOPropertyPricing_WeekDays").size();
      Assert.assertTrue(DayCount == 35, "The calendar have a default view of 35 days");
      gc.browser.BrowserWaitForPageToLoad();

      /* To select the past week */
      gc.rmo.RMOPricing_SelectPastWeek();

      Assert.assertTrue(
          IsWebElementReadOnly("RMOPropertyPricing_Calendar_PastWeek_StartDate"),
          "The WebElement is read only & cannot be edited.");

      /* To verify that each day in past week have BAR Value*/
      Assert.assertTrue(
          GetPastRoomUpchargeValues(),
          "Valid Upcharge values for all room type masters along with their child rooms displayed for each day");

      Assert.assertTrue(
          GetPastPersonUpchargeValues(),
          " Valid Upcharge values for all room type masters along with their child rooms displayed for each day");

      gc.browser.BrowserCloseAllBrowser();

    } catch (ParserConfigurationException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... FAiling the script...!!");
    } catch (SAXException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... FAiling the script...!!");
    } catch (IOException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... FAiling the script...!!");
    } catch (TimeoutException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... FAiling the script...!!");
    } catch (Exception e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    }
  }
 public boolean afterInsert(final Object key, final Object value, final Object version)
     throws CacheException {
   try {
     return put(key, value, version, null);
   } catch (TimeoutException e) {
     LOG.log(Level.FINEST, e.getMessage());
   }
   return false;
 }
  @Parameters("browser")
  @Test
  public void RMO_AddNewPricing_DefaultPerPersonUpcharge_QA_Test(@Optional("FF") String BrowserType)
      throws Exception {

    try {
      this.gc.log.logSetup(this);
      this.gc.log.logInfo("/////Execution Started/////");
      gc.browser.BrowserCloseAllBrowser();

      gc.browser.BrowserGetBrowserType(BrowserType);
      gc.browser.BrowserGet(Global.BaseUrlRMO_QA);
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMO_Login(Global.RMOLoginUsername, Global.RMOLoginPassword);
      Thread.sleep(10000);

      gc.rmo.RMOPricing_ClickProperty_QA(Global.RMO_PropertyName2);
      gc.browser.BrowserWaitForPageToLoad();
      gc.browser.BrowserClick("RMOPropertyPage_PropertiesLink_QA");
      gc.browser.BrowserWaitForPageToLoad();

      gc.browser.BrowserClick("RMOPropertyPage_AddNewPricingButton");
      gc.browser.BrowserWaitForPageToLoad();
      gc.rmo.RMOPricing_SelectDate();
      gc.rmo.RMOPricing_SelectBAR();
      gc.browser.BrowserClick("RMOAddNewPricing_Override_xp2btn");
      gc.rmo.RMOPricing_UpdatePersonUpchargeXP2(Global.XP_Upcharge_Positive);
      gc.browser.BrowserClick("RMOAddNewPricing_Override_RUbtn");
      gc.rmo.RMOPricing_UpdateRoomUpchargeXP2(Global.XP_Upcharge_Positive);
      gc.browser.BrowserClick("RMOAddNewPricing_CreatePricingBtn");
      gc.browser.BrowserWaitForElementPresent(
          "RMOPropertyPricing_PricingConfirmationMessage_QA", 5);
      Thread.sleep(10000);
      Assert.assertTrue(
          gc.browser.BrowserGetTextFromElement("RMOPropertyPricing_PricingConfirmationMessage_QA")
              .contains("You have successfully created a Pricing Strategy"),
          "Confirmation Message dilog is dispalyed");
      /*gc.browser.BrowserVerifyText("You have successfully created a Pricing Strategy for");*/
      gc.browser.BrowserClick("RMOAddNewPricing_Alert_DoneBtn");

      gc.browser.BrowserCloseAllBrowser();

    } catch (ParserConfigurationException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (IOException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (TimeoutException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } finally {
      gc.generic.Env_Teardown();
    }
  }
Beispiel #21
0
 @Test
 public void testCheckConnection() {
   try {
     assertTrue(PlintRobot.getInstance().checkConnection());
   } catch (LintException e) {
     assertFalse(e.getMessage(), true);
   } catch (TimeoutException e) {
     assertFalse(e.getMessage(), true);
   }
 }
Beispiel #22
0
 public void close() {
   try {
     channel.close();
     conn.close();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
 }
Beispiel #23
0
  public static void updateSecurityEvents(final SecurityNode node) {

    final ExecutorService service = Executors.newSingleThreadExecutor();
    final Future<Boolean> future = service.submit(new UpdateSecurityNodeEventsCallable(node));

    try {
      future.get(TIMEOUT, TimeUnit.MINUTES);
      service.shutdown();
    } catch (final InterruptedException | ExecutionException e) { // intentionally interrupted
      logger.log(Level.FINEST, e.getLocalizedMessage(), e);
    } catch (final TimeoutException e) {
      logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
  }
 public boolean putFromLoad(
     final Object key,
     final Object value,
     final long txTimestamp,
     final Object version,
     final boolean minimalPutOverride)
     throws CacheException {
   try {
     return put(key, value, version, null);
   } catch (TimeoutException e) {
     LOG.log(Level.FINEST, e.getMessage());
   }
   return false;
 }
Beispiel #25
0
 /**
  * 测试类
  *
  * @param client
  */
 public void test(MemcachedClient client) {
   try {
     System.out.println(client.get("1"));
     if (client.get("1") == null) {
       client.set("1", 0, "11111111111");
     }
   } catch (TimeoutException e) {
     e.printStackTrace();
   } catch (InterruptedException e) {
     e.printStackTrace();
   } catch (MemcachedException e) {
     e.printStackTrace();
   }
 }
Beispiel #26
0
 public static void main(String[] args) {
   ExecutorService executor = Executors.newFixedThreadPool(2);
   Future<Integer> futureVal1 = executor.submit(new SumToN(100));
   Future<Integer> futureVal2 = executor.submit(new SumToN(1000));
   try {
     System.out.println(futureVal1.get());
     System.out.println(futureVal2.get(2000, TimeUnit.MILLISECONDS));
   } catch (InterruptedException e) {
     e.printStackTrace();
   } catch (ExecutionException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
 }
 @Override
 protected String doInBackground(String... params) {
   String result = null;
   ThreadsRequest request = new ThreadsRequest(UserInformationActivity.this);
   try {
     Log.d("doInBackground", "start request");
     result = request.getThreadListByMemberID(100, 1, Integer.parseInt(memberID));
     Log.d("doInBackground", "returned");
   } catch (IOException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
   return result;
 }
 public V txGet(long timeout, TimeUnit unit) throws ElasticSearchException {
   try {
     return get(timeout, unit);
   } catch (TimeoutException e) {
     throw new ElasticSearchTimeoutException(e.getMessage());
   } catch (InterruptedException e) {
     throw new ElasticSearchInterruptedException(e.getMessage());
   } catch (ExecutionException e) {
     if (e.getCause() instanceof ElasticSearchException) {
       throw (ElasticSearchException) e.getCause();
     } else {
       throw new TransportException("Failed execution", e);
     }
   }
 }
  @Parameters("browser")
  @Test
  public void RMO_TC384_PricingSummaryExpandedOverlap_QA_Test(@Optional("FF") String BrowserType)
      throws Exception {

    try {
      this.gc.log.logSetup(this);
      this.gc.log.logInfo("/////Execution Started/////");

      gc.browser.BrowserCloseAllBrowsersBeforeRun();
      gc.browser.BrowserGetBrowserType(BrowserType);
      gc.browser.BrowserGet(Global.BaseUrlRMO_QA);
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMO_Login(Global.RMOLoginUsername, Global.RMOLoginPassword);
      Thread.sleep(10000);

      gc.rmo.RMOPricing_ClickProperty_QA(Global.RMO_PropertyName2);
      gc.browser.BrowserWaitForPageToLoad();
      gc.browser.BrowserClick("RMOPropertyPage_PropertiesLink_QA");
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMOPricing_SelectFutureWeek();

      // UpdateDateStartDate();
      // UpdateDateEndDate();
      gc.rmo.RMOPricing_UpdateDate();
      gc.rmo.RMOPricing_SelectBAR();

      gc.browser.BrowserClick("RMOAddNewPricing_Override_xp2btn");
      gc.rmo.RMOPricing_UpdateRoomUpchargeXP2(Global.XP_Upcharge_Positive);
      gc.browser.BrowserClick("RMOAddNewPricing_CreatePricingBtn");
      gc.browser.BrowserWaitForElementPresent("RMOAddNewPricing_ConfimationAlert", 5);
      gc.browser.BrowserVerifyText("You have successfully created a Pricing Strategy for");

    } catch (ParserConfigurationException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (IOException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (TimeoutException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } finally {
      gc.generic.Env_Teardown();
    }
  }
 private void stopManagementMachines() {
   try {
     provisioning.stopManagementMachines();
   } catch (final CloudProvisioningException e) {
     // log a warning, don't throw an exception on this failure
     logger.warning(
         "Failed to clean management machines after provisioning failure, reported error: "
             + e.getMessage());
   } catch (final TimeoutException e) {
     // log a warning, don't throw an exception on this failure
     logger.warning(
         "Failed to clean management machines after provisioning failure, the operation timed out ("
             + e.getMessage()
             + ")");
   }
 }