protected void assertFileExists(File targetdir, String pattern) {
   DirectoryScanner ds = new DirectoryScanner();
   ds.setBasedir(targetdir);
   ds.setIncludes(new String[] {pattern});
   ds.scan();
   Assert.assertEquals(
       targetdir.getAbsolutePath() + "/" + pattern, 1, ds.getIncludedFiles().length);
   Assert.assertTrue(
       targetdir.getAbsolutePath() + "/" + pattern,
       new File(targetdir, ds.getIncludedFiles()[0]).canRead());
 }
 protected void assertFileDoesNotExist(File targetdir, String pattern) {
   DirectoryScanner ds = new DirectoryScanner();
   ds.setBasedir(targetdir);
   ds.setIncludes(new String[] {pattern});
   ds.scan();
   Assert.assertEquals(
       targetdir.getAbsolutePath() + "/" + pattern, 0, ds.getIncludedFiles().length);
 }
  /** Returns approximate target platform version. */
  public static Version getEclipseVersion() {
    String location = EnvironmentUtil.getTargetPlatforn();

    DirectoryScanner ds = new DirectoryScanner();
    ds.setBasedir(new File(location, "plugins"));
    ds.setIncludes(new String[] {"org.eclipse.osgi_*.jar"});
    ds.scan();

    String[] files = ds.getIncludedFiles();
    if (files == null || files.length < 1) {
      throw new IllegalStateException(
          "Unable to determine version of the test target platform " + location);
    }

    String version =
        files[0].substring("org.eclipse.osgi_".length(), files[0].length() - ".jar".length());

    return Version.parseVersion(version);
  }