Ejemplo n.º 1
0
  // XXX shoud be on the spi
  public void testLastRefresh() {
    String parameters =
        "query_format=advanced&"
            + "short_desc_type=allwordssubstr&"
            + "short_desc=whatever112233445566778899&"
            + "product=TestProduct";
    String qname = "q" + System.currentTimeMillis();
    BugzillaQuery q =
        new BugzillaQuery(qname, QueryTestUtil.getRepository(), parameters, true, true, false);
    long lastRefresh = q.getLastRefresh();
    assertEquals(0, lastRefresh);
    long ts = System.currentTimeMillis();

    ts = System.currentTimeMillis();
    q.refresh(parameters, false);
    assertTrue(q.getLastRefresh() >= ts);

    ts = System.currentTimeMillis();
    q.refresh();
    lastRefresh = q.getLastRefresh();
    assertTrue(lastRefresh >= ts);

    // emulate restart
    q = new BugzillaQuery(qname, QueryTestUtil.getRepository(), parameters, true, true, false);
    assertEquals((int) (lastRefresh / 1000), (int) (q.getLastRefresh() / 1000));
  }
Ejemplo n.º 2
0
  @RandomlyFails
  public void testSaveAterSearch()
      throws MalformedURLException, CoreException, NoSuchMethodException, IllegalAccessException,
          IllegalArgumentException, InvocationTargetException, InterruptedException {
    long ts = System.currentTimeMillis();
    String summary = "somary" + ts;
    BugzillaRepository repository = QueryTestUtil.getRepository();
    String id1 = TestUtil.createIssue(repository, summary);

    LogHandler h = new LogHandler("Finnished populate", LogHandler.Compare.STARTS_WITH);

    // create query
    BugzillaQuery q = new BugzillaQuery(repository);

    // get controler and wait until populated with default values
    QueryController c = q.getController();
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    // populate with parameters - summary
    populate(c, summary);

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    // search
    nl.reset();
    h = new LogHandler("refresh finish", LogHandler.Compare.STARTS_WITH);
    search(c); // search button and wait until done
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    assertTrue(nl.started);
    assertTrue(nl.finished);
    List<BugzillaIssue> il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    BugzillaIssue i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());

    // save
    nl.reset();
    String name = QUERY_NAME + ts;
    h = new LogHandler(" saved", LogHandler.Compare.ENDS_WITH);
    save(c, name); // save button
    h.waitUntilDone();
    assertTrue(q.isSaved());
    // create a new repo instance and check if our query is between them
    repository = QueryTestUtil.getRepository();
    Collection<BugzillaQuery> queries = repository.getQueries();
    boolean bl = false;
    for (BugzillaQuery query : queries) {
      bl = query.getDisplayName().equals(name);
      if (bl) break;
    }
    assertTrue(bl);
  }
Ejemplo n.º 3
0
  public void testSaveRemove()
      throws MalformedURLException, CoreException, InterruptedException, NoSuchMethodException,
          IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    long ts = System.currentTimeMillis();

    // create query
    LogHandler h = new LogHandler("Finnished populate", LogHandler.Compare.STARTS_WITH);
    BugzillaQuery q = new BugzillaQuery(QueryTestUtil.getRepository());

    // get controler and wait until populated with default values
    QueryController c = q.getController();
    h.waitUntilDone();
    Collection<BugzillaQuery> qs = QueryTestUtil.getRepository().getQueries();
    int queriesCount = qs.size();

    QueryListener ql = new QueryListener();
    q.addPropertyChangeListener(ql);
    // save
    h = new LogHandler(" saved", LogHandler.Compare.ENDS_WITH);
    save(c, QUERY_NAME + ts);
    h.waitUntilDone();
    assertEquals(1, ql.saved);

    qs = QueryTestUtil.getRepository().getQueries();
    assertEquals(queriesCount + 1, qs.size());

    // remove
    remove(c);
    assertEquals(1, ql.removed);
    qs = QueryTestUtil.getRepository().getQueries();
    assertEquals(queriesCount, qs.size());
  }
Ejemplo n.º 4
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    MockLookup.setLayersAndInstances();
    BugtrackingUtil.getBugtrackingConnectors(); // ensure conector

    System.setProperty("netbeans.user", getWorkDir().getAbsolutePath());
    cleanupStoredIssues();
  }
Ejemplo n.º 5
0
  public void testRefresh() throws MalformedURLException, CoreException, InterruptedException {
    long ts = System.currentTimeMillis();
    String summary = "somary" + ts;
    String id1 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary);

    LogHandler h = new LogHandler("Finnished populate", LogHandler.Compare.STARTS_WITH);

    String p = MessageFormat.format(PARAMETERS_FORMAT, summary);
    BugzillaQuery q =
        new BugzillaQuery(QUERY_NAME, QueryTestUtil.getRepository(), p, true, false, true);
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    nl.reset();
    q.refresh();
    Collection<BugzillaIssue> is = q.getIssues();
    assertEquals(1, is.size());
    assertTrue(nl.started);
    assertTrue(nl.finished);
    List<BugzillaIssue> il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    BugzillaIssue i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());

    nl.reset();
    q.refresh(p, false);
    assertTrue(nl.started);
    assertTrue(nl.finished);
    il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());
    is = q.getIssues();
    assertEquals(1, is.size());
  }
Ejemplo n.º 6
0
  public void testSaveBeforeSearch()
      throws MalformedURLException, CoreException, NoSuchMethodException, IllegalAccessException,
          IllegalArgumentException, InvocationTargetException, InterruptedException {
    long ts = System.currentTimeMillis();
    String summary = "somary" + ts;
    String id1 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary);

    LogHandler h = new LogHandler("Finnished populate ", LogHandler.Compare.STARTS_WITH);

    // create query
    BugzillaQuery q = new BugzillaQuery(QueryTestUtil.getRepository());

    // get controler and wait until populated with default values
    QueryController c = q.getController();
    h.waitUntilDone();

    // populate with parameters - summary
    populate(c, summary);

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);
    nl.reset();
    QueryListener ql = new QueryListener();
    q.addPropertyChangeListener(ql);

    h = new LogHandler("refresh finish", LogHandler.Compare.STARTS_WITH); // we wan't to check
    // if the refresh is made after save
    save(c, QUERY_NAME + ts); // save button
    h.waitUntilDone();
    assertEquals(1, ql.saved);

    assertTrue(nl.started);
    assertTrue(nl.finished);
    List<BugzillaIssue> il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    BugzillaIssue i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());
  }
Ejemplo n.º 7
0
  public void testGetIssues() throws MalformedURLException, CoreException {
    long ts = System.currentTimeMillis();
    String summary1 = "somary1" + ts;
    String id1 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary1);
    String summary2 = "somary2" + ts;
    String id2 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary2);

    // query for issue1
    String p = MessageFormat.format(PARAMETERS_FORMAT, summary1);
    BugzillaQuery q =
        new BugzillaQuery(QUERY_NAME, QueryTestUtil.getRepository(), p, true, false, true);
    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    Collection<BugzillaIssue> bugzillaIssues = q.getIssues();
    assertEquals(0, nl.issues.size());

    nl.reset();
    q.refresh();
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(1, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(1, q.getIssues().size());
    BugzillaIssue i = q.getIssues().iterator().next();
    assertEquals(summary1, i.getSummary());
    assertEquals(id1, i.getID());

    nl.reset();
    q.refresh(p, false);
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(1, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(1, q.getIssues().size());
    i = q.getIssues().iterator().next();
    assertEquals(summary1, i.getSummary());
    assertEquals(id1, i.getID());

    // query for issue1 & issue2
    p = MessageFormat.format(PARAMETERS_FORMAT, ts);
    nl.reset();
    q.refresh(p, false);
    bugzillaIssues = q.getIssues();
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(2, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(2, bugzillaIssues.size());
    List<String> summaries = new ArrayList<String>();
    List<String> ids = new ArrayList<String>();
    for (BugzillaIssue issue : bugzillaIssues) {
      summaries.add(issue.getSummary());
      ids.add(issue.getID());
    }
    assertTrue(summaries.contains(summary1));
    assertTrue(summaries.contains(summary2));
    assertTrue(ids.contains(id1));
    assertTrue(ids.contains(id2));

    //        Collection<Issue> is =
    // BugtrackingUtil.getByIdOrSummary(BugzillaUtil.getQuery(q).getIssues(), "" + ts); // shoud
    // return both issues
    //        assertEquals(2, is.size());
    //        summaries = new ArrayList<String>();
    //        ids = new ArrayList<String>();
    //        for(Issue issue : is) {
    //            summaries.add(issue.getSummary());
    //            ids.add(issue.getID());
    //        }
    //        assertTrue(summaries.contains(summary1));
    //        assertTrue(summaries.contains(summary2));
    //        assertTrue(ids.contains(id1));
    //        assertTrue(ids.contains(id2));
    //
    //        is = BugtrackingUtil.getByIdOrSummary(BugzillaUtil.getQuery(q).getIssues(), summary1);
    // // shoud return 1st issue
    //        assertEquals(1, is.size());
    //        assertEquals(id1, is.iterator().next().getID());
    //        assertEquals(summary1, is.iterator().next().getSummary());
  }