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()); } }
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()); }
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()); }
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()); }
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()); }
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")); }
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(); }
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()); } }