コード例 #1
0
  /**
   * Do a few simple checks to see if the contents of a generated dependency file looks ok. These
   * checks are by no means comprehensive, but it is better than nothing.
   *
   * @throws IOException
   */
  protected void checkDependencyFile(IProject project, File file) throws IOException {
    // ///////////////////////////////////////
    // Check the generated file...
    assertTrue(file.exists());

    DependencyData depData = DependencyFileFormat.read(file);

    String dotGrailsFolder =
        new File(
                GrailsCoreActivator.getDefault().getUserHome() + "/" + ".grails/" + grailsVersion())
            .getCanonicalPath();

    // Check plugins directory points where it should
    String pluginsDirectory = depData.getPluginsDirectory();
    if (GrailsVersion.V_2_3_.compareTo(GrailsVersion.MOST_RECENT) <= 0) {
      // Grails 2.3 has moved the plugin area into the project area. It's no longer inside
      // the .grails folder.
      assertEquals(project.getLocation() + "/target/work/plugins", pluginsDirectory);
    } else {
      assertEquals(
          dotGrailsFolder + "/projects/" + TEST_PROJECT_NAME + "/plugins", pluginsDirectory);
    }

    Set<String> sources = depData.getSources();
    for (String string : sources) {
      System.out.println(string);
    }
    String[] expectedPlugins = new String[] {"tomcat", "hibernate"};
    // Checkinf for these makes the tests unstable? No real way to know what is expected here
    // It varies depending on plugins and grails version.

    //		for (String pluginName : expectedPlugins) {
    //			for (String javaGroovy : new String[] { "java", "groovy" }) {
    //				String expect = pluginsDirectory + "/" + pluginName + "-"
    //						+ grailsVersion() + "/src/" + javaGroovy;
    //				assertTrue("Missing source entry: " + expect,
    //						sources.contains(expect));
    //			}
    //		}

    Set<String> pluginsXmls = depData.getPluginDescriptors();
    for (String string : pluginsXmls) {
      System.out.println(string);
    }
    for (String pluginName : expectedPlugins) {
      assertPluginXml(pluginName, pluginsXmls);
    }

    // TODO: KDV: (depend) add some more checks of the contents of the file
    // (i.e. check for a few basic jar dependencies that should always be
    // there.)
  }