From 339ea538401b92a3c87f0e57ac1f31821636d3b6 Mon Sep 17 00:00:00 2001 From: Evgen Vidolob Date: Fri, 31 Mar 2017 09:17:32 +0300 Subject: [PATCH] #4554 fix Class not found exception in maven server (#4613) Signed-off-by: Even Vidolob --- .../classpath/ClasspathManagerTest.java | 22 +++++++++++++++++++ .../che/maven/server/MavenServerImpl.java | 5 +++-- .../che/maven/server/ProjectResolverTest.java | 16 ++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/classpath/ClasspathManagerTest.java b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/classpath/ClasspathManagerTest.java index 21015196be2..b3cebd2e54a 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/classpath/ClasspathManagerTest.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/classpath/ClasspathManagerTest.java @@ -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; @@ -124,6 +125,27 @@ public void testDownloadSources() throws Exception { assertTrue(downloadSources); } + @Test + public void testDownloadSourcesLog4j() throws Exception { + String pom = "test" + + "testArtifact" + + "42" + + "" + + " " + + " log4j" + + " log4j" + + " 1.2.12" + + " " + + ""; + 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 = "test" + diff --git a/plugins/plugin-maven/maven-server/maven-server-impl/src/main/java/org/eclipse/che/maven/server/MavenServerImpl.java b/plugins/plugin-maven/maven-server/maven-server-impl/src/main/java/org/eclipse/che/maven/server/MavenServerImpl.java index 46fc4bd83c6..5c916dc77d0 100644 --- a/plugins/plugin-maven/maven-server/maven-server-impl/src/main/java/org/eclipse/che/maven/server/MavenServerImpl.java +++ b/plugins/plugin-maven/maven-server/maven-server-impl/src/main/java/org/eclipse/che/maven/server/MavenServerImpl.java @@ -425,8 +425,9 @@ public MavenArtifact resolveArtifact(MavenArtifactKey artifactKey, List { - 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"))); @@ -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 @@ -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", "");