Esempio n. 1
0
  @Test
  public void testDownloadedSourcesShouldAttachToPackageFragmentRoot() throws Exception {
    String pom =
        "<groupId>test</groupId>"
            + "<artifactId>testArtifact</artifactId>"
            + "<version>42</version>"
            + "<dependencies>"
            + "    <dependency>"
            + "        <groupId>junit</groupId>"
            + "        <artifactId>junit</artifactId>"
            + "        <version>4.12</version>"
            + "    </dependency>"
            + "</dependencies>";
    createTestProject("test2", pom);

    IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test2");
    mavenWorkspace.update(Collections.singletonList(test));
    mavenWorkspace.waitForUpdate();
    IJavaProject javaProject = JavaCore.create(test);
    IType type = javaProject.findType("org.junit.Test");
    assertNull(type.getClassFile().getSourceRange());
    boolean downloadSources =
        classpathManager.downloadSources(test.getFullPath().toOSString(), "org.junit.Test");
    assertTrue(downloadSources);
    IType type2 = javaProject.findType("org.junit.Test");
    assertNotNull(type2.getClassFile().getSourceRange());
  }
Esempio n. 2
0
  @Test
  public void testDownloadSources() throws Exception {
    String pom =
        "<groupId>test</groupId>"
            + "<artifactId>testArtifact</artifactId>"
            + "<version>42</version>"
            + "<dependencies>"
            + "    <dependency>"
            + "        <groupId>junit</groupId>"
            + "        <artifactId>junit</artifactId>"
            + "        <version>4.12</version>"
            + "    </dependency>"
            + "</dependencies>";
    createTestProject("test", pom);

    IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
    mavenWorkspace.update(Collections.singletonList(test));
    mavenWorkspace.waitForUpdate();
    boolean downloadSources =
        classpathManager.downloadSources(test.getFullPath().toOSString(), "org.junit.Test");
    assertTrue(downloadSources);
  }