コード例 #1
0
  @Test
  public void testExportProperties() throws Exception {
    Assert.assertNotNull(pool);
    importParamters();
    final File exportedFile =
        new File(ProjectUtil.getBonitaStudioWorkFolder(), "parameters.properties");
    exportedFile.delete();
    final ExportParametersAction action = new ExportParametersAction();
    action.setProcess(pool);
    action.setConfiguration(pool.getConfigurations().get(0));
    action.setTargetPath(ProjectUtil.getBonitaStudioWorkFolder().getAbsolutePath());
    action.run();

    Assert.assertTrue(
        "Exported file doesn't exists", exportedFile.exists() && exportedFile.length() > 0);

    final Properties p = new Properties();
    p.load(new FileInputStream(exportedFile));
    Assert.assertEquals("Exported file not xpected parameters count", 3, p.size());
  }
コード例 #2
0
 protected File getTempFolder() {
   return ProjectUtil.getBonitaStudioWorkFolder();
 }
コード例 #3
0
  @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());
    }
  }