Skip to content

Commit

Permalink
eclipse-che#4554 fix Class not found exception in maven server (eclip…
Browse files Browse the repository at this point in the history
…se-che#4613)

Signed-off-by: Even Vidolob <evidolob@codenvy.com>
  • Loading branch information
Evgen Vidolob authored Mar 31, 2017
1 parent 374e10f commit 339ea53
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -124,6 +125,27 @@ public void testDownloadSources() throws Exception {
assertTrue(downloadSources);
}

@Test
public void testDownloadSourcesLog4j() throws Exception {
String pom = "<groupId>test</groupId>" +
"<artifactId>testArtifact</artifactId>" +
"<version>42</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>log4j</groupId>" +
" <artifactId>log4j</artifactId>" +
" <version>1.2.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.apache.log4j.Logger");
assertFalse(downloadSources);
}

@Test
public void testDownloadedSourcesShouldAttachToPackageFragmentRoot() throws Exception {
String pom = "<groupId>test</groupId>" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@ public MavenArtifact resolveArtifact(MavenArtifactKey artifactKey, List<MavenRem
new ArtifactRequest(RepositoryUtils.toArtifact(artifact),
remoteRepositories, null));
return MavenModelUtil.convertArtifact(RepositoryUtils.toArtifact(artifactResult.getArtifact()), localRepository);
} catch (ArtifactResolutionException e) {
MavenServerContext.getLogger().info(e);
} catch (ArtifactResolutionException ignored) {
//we need ignore exception, it's some times has class that client doesn't has
// .printStackTrace() may be solution, but it will spam wsagent logs
}
return MavenModelUtil.convertArtifact(artifact, localRepository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ public void setUp() throws Exception {

@Override
public void warning(Throwable t) throws RemoteException {
t.printStackTrace();
}

@Override
public void info(Throwable t) throws RemoteException {
t.printStackTrace();
}

@Override
public void error(Throwable t) throws RemoteException {
t.printStackTrace();
}
}, (file, relativePath) -> {
System.out.println(file.getAbsolutePath());
});
}, (file, relativePath) -> System.out.println(file.getAbsolutePath()));
MavenSettings mavenSettings = new MavenSettings();
mavenSettings.setLoggingLevel(MavenTerminal.LEVEL_INFO);
mavenSettings.setMavenHome(new File(System.getenv("M2_HOME")));
Expand All @@ -69,7 +70,6 @@ public void error(Throwable t) throws RemoteException {
}, new MavenServerProgressNotifier() {
@Override
public void setText(String text) throws RemoteException {
System.out.println(text);
}

@Override
Expand Down Expand Up @@ -144,6 +144,14 @@ public void testResolveArtifactSource() throws Exception {
assertTrue(artifact.isResolved());
}

@Test
public void testResolveLog4jSource() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("log4j", "log4j", "1.2.12", "jar", "sources");
MavenArtifact artifact = mavenServer.resolveArtifact(artifactKey, Collections.emptyList());
assertNotNull(artifact);
assertFalse(artifact.isResolved());
}

@Test
public void testResolveNotExistingArtifact() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("junit", "junit", "3.56", "jar", "");
Expand Down

0 comments on commit 339ea53

Please sign in to comment.