Example #1
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);
    }
  }
Example #2
0
  public static boolean importHistory(
      final SecurityNode securityNode, final LocalDate startDate, final LocalDate endDate) {
    boolean result = false;

    final ExecutorService service = Executors.newSingleThreadExecutor();
    final Future<Boolean> future =
        service.submit(new HistoricalImportCallable(securityNode, startDate, endDate));

    try {
      result = 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);
    }

    return result;
  }
  @Test
  public void testCreateCises() {
    for (int i = 0; i < this.numCIS; i++) {
      String cisId;
      String testTitle = "CPA: ";
      LOG.info("[#" + testCaseNumber + "] " + testTitle);

      // Create CIS
      LOG.info("############## CREATED CIS with Id:" + cssId + " (" + cssPassword + ")");
      Future<ICisOwned> futureCis =
          TestCase1096.cisManager.createCis(
              cisName, cisType, cisMembershipCriteria, cisDescription);
      ICisOwned newCis = null;
      assertNotNull("Future new CIS is null", futureCis);

      // Retrieve future CIS
      try {
        newCis = futureCis.get(10, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
        LOG.error("[Error " + e.getLocalizedMessage() + "] " + testTitle, e);
        fail("[Error InterruptedException] " + testTitle);
      } catch (ExecutionException e) {
        LOG.error("[Error " + e.getLocalizedMessage() + "] " + testTitle, e);
        fail("[Error ExecutionException] " + testTitle);
      } catch (TimeoutException e) {
        LOG.error("[Error " + e.getLocalizedMessage() + "] " + testTitle, e);
        fail("[Error TimeoutException] " + testTitle);
      }
      assertNotNull("New CIS is null", newCis);

      // Retrieve CIS id
      cisId = newCis.getCisId();
      cisIds.add(cisId);
      assertNotNull("New CIS id is null", cisIds);

      // Check if the CIS is on the CIS Management registry
      ICis cisRetrieved = TestCase1096.cisManager.getCis(cisId);
      assertNotNull("New CIS is not stored", cisRetrieved);
      assertEquals("New CIS and retrived CIS should be the same but are not", newCis, cisRetrieved);
    }
    LOG.info("Starting simulation and injection of fake activities..");
    ArrayList<String[]> data = new ArrayList<String[]>();
    try {
      URL u = NominalTestCase.class.getClassLoader().getResource("msn-data-xml.csv");
      BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream()));
      CSVParser parser = new CSVParser(br, CSVStrategy.EXCEL_STRATEGY);
      String[] value = parser.getLine();
      while (value != null) {
        data.add(value);
        value = parser.getLine();
      }
    } catch (FileNotFoundException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } catch (IOException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
    long msgCounter = 0;
    for (String[] line : data) {
      msgCounter++;
      TestCase1096.cisManager
          .getCis(cisIds.get(0))
          .getActivityFeed()
          .addActivity(makeMessage(line[1], line[2], "nonsense", "0"), this);
      if (msgCounter > 2000) {
        break;
      }
    }
    LOG.info("cisIds.size(): " + cisIds.size());
    assert (cisIds.size() == this.numCIS);
  }