@Test @Ignore // workspace model dosn't show non-workspace files ... yet ;) public void shouldShowCompareEditorForNonWorkspaceFileFromSynchronization() throws Exception { // given String content = "file content"; String name = "non-workspace.txt"; File root = new File(getTestDirectory(), REPO1); File nonWorkspace = new File(root, name); BufferedWriter writer = new BufferedWriter(new FileWriter(nonWorkspace)); writer.append(content); writer.close(); // when launchSynchronization(INITIAL_TAG, HEAD, true); // then SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree(); SWTBotTreeItem workingTree = syncViewTree.expandNode(PROJ1); assertEquals(1, syncViewTree.getAllItems().length); workingTree.expand().getNode(name).doubleClick(); SWTBotEditor editor = bot.editorByTitle(name); editor.setFocus(); // the WidgetNotFoundException will be thrown when widget with given content cannot be not found SWTBotStyledText left = editor.bot().styledText(content); SWTBotStyledText right = editor.bot().styledText(""); // to be complete sure assert that both sides are not the same assertNotSame(left, right); }
@Test public void shouldNotShowIgnoredFiles() throws Exception { // given resetRepositoryToCreateInitialTag(); String ignoredName = "to-be-ignored.txt"; IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1); IFile ignoredFile = proj.getFile(ignoredName); ignoredFile.create( new ByteArrayInputStream("content of ignored file".getBytes(proj.getDefaultCharset())), false, null); IFile gitignore = proj.getFile(".gitignore"); gitignore.create( new ByteArrayInputStream(ignoredName.getBytes(proj.getDefaultCharset())), false, null); proj.refreshLocal(IResource.DEPTH_INFINITE, null); // when launchSynchronization(INITIAL_TAG, HEAD, true); // then SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree(); SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, PROJ1); projectTree.expand(); assertEquals(1, projectTree.getItems().length); }
@Override public boolean test() throws Exception { fParentItem.expand(); for (SWTBotTreeItem item : fParentItem.getItems()) { if (item.getText().matches(fRegex)) { fItem = item; return true; } } return false; }
/** * Select the given element in the given editor. * * @param editor the editor where the bot must process * @param element the element to select * @return the selected node */ public SWTBotTreeItem selectNode(SWTBotTree tree, EObject element) { assertNotNull("The model has not been initialized.", testModelResource); final List<Object> expansionPath = EEFModelHelper.getExpansionPath(element); final Iterator<Object> iterator = expansionPath.iterator(); Object next = null; SWTBotTreeItem node2 = tree.getTreeItem(testModelResource.getURI().toString()); while (iterator.hasNext()) { node2.expand(); next = iterator.next(); node2 = selectSubNode(node2, next); } return node2; }
/** * Remove Project from all Servers * * @param projectName * @param stringToContain */ public void removeProjectFromServers(String projectName, String stringToContain) { eclipse.showView(ViewType.SERVERS); delay(); try { SWTBotTree serverTree = bot.viewByTitle(IDELabel.View.SERVERS).bot().tree(); delay(); // Expand All for (SWTBotTreeItem serverTreeItem : serverTree.getAllItems()) { serverTreeItem.expand(); // if JSF Test Project is deployed to server remove it SWTBotTreeItem[] serverTreeItemChildren = serverTreeItem.getItems(); if (serverTreeItemChildren != null && serverTreeItemChildren.length > 0) { int itemIndex = 0; boolean found = false; String treeItemlabel = null; do { treeItemlabel = serverTreeItemChildren[itemIndex].getText(); found = treeItemlabel.startsWith(projectName) && (stringToContain == null || treeItemlabel.indexOf(stringToContain) >= 0); } while (!found && ++itemIndex < serverTreeItemChildren.length); // Server Tree Item has Child with Text equal to JSF TEst Project if (found) { log.info("Found project to be removed from server: " + treeItemlabel); ContextMenuHelper.prepareTreeItemForContextMenu( serverTree, serverTreeItemChildren[itemIndex]); new SWTBotMenu( ContextMenuHelper.getContextMenu(serverTree, IDELabel.Menu.REMOVE, false)) .click(); bot.shell("Server").activate(); bot.button(IDELabel.Button.OK).click(); log.info("Removed project from server: " + treeItemlabel); bot.sleep(10 * 1000L); } } } delay(); } catch (WidgetNotFoundException wnfe) { // do nothing it means there is no server defined } }
private void testClient() { Assert.assertTrue("service must exist", servicePassed); clientHelper.createClient( deploymentHelper.getWSDLUrl(getWsProjectName(), getWsName()), WebServiceRuntime.JBOSS_WS, getWsClientProjectName(), getEarProjectName(), SliderLevel.DEVELOP, getWsClientPackage()); IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsClientProjectName()); String pkg = "org/jboss/wsclient"; String cls = "src/" + pkg + "/AreaService.java"; Assert.assertTrue(p.getFile(cls).exists()); cls = "src/" + pkg + "/clientsample/ClientSample.java"; IFile f = p.getFile(cls); Assert.assertTrue(f.exists()); replaceContent(f, "/resources/jbossws/clientsample.java.ws"); /* * workaround for https://issues.jboss.org/browse/JBIDE-9817 */ projectExplorer.selectProject(getWsClientProjectName()); SWTBotTree tree = projectExplorer.bot().tree(); SWTBotTreeItem item = tree.getTreeItem(getWsClientProjectName()); item.expand(); removeRuntimeLibrary(tree, item, bot, util); /* workaround problems with generated code that require JAX-WS API 2.2 */ jaxWsApi22RequirementWorkaround(getWsClientProjectName(), getWsClientPackage()); eclipse.runJavaApplication( getWsClientProjectName(), "org.jboss.wsclient.clientsample.ClientSample", null); util.waitForNonIgnoredJobs(); // wait until the client ends (prints the last line) new WaitUntil(new ConsoleHasText("Call Over!"), TimePeriod.NORMAL); ConsoleView cw = new ConsoleView(); String consoleOutput = cw.getConsoleText(); LOGGER.info(consoleOutput); Assert.assertTrue(consoleOutput, consoleOutput.contains("Server said: 37.5")); Assert.assertTrue(consoleOutput.contains("Server said: 3512.3699")); }
/** * 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); }
/** * Checks IU (Category, or Feature) in a tree * * @param iu to be checked * @return true if checked * @author Pavol Srna */ private boolean checkIU(String iu) { boolean checked = false; for (SWTBotTreeItem node : bot.tree().getAllItems()) { // traverse through all categories if (node.getText().equals(iu)) { node.check(); checked = true; break; } else { // expand category node.expand(); for (SWTBotTreeItem i : node.getItems()) { // traverse through category features if (i.getText().equals(iu)) { i.check(); checked = true; break; } } } } return checked; }
@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")); }
@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()); } }