@BeforeClass
  public static void init() throws Exception {
    importMavenProject("projects/testDeployableContainer.zip", TEST_PROJECT_NAME);
    JobUtils.waitForIdle(1000);
    IProject project = getProject(TEST_PROJECT_NAME);
    addArquillianSupport(project);
    JobUtils.waitForIdle(1000);
    if (!ArquillianUtility.isValidatorEnabled(project)) {
      IEclipsePreferences prefs =
          new ProjectScope(project).getNode(ArquillianCoreActivator.PLUGIN_ID);
      prefs.putBoolean(ArquillianConstants.TEST_ARQUILLIAN_CONTAINER, true);
      prefs.flush();
    }
    IProjectConfigurationManager configurationManager =
        MavenPlugin.getProjectConfigurationManager();
    ResolverConfiguration configuration = configurationManager.getResolverConfiguration(project);

    configuration.setSelectedProfiles("JBOSS_AS_REMOTE_7.X, JBOSS_AS_MANAGED_7.X");
    boolean isSet = configurationManager.setResolverConfiguration(project, configuration);
    if (isSet) {
      MavenUpdateRequest request = new MavenUpdateRequest(project, true, true);
      configurationManager.updateProjectConfiguration(request, new NullProgressMonitor());
    }

    JobUtils.waitForIdle(1000);
  }
  public void testNoDefaultLocaleForChangeAndRefresh() throws Throwable {
    VpeController controller =
        openInVpe(JsfAllTests.IMPORT_JSF_LOCALES_PROJECT_NAME, NO_DEFLOC_CHANGE_REFRESH_PAGE);
    nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();

    nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID);
    String localizedText = getLocalizedText(localeText);
    assertTrue(
        "Text is '" + localizedText + "', but should be in 'de' locale",
        HELLO2_DE.equalsIgnoreCase(localizedText)); // $NON-NLS-1$ //$NON-NLS-2$
    /*
     * Change the locale
     */
    Element fViewElement =
        controller.getSourceBuilder().getSourceDocument().getElementById(FVIEW_ID);
    int offset = controller.getSourceBuilder().getPosition(fViewElement, 0, false);
    assertTrue(
        "Previous locale should be 'de'",
        "de"
            .equalsIgnoreCase(
                fViewElement.getAttribute("locale"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    IRegion reg =
        new FindReplaceDocumentAdapter(
                controller.getSourceBuilder().getStructuredTextViewer().getDocument())
            .find(offset, "de", true, true, false, false);
    controller
        .getSourceBuilder()
        .getStructuredTextViewer()
        .getDocument()
        .replace(reg.getOffset(), reg.getLength(), "en_GB");
    /*
     * Wait until new value is applied and children are refreshed.
     * Wait while all deferred events are processed
     */
    while (Display.getCurrent().readAndDispatch()) ;
    /*
     * Wait while all jobs including started through deferred events are ended
     */
    JobUtils.delay(VpeController.DEFAULT_UPDATE_DELAY_TIME * 4);
    TestUtil.waitForIdle();
    fViewElement = controller.getSourceBuilder().getSourceDocument().getElementById(FVIEW_ID);
    assertTrue(
        "Current locale should be 'en_GB'",
        "en_GB"
            .equalsIgnoreCase(
                fViewElement.getAttribute("locale"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    doc = controller.getXulRunnerEditor().getDOMDocument();
    localeText = doc.getElementById(LOCALE_TEXT_ID);
    localizedText = getLocalizedText(localeText);

    /*
     * Check the new localized message.
     */
    assertTrue(
        "Text is '" + localizedText + "', but should be in 'en_GB' locale",
        HELLO_EN_GB.equalsIgnoreCase(localizedText)); // $NON-NLS-1$ //$NON-NLS-2$
    closeEditors();
  }
 @Before
 public void setUp() throws Exception {
   TestProjectProvider provider =
       new TestProjectProvider(BUNDLE, "/projects/" + "WebTest", "WebTest", true);
   prj = provider.getProject();
   JobUtils.delay(3000);
 }
  @Override
  protected void setUp() throws Exception {
    JobUtils.waitForIdle();
    IResource project =
        ResourcesPlugin.getWorkspace().getRoot().findMember("SeamWebWarTestProject");
    this.project = project.getProject();

    IPreferenceStore store = SeamCorePlugin.getDefault().getPreferenceStore();

    store.putValue(SeamPreferences.DUPLICATE_REMOVE, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.DUPLICATE_DESTROY, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.DUPLICATE_CREATE, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.DUPLICATE_UNWRAP, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.CREATE_DOESNT_BELONG_TO_COMPONENT, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.UNWRAP_DOESNT_BELONG_TO_COMPONENT, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.OBSERVER_DOESNT_BELONG_TO_COMPONENT, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.NONUNIQUE_COMPONENT_NAME, SeamPreferences.WARNING);
    store.putValue(
        SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE, SeamPreferences.WARNING);
    store.putValue(
        SeamPreferences.STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.STATEFUL_COMPONENT_WRONG_SCOPE, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.ENTITY_COMPONENT_WRONG_SCOPE, SeamPreferences.WARNING);
    store.putValue(SeamPreferences.UNKNOWN_COMPONENT_PROPERTY, SeamPreferences.WARNING);

    if (store instanceof IPersistentPreferenceStore) {
      try {
        ((IPersistentPreferenceStore) store).save();
      } catch (IOException e) {
        SeamCorePlugin.getPluginLog().logError(e);
      }
    }
  }
  protected void setUp() throws Exception {
    JobUtils.waitForIdle();
    if (project == null) {
      IResource projectResource = ResourcesPlugin.getWorkspace().getRoot().findMember(PROJECT_NAME);
      IProject prj = null;
      if (projectResource == null) {
        ProjectImportTestSetup setup =
            new ProjectImportTestSetup(
                this, "org.jboss.tools.seam.ui.test", "projects/" + PROJECT_NAME, PROJECT_NAME);
        projectResource = setup.importProject();
      }
      if (projectResource == null) return;
      prj = projectResource.getProject();

      this.project = prj;
    }
    JobUtils.waitForIdle();
  }
 @After
 public void tearDown() throws Exception {
   boolean oldAutoBuilding = ResourcesUtils.setBuildAutomatically(false);
   Exception last = null;
   try {
     JobUtils.delay(500);
     try {
       prj.delete(true, null);
       JobUtils.delay(500);
     } catch (Exception e) {
       e.printStackTrace();
       last = e;
     }
   } finally {
     ResourcesUtils.setBuildAutomatically(oldAutoBuilding);
   }
   if (last != null) throw last;
 }
  @BeforeClass
  public static void init() throws Exception {
    importMavenProject("projects/testFilter1.zip", TEST_PROJECT_NAME);
    IPath path = Platform.getLocation();
    path = path.append(TEST_PROJECT_NAME2);
    File location = new File(path.toOSString());
    location.mkdirs();
    importMavenProject("projects/testFilter2.zip", TEST_PROJECT_NAME2, path);
    JobUtils.waitForIdle(1000);
    IProject project = getProject(TEST_PROJECT_NAME);
    addArquillianSupport(project);
    JobUtils.waitForIdle(1000);
    project = getProject(TEST_PROJECT_NAME2);
    addArquillianSupport(project);
    JobUtils.waitForIdle(1000);

    Display.getDefault()
        .syncExec(
            new Runnable() {

              @Override
              public void run() {
                IWorkbenchWindow workbenchWindow =
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                IWorkingSetManager manager = workbenchWindow.getWorkbench().getWorkingSetManager();
                IWorkingSet workingSet =
                    manager.createWorkingSet(
                        "test",
                        new IAdaptable[] {
                          getProject(TEST_PROJECT_NAME), getProject(TEST_PROJECT_NAME2)
                        });
                manager.addWorkingSet(workingSet);
                IWorkingSet[] ws = manager.getAllWorkingSets();
                System.out.println(ws);
              }
            });
  }
  protected void setUp() throws Exception {
    super.setUp();

    File folder = getSeamHomeFolder();
    assertNotNull(
        "An error occured while getting the SEAM HOME folder for: " + getSeamRTName(), folder);

    SeamRuntimeManager.getInstance()
        .addRuntime(
            getSeamRTName(), folder.getAbsolutePath(), getSeamRTVersion(getSeamRTName()), true);
    SeamRuntime sr = SeamRuntimeManager.getInstance().findRuntimeByName(getSeamRTName());
    assertNotNull("An error occured while getting the SEAM RUN-TIME for: " + getSeamRTName(), sr);

    IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(SEAM_EAR_PROJECTNAME);
    if (project == null
        && earProject == null
        && earEjbProject == null
        && earEarProject == null
        && testProject == null) createSeamEarProject(SEAM_EAR_PROJECTNAME);

    try {
      JobUtils.waitForIdle();
    } catch (Exception e) {
      JUnitUtils.fail(e.getMessage(), e);
    }

    if (earProject == null) {
      earProject = ProjectImportTestSetup.loadProject(SEAM_EAR_PROJECTNAME);
    }
    if (earEjbProject == null) {
      earEjbProject = ProjectImportTestSetup.loadProject(SEAM_EAR_EJB_PROJECTNAME);
    }
    if (earEarProject == null) {
      earEarProject = ProjectImportTestSetup.loadProject(SEAM_EAR_EAR_PROJECTNAME);
    }
    if (testProject == null) {
      testProject = ProjectImportTestSetup.loadProject(SEAM_EAR_TEST_PROJECTNAME);
    }
    if (seamEarProject == null) {
      seamEarProject = loadSeamProject(earProject);
    }
    if (seamEarEjbProject == null) {
      seamEarEjbProject = loadSeamProject(earEjbProject);
    }
    if (seamTestProject == null) {
      seamTestProject = loadSeamProject(testProject);
    }
  }
 @AfterClass
 public static void dispose() throws Exception {
   JobUtils.waitForIdle(1000);
   getProject(TEST_PROJECT_NAME).delete(true, true, null);
   getProject(TEST_PROJECT_NAME2).delete(true, true, null);
 }