@Test public void testDeleteSingleBranch() throws Exception { // expand first level SWTBotTree tree = getOrOpenView().bot().tree(); refreshAndWait(); // create a branch (no checkout) SWTBotTreeItem localBranchesItem = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand(); SWTBotTreeItem masterNode = localBranchesItem.getNode("master"); masterNode.select(); ContextMenuHelper.clickContextMenu( tree, myUtil.getPluginLocalizedValue("RepoViewCreateBranch.label")); SWTBotShell createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle); createBranchShell.bot().textWithId("BranchName").setText("abc"); createBranchShell.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect(); createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click(); refreshAndWait(); // delete branch // lookup node again. Widget might have changed due to refresh localBranchesItem = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand(); localBranchesItem.getNode("abc").select(); ContextMenuHelper.clickContextMenuSync( tree, myUtil.getPluginLocalizedValue("RepoViewDeleteBranch.label")); refreshAndWait(); SWTBotTreeItem[] items = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).getItems(); assertEquals("Wrong number of branches", 2, items.length); assertEquals("master", items[0].getText()); assertEquals("stable", items[1].getText()); }
/** Import a gzip trace */ @Test public void testGzipImport() { final String traceType = "Test trace : TMF Tests"; final String tracesNode = "Traces [1]"; /* * Actual importing */ openImportWizard(); selectImportFromArchive(fGzipTrace.getAbsolutePath()); selectFolder(ROOT_FOLDER); SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace); assertFalse(checkBox.isEnabled()); SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType); comboBox.setSelection(traceType); importFinish(); /* * Remove .gz extension */ assertNotNull(fGzipTrace); String name = fGzipTrace.getName(); assertNotNull(name); assertTrue(name.length() > 3); String traceName = name.substring(0, name.length() - 3); assertNotNull(traceName); assertFalse(traceName.isEmpty()); /* * Open trace */ SWTBotView projectExplorer = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER); projectExplorer.setFocus(); final SWTBotTree tree = projectExplorer.bot().tree(); /* * This appears to be problematic due to the length of the file name and * the resolution in our CI. */ tree.expandNode(PROJECT_NAME, true); SWTBotTreeItem treeItem = tree.getTreeItem(PROJECT_NAME); fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(tracesNode, treeItem)); treeItem = treeItem.getNode(tracesNode); fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(traceName, treeItem)); treeItem = treeItem.getNode(traceName); treeItem.doubleClick(); SWTBotUtils.waitForJobs(); /* * Check results */ SWTBotTable editor = fBot.activeEditor().bot().table(); String c22 = editor.cell(2, 2); String c10 = editor.cell(1, 0); assertEquals("Type-1", c22); assertEquals("", c10); }
private SWTBotTreeItem getEntry(String ViewTitle, String... path) throws Exception { SWTBotTree browserTree = getTree(ViewTitle); List<String> pathList = new ArrayList<String>(Arrays.asList(path)); SWTBotTreeItem entry = null; while (!pathList.isEmpty()) { String node = pathList.remove(0); if (entry == null) { node = adjustNodeName(browserTree, node); entry = browserTree.getTreeItem(node); } else { // adjust current path, because the label is decorated with the // number of children node = adjustNodeName(entry, node); entry = entry.getNode(node); } if (!pathList.isEmpty()) { // expand entry and wait till // - children are displayed // - next child is visible final String nextNode = !pathList.isEmpty() ? pathList.get(0) : null; expand(entry, true, nextNode); } } return entry; }
/** * Selects an entry in the given tree and optionally expands the selected entry. Takes care that * all attributes and child entries are initialized so that there are no pending background * actions and event notifications. This is necessary to avoid race conditions. * * @param bot the SWT bot * @param tree the given tree * @param expandChild true to expand the child entry * @param path the path to the entry * @return the selected entry as SWTBotTreeItem * @throws Exception the exception */ public static SWTBotTreeItem selectEntry( final SWTWorkbenchBot bot, final SWTBotTree tree, final boolean expandChild, final String... path) { List<String> pathList = new ArrayList<String>(Arrays.asList(path)); SWTBotTreeItem entry = null; while (!pathList.isEmpty()) { String currentPath = pathList.remove(0); if (entry == null) { currentPath = adjustNodeName(tree, currentPath); entry = tree.getTreeItem(currentPath); } else { // adjust current path, because the label is decorated with the // number of children currentPath = adjustNodeName(entry, currentPath); entry = entry.getNode(currentPath); } entry.click(); if (!pathList.isEmpty() || expandChild) { // expand entry and wait till // - children are displayed // - next child is visible final String nextName = !pathList.isEmpty() ? pathList.get(0) : null; expandEntry(bot, entry, nextName); } entry.select(); } return entry; }
/** * Open (expand, file->editor, branch->checkout) * * @throws Exception */ @Test public void testOpen() throws Exception { // expand first level SWTBotTree tree = getOrOpenView().bot().tree(); SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile); item.collapse(); refreshAndWait(); item = myRepoViewUtil.getRootItem(tree, repositoryFile); assertTrue("Item should not be expanded", !item.isExpanded()); item.doubleClick(); assertTrue("Item should be expanded", item.isExpanded()); // open a file in editor item = myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand(); SWTBotTreeItem fileiItem = item.getNode(PROJ1).expand().getNode(FOLDER).expand().getNode(FILE1).select(); fileiItem.doubleClick(); assertTrue(bot.activeEditor().getTitle().equals(FILE1)); bot.activeEditor().close(); // open a branch (checkout) checkoutWithDoubleClick(tree, "master"); String contentMaster = getTestFileContent(); checkoutWithDoubleClick(tree, "stable"); TestUtil.joinJobs(JobFamilies.CHECKOUT); String contentStable = getTestFileContent(); assertNotEquals("Content of master and stable should differ", contentMaster, contentStable); }
@After public void canDeleteEWSApp() { SWTBotView openshiftExplorer = open.viewOpen(OpenShiftUI.Explorer.iView); SWTBotTreeItem account = openshiftExplorer.bot().tree().getAllItems()[0].doubleClick(); // expand account bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S); account .getNode(EWS_APP_NAME + " " + OpenShiftUI.AppType.JBOSS_EWS) .contextMenu(OpenShiftUI.Labels.EXPLORER_DELETE_APP) .click(); bot.waitForShell(OpenShiftUI.Shell.DELETE_APP); bot.button(IDELabel.Button.OK).click(); bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S); assertTrue( "Application still present in the OpenShift Explorer!", account.getItems().length == 0); projectExplorer.show(); projectExplorer.deleteAllProjects(); assertFalse("The project still exists!", bot.tree().getAllItems().length > 0); servers.show(); servers.deleteServer(EWS_APP_NAME + " at OpenShift"); }
public void testCancelTagLibDefenition() { openPage(); openPalette(); // Test open import dialog bot.viewByTitle(ActionItem.View.GeneralPalette.LABEL.getName()).setFocus(); // $NON-NLS-1$ new PaletteView().getToolbarButtonWitTooltip("Import").click(); bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$ // Test open edit TLD dialog bot.button("Browse...").click(); // $NON-NLS-1$ bot.shell("Edit TLD").activate(); // $NON-NLS-1$ delay(); // Test cancel TLD SWTBotTree tree = bot.tree(); delay(); SWTBotTreeItem item = tree.expandNode(JBT_TEST_PROJECT_NAME); delay(); item.getNode("html_basic.tld [h]").select(); // $NON-NLS-1$ //$NON-NLS-2$ delay(); bot.button("Cancel").click(); // $NON-NLS-1$ // Test check fields bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$ assertEquals("", bot.textWithLabel("TLD File:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$ assertEquals("", bot.textWithLabel("Name:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$ assertEquals("", bot.textWithLabel("Default Prefix:").getText()); // $NON-NLS-1$ //$NON-NLS-2$ assertEquals("", bot.textWithLabel("Library URI:").getText()); // $NON-NLS-1$ //$NON-NLS-2$ bot.button("Cancel").click(); // $NON-NLS-1$ }
/** * Select the object <code>next</code> as a subnode of the <code>currentNode</code>. * * @param currentNode the currentNode * @param next the subnode to select * @return the selected node */ private SWTBotTreeItem selectSubNode(SWTBotTreeItem currentNode, Object next) { final AdapterFactory adapterFactory = EEFRuntimePlugin.getDefault().getAdapterFactory(); final IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(next, IItemLabelProvider.class); final String text = labelProvider.getText(next); final SWTBotTreeItem node2 = currentNode.getNode(text); node2.select(); return node2; }
@Test public void testDeleteFileNotInProject() throws Exception { SWTBotTree tree = getOrOpenView().bot().tree(); refreshAndWait(); SWTBotTreeItem folder = findWorkdirNode(tree, PROJ2, FOLDER); folder.getNode(FILE1).select(); ContextMenuHelper.clickContextMenu( tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label")); SWTBotShell confirm = bot.shell(UIText.DeleteResourcesOperationUI_confirmActionTitle); confirm.bot().button(IDialogConstants.OK_LABEL).click(); bot.waitUntil(shellCloses(confirm)); TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH); folder = findWorkdirNode(tree, PROJ2, FOLDER); assertThat(folder.getNodes(), not(hasItem(FILE1))); assertThat(folder.getNodes(), hasItem(FILE2)); }
/** * Creates Drools Rule and checks result * * @param droolsRuletName */ private void createDroolsRule(String droolsRuleName) { packageExplorer.show(); SWTBotTreeItem tiDroolsRules = packageExplorer.selectTreeItem( DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE, new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME}); tiDroolsRules.select(); eclipse.createNew(EntityType.DROOLS_RULE); bot.textWithLabel(IDELabel.NewDroolsRuleDialog.FILE_NAME).setText(droolsRuleName); bot.textWithLabel(IDELabel.NewDroolsRuleDialog.RULE_PACKAGE_NAME) .setText(DroolsAllBotTests.COM_SAMPLE_TREE_NODE); bot.button(IDELabel.Button.FINISH).click(); bot.sleep(Timing.time1S()); tiDroolsRules.expand(); // Test if new Drools Rule is within package tree view boolean isRuleCreated = true; try { tiDroolsRules.getNode(droolsRuleName); } catch (WidgetNotFoundException wnfe) { isRuleCreated = false; } assertTrue( "New Drools Rule was not created properly. It's not present within Package Explorer", isRuleCreated); // Test if new Drools Rule is opened in editor isRuleCreated = true; try { bot.editorByTitle(droolsRuleName); } catch (WidgetNotFoundException wnfe) { isRuleCreated = false; } assertTrue( "New Drools Rule was not created properly. File " + droolsRuleName + " is not opened in editor", isRuleCreated); }
@Test public void testDeleteFileInProject() throws Exception { SWTBotTree tree = getOrOpenView().bot().tree(); refreshAndWait(); IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1); // Make sure that the refresh doesn't happen on delete and cause a timeout project1.refreshLocal(IResource.DEPTH_INFINITE, null); SWTBotTreeItem folder = findWorkdirNode(tree, PROJ1, FOLDER); folder.getNode(FILE1).select(); ContextMenuHelper.clickContextMenu( tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label")); SWTBotShell confirm = bot.shell("Delete Resources"); confirm.bot().button(IDialogConstants.OK_LABEL).click(); bot.waitUntil(shellCloses(confirm)); TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH); folder = findWorkdirNode(tree, PROJ1, FOLDER); assertThat(folder.getNodes(), not(hasItem(FILE1))); assertThat(folder.getNodes(), hasItem(FILE2)); }
@Test public void seamGenerateEntitiesTest() { bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.NEW).menu(IDELabel.Menu.OTHER).click(); SWTBotShell shell = bot.shell("New"); shell.activate(); shell.bot().tree(0).expandNode("Seam").select("Seam Generate Entities"); shell.bot().button(IDELabel.Button.NEXT).click(); shell.bot().button("Browse...").click(); shell = bot.shell("Seam Web Projects"); shell.activate(); shell.bot().table(0).getTableItem(Properties.SEAM_PROJECT_NAME).click(); open.finish(shell.bot(), IDELabel.Button.OK); shell = bot.shell("Generate Seam Entities"); shell.activate(); shell .bot() .comboBoxWithLabel("Hibernate Console Configuration:") .setSelection(Properties.SEAM_PROJECT_NAME); shell.bot().radio("Reverse engineer from database").click(); shell.bot().button(IDELabel.Button.NEXT).click(); shell.bot().button("Refresh").click(); shell.bot().sleep(TIME_5S); SWTBotTreeItem item = shell.bot().tree(0).getTreeItem("ModeShape"); item.expand(); shell.bot().sleep(TIME_5S); item = item.getNode("ModeShape"); item.expand(); shell.bot().sleep(TIME_5S); item = item.getNode("xmi_model"); item.select(); shell.bot().button("Include...").click(); assertTrue(shell.bot().table(0).cell(0, "Catalog").equals("ModeShape")); assertTrue(shell.bot().table(0).cell(0, "Schema").equals("ModeShape")); assertTrue(shell.bot().table(0).cell(0, "Table").equals("xmi_model")); open.finish(shell.bot()); assertTrue( SWTTestExt.projectExplorer.existsResource( Properties.SEAM_PROJECT_NAME, "src", "main", "org", "domain", Properties.SEAM_PROJECT_NAME, "entity", "XmiModel.java")); assertTrue( SWTTestExt.projectExplorer.existsResource( Properties.SEAM_PROJECT_NAME, "src", "main", "org", "domain", Properties.SEAM_PROJECT_NAME, "entity", "XmiModelId.java")); }
public static void addemailconnector( final SWTGefBot bot, final String name, final String from, final String to, final String subject, final String content) { bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show(); SWTBotTestUtil.selectTabbedPropertyView(bot, "Connectors"); bot.button("Add...").click(); bot.waitUntil(Conditions.shellIsActive("Connectors")); bot.tree().setFocus(); final SWTBotTreeItem wss = bot.tree().getTreeItem("Messaging").expand(); String emailNode = null; for (final String child : wss.getNodes()) { if (child.contains("Email")) { emailNode = child; } } wss.getNode(emailNode).select(); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.textWithLabel("Name *").setText(name); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 0).setText(from); bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 1).setText(to); bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.NEXT_LABEL))); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click(); SWTBotTestUtil.setScriptExpression(bot, "subject", subject, null); // bot.button(IDialogConstants.OK_LABEL).click(); bot.styledText().setText(content); /*bot.sleep(2000); bot.link(0).click(); bot.sleep(2000); bot.button("Yes").click(); bot.sleep(2000); bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click(); SWTBotTestUtil.setScriptExpression( bot, "body", content, null ); */ bot.sleep(5000); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.button(IDialogConstants.FINISH_LABEL).click(); bot.activeEditor().save(); // DiagramEditPart dpart = (DiagramEditPart) // bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart().part(); // MainProcess proc = (MainProcess) dpart.resolveSemanticElement(); // List<Connector> connectors = ModelHelper.getAllItemsOfType(proc, // ProcessPackage.Literals.CONNECTOR); /* for(Connector c : connectors){ if(c.getDefinitionId().equals("email")){ for(ConnectorParameter p : c.getConfiguration().getParameters()){ if("message".equals(p.getKey())){ String htmlContent = ((Expression) p.getExpression()).getContent(); assertEquals("Invalid html content", HTML_CONTENT, htmlContent.replaceAll(" ","").replaceAll("\\s","")); } } }*/ }
private SWTBotTreeItem findWorkdirNode(SWTBotTree tree, String... nodes) throws Exception { SWTBotTreeItem item = myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand(); for (String node : nodes) item = item.getNode(node).expand(); return item; }
@Test public void testServerBuild() { SWTBotTestUtil.createNewDiagram(bot); final SWTBotEditor activeEditor = bot.activeEditor(); final String editorTitle = activeEditor.getTitle(); // System.out.println("editorTitle1 = "+editorTitle1); assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty()); new BotProcessDiagramPropertiesViewFolder(bot) .selectExecutionTab() .selectInstantiationFormTab() .selectLegacy(); new BotGefProcessDiagramEditor(bot).selectElement("Step1"); new BotExecutionDiagramPropertiesView(bot).selectFormTab().selectLegacy(); // get the GEF editor to activate tools final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle); // Create 2 Pools gmfEditor.activateTool("Pool"); gmfEditor.click(200, 500); new BotProcessDiagramPropertiesViewFolder(bot) .selectExecutionTab() .selectInstantiationFormTab() .selectLegacy(); gmfEditor.activateTool("Pool"); gmfEditor.click(200, 800); new BotProcessDiagramPropertiesViewFolder(bot) .selectExecutionTab() .selectInstantiationFormTab() .selectLegacy(); // Save Diagram bot.menu("Diagram").menu("Save").click(); // System.out.println(editorTitle); bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Server"))); // Menu Server > Build... bot.menu("Server").menu("Build...").click(); // shell 'Build' final SWTBotShell shell = bot.shell(Messages.buildTitle); bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle)); // select and check created Diagram in the Tree final SWTBotTree tree = bot.treeWithLabel("Select processes to export"); final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle); // check the diagram to export diagramTreeItem.select().check(); diagramTreeItem.expand(); // Number of pool in the diagram final int poolListSize = diagramTreeItem.getItems().length; // System.out.println("Diagram contains "+ poolListSize + " items"); assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize); // unselect the first pool of the list diagramTreeItem.getNode(0).select(); diagramTreeItem.getNode(0).uncheck(); final Vector<String> poolTitleList = new Vector<String>(3); final int poolTitleListSize = poolTitleList.size(); // check the selected pools for (int i = 1; i < poolTitleListSize; i++) { final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i); poolTitleList.set(i, poolTreeItem.getText()); final String poolName = getItemName(poolTitleList.get(i)); // test the good pool is checked assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked()); assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i)); } // create tmp directory to write diagrams final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar"); tmpBarFolder.mkdirs(); // set the path where files are saved final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath(); bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath); // String tmpBarFolderPath = bot.comboBoxWithLabel(Messages.destinationPath+" *").getText(); // System.out.println("tmpBarFolder = "+tmpBarFolderPath); // click 'Finish' button to close 'Build' shell bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL))); bot.button(IDialogConstants.FINISH_LABEL).click(); // click 'OK' button to close 'Export' shell bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle)); bot.button(IDialogConstants.OK_LABEL).click(); // wait the shell to close before checking creation of files bot.waitUntil(Conditions.shellCloses(shell)); // check pools files exist for (int i = 1; i < poolTitleListSize; i++) { final String tmpPoolTitle = poolTitleList.get(i); final String poolFileName = getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar"; final File poolFile = new File(tmpBarFolderPath, poolFileName); assertTrue("Error: The Pool export must exist", poolFile.exists()); assertTrue("Error: The Pool export must be a file", poolFile.isFile()); } }