コード例 #1
0
  public void testTriggerExceptionsAreStoredAndRethrownWhenNotCaughtImmediately() throws Exception {
    final Exception exception = new RuntimeException("unexpected production code exception");
    Window window1 =
        WindowInterceptor.getModalDialog(
            new Trigger() {
              public void run() throws Exception {
                JDialog dialog = createModalDialog("dialog");
                addHideButton(dialog, "OK");
                dialog.setVisible(true);
                JDialog dialog2 = createModalDialog("dialog2");
                addHideButton(dialog2, "OK");
                dialog2.setVisible(true);
                throw exception;
              }
            });

    Window window2 = WindowInterceptor.getModalDialog(window1.getButton("OK").triggerClick());
    window2.titleEquals("dialog2");
    window2.getButton("OK").click();
    Utils.sleep(1);

    try {
      WindowInterceptor.run(
          new Trigger() {
            public void run() throws Exception {
              JDialog dialog3 = new JDialog();
              addHideButton(dialog3, "OK");
              dialog3.setVisible(true);
            }
          });
      fail();
    } catch (Exception e) {
      assertSame(exception, e.getCause());
    }
  }
コード例 #2
0
  public void testUnknowParams() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_UNKNOWN_PARAMS);

    TextBox runTextBox = uispecDialog.getTextBox(ComponentMatchers.componentLabelFor("run"));
    assertTrue(runTextBox.textEquals("Unkown parameter"));
    assertTrue(runTextBox.iconEquals(GuiUtil.loadIcon("error.png")));

    assertFalse(uispecDialog.getButton("OK").isEnabled());
  }
コード例 #3
0
  public void testUnsupportedParams() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_UNSUPPORTED_PARAMS);

    TextBox runTextBox = uispecDialog.getTextBox(ComponentMatchers.componentLabelFor("run"));
    assertTrue(runTextBox.textEquals("RunParameterDefinition is unsupported."));
    assertTrue(runTextBox.iconEquals(GuiUtil.loadIcon("error.png")));

    assertFalse(uispecDialog.getButton("OK").isEnabled());
  }
コード例 #4
0
 public void testInterceptingAModalDialog() throws Exception {
   Window window =
       WindowInterceptor.getModalDialog(
           new Trigger() {
             public void run() {
               logger.log("triggerRun");
               JDialog dialog = createModalDialog("aDialog");
               addHideButton(dialog, "OK");
               dialog.setVisible(true);
             }
           });
   logger.assertEquals("<log>" + "  <triggerRun/>" + "</log>");
   assertTrue(window.isVisible());
   window.getButton("OK").click();
   logger.assertEquals("<log>" + "  <click button='OK'/>" + "</log>");
   assertFalse(window.isVisible());
 }
コード例 #5
0
  public void testLaunchBuild() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_GOOD_PARAMS);

    uispecDialog.getCheckBox("integrationTest").unselect();
    uispecDialog.getComboBox("environment").select("acceptance");

    uispecDialog.getButton("OK").click();

    ArgumentCaptor<Map> paramMap = ArgumentCaptor.forClass(Map.class);
    verify(requestManager, times(1))
        .runParameterizedBuild(any(Job.class), any(JenkinsConfiguration.class), paramMap.capture());

    Map expectedParamMapValue = paramMap.getValue();
    assertEquals(3, expectedParamMapValue.size());
    assertEquals("false", expectedParamMapValue.get("integrationTest"));
    assertEquals("acceptance", expectedParamMapValue.get("environment"));
    assertEquals("", expectedParamMapValue.get("message"));
  }
コード例 #6
0
 public void testInterceptingAJDialogShownFromAnotherThread() throws Exception {
   Window window =
       WindowInterceptor.getModalDialog(
           new Trigger() {
             public void run() throws Exception {
               thread =
                   new Thread() {
                     public void run() {
                       JDialog dialog = createModalDialog("expected title");
                       addHideButton(dialog, "OK");
                       dialog.setVisible(true);
                     }
                   };
               thread.start();
             }
           });
   window.titleEquals("expected title");
   window.getButton("OK").click();
   assertFalse(window.isVisible());
   window.dispose();
 }
コード例 #7
0
  public void testTriggerExceptionsAreStoredWhenNotCaughtImmediately2() throws Exception {
    final RuntimeException exception = new RuntimeException("unexpected production code exception");
    Window window =
        WindowInterceptor.getModalDialog(
            new Trigger() {
              public void run() throws Exception {
                JDialog dialog = createModalDialog("dialog");
                addHideButton(dialog, "OK");
                dialog.setVisible(true);
                throw exception;
              }
            });

    window.getButton("OK").click();
    Utils.sleep(1);
    try {
      UISpecDisplay.instance().rethrowIfNeeded();
      fail();
    } catch (Exception e) {
      assertSame(exception, e.getCause());
    }
  }
コード例 #8
0
  public void testDisplay() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_GOOD_PARAMS);

    assertEquals("This build requires parameters", uispecDialog.getTitle());

    assertTrue(uispecDialog.getCheckBox("integrationTest").isSelected());

    ComboBox envCombo = uispecDialog.getComboBox("environment");
    assertTrue(envCombo.contains("development", "integration", "acceptance", "production"));
    assertTrue(envCombo.selectionEquals("development"));
    assertTrue(StringUtils.isEmpty(uispecDialog.findSwingComponent(JTextField.class).getText()));

    assertTrue(uispecDialog.getButton("OK").isEnabled());
  }
コード例 #9
0
  /**
   * Method testMainWindowCanBeCreated ...
   *
   * @throws Exception when
   */
  @Test()
  public void testMainWindowCanBeCreated() throws Exception {
    Assert.assertNotNull(window);

    Assert.assertTrue(window.isEnabled().isTrue());
  }
コード例 #10
0
 public void testInterceptingUsingAButtonTrigger() throws Exception {
   Button button = new Button(new JButton(new ShowDialogAction(true)));
   Window window = WindowInterceptor.getModalDialog(button.triggerClick());
   window.titleEquals("MyDialog");
   window.dispose();
 }