public void testNewBeansXMLWizard() throws CoreException {
    NewBeansXMLWizardContext context = new NewBeansXMLWizardContext();
    context.init("org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard");

    try {

      WizardNewFileCreationPage page =
          (WizardNewFileCreationPage) context.wizard.getPage("newFilePage1");
      String s = page.getFileName();
      assertEquals("beans.xml", s);
      assertFalse(context.wizard.canFinish());
      page.setFileName("beans2.xml");
      assertTrue(context.wizard.canFinish());
      String c = page.getContainerFullPath().toString();
      assertEquals("/tck/WebContent/WEB-INF", c);

      context.wizard.performFinish();

      IFile f =
          context.tck.getParent().getFile(page.getContainerFullPath().append(page.getFileName()));
      assertTrue(f.exists());

      String text = FileUtil.readStream(f.getContents());
      assertTrue(text.indexOf("http://java.sun.com/xml/ns/javaee") > 0);

    } finally {
      context.close();
    }
  }
  /**
   * Test for http://jira.jboss.com/jira/browse/JBIDE-1803
   * http://jira.jboss.com/jira/browse/JBIDE-2007
   *
   * @throws CoreException
   */
  public void testVarAttributes() throws CoreException {
    assertTrue("Test project \"" + PROJECT_NAME + "\" is not loaded", (project != null));

    IFile component = project.getFile("src/action/demo/TestComponentForVarAttributes.java");
    IFile newComponent = project.getFile("src/action/demo/TestComponentForVarAttributes.1");
    IFile emptyComponent = project.getFile("src/action/demo/TestComponentForVarAttributes.2");
    try {
      FileUtil.copyContent(newComponent, component, true, false, new NullProgressMonitor());

      project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);

      checkProposals("/WebContent/varAttributes.xhtml", 458, new String[] {"test.name"}, false);
      checkProposals("/WebContent/varAttributes.xhtml", 640, new String[] {"item.name"}, false);
    } finally {
      FileUtil.copyContent(emptyComponent, component, true, false, new NullProgressMonitor());
      project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
    }
  }
 @Test
 public void modifiedButNotCommittedIsDirty() throws Exception {
   assertFalse(EGitUtils.isDirty(testRepository.getRepository(), new NullProgressMonitor()));
   File file = testRepository.createFile("a.txt", "protonica");
   assertTrue(EGitUtils.isDirty(testRepository.getRepository(), new NullProgressMonitor()));
   testRepository.addAndCommit(file, "commit-by-junit-tests");
   assertFalse(EGitUtils.isDirty(testRepository.getRepository(), new NullProgressMonitor()));
   FileUtil.writeFileDefault(file, "atrix");
   assertTrue(EGitUtils.isDirty(testRepository.getRepository(), new NullProgressMonitor()));
 }
 void assertTextSourceReference(ITextSourceReference ref, String expectedContent) {
   try {
     String text = FileUtil.readStream((IFile) ref.getResource());
     String content =
         text.substring(ref.getStartPosition(), ref.getStartPosition() + ref.getLength());
     assertEquals(expectedContent, content);
   } catch (CoreException e) {
     fail(e.getMessage());
   }
 }
    public String getNewTypeContent() {
      IType type = findType();

      IFile file = (IFile) type.getResource();
      assertNotNull(file);
      String text = null;
      try {
        text = FileUtil.readStream(file.getContents());
      } catch (CoreException e) {
        JUnitUtils.fail("Cannot read from " + file, e);
      }
      return text;
    }
    public String getNewTypeContent() {
      IType type = null;
      try {
        String tn = typeName;
        int q = tn.indexOf("<");
        if (q >= 0) tn = tn.substring(0, q);
        type = jp.findType(packName + "." + tn);
      } catch (JavaModelException e) {
        JUnitUtils.fail("Cannot find type " + typeName, e);
      }

      IFile file = (IFile) type.getResource();
      assertNotNull(file);
      String text = null;
      try {
        text = FileUtil.readStream(file.getContents());
      } catch (CoreException e) {
        JUnitUtils.fail("Cannot read from " + file, e);
      }
      return text;
    }
  public void testNewBeansXMLWizard() throws CoreException {
    NewBeansXMLWizardContext context = new NewBeansXMLWizardContext();
    context.init(NewJobXMLCreationWizard.WIZARD_ID);

    try {

      WizardNewFileCreationPage page =
          (WizardNewFileCreationPage) context.wizard.getPage(NewJobXMLCreationWizard.PAGE_NAME);
      String s = page.getFileName();
      assertEquals("job.xml", s);
      assertFalse(context.wizard.canFinish());
      page.setFileName("job222.xml");
      assertTrue(context.wizard.canFinish());
      String c = page.getContainerFullPath().toString();
      assertEquals("/BatchTestProject/src/META-INF/batch-jobs", c);

      assertEquals("1.0", context.wizard.getVersion());

      context.wizard.setID("myNewJob");

      context.wizard.performFinish();

      IFile f =
          context
              .project
              .getParent()
              .getFile(page.getContainerFullPath().append(page.getFileName()));
      assertTrue(f.exists());

      String text = FileUtil.readStream(f.getContents());
      assertTrue(text.indexOf("http://xmlns.jcp.org/xml/ns/javaee") > 0);
      assertTrue(text.indexOf("id=\"myNewJob\"") > 0);

    } finally {
      context.close();
    }
  }