simplify code, add more details in junit failure #1623
Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
parent
56bf71aec2
commit
0fac9c390a
|
@ -40,13 +40,13 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
System.out.println( "httpResponse hello annotation servlet:" + response );
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
|
|
|
@ -41,13 +41,13 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
System.out.println( "httpResponse hello annotation servlet:" + response );
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,12 @@
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>1.7.21</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
|
|
|
@ -283,24 +283,13 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
if (useTestScope && (testClassesDirectory != null))
|
if (useTestScope && (testClassesDirectory != null))
|
||||||
webApp.setTestClasses (testClassesDirectory);
|
webApp.setTestClasses (testClassesDirectory);
|
||||||
|
|
||||||
List<File> dependencyProjects = getDependencyProjects();
|
webApp.setWebInfLib(getDependencyFiles());
|
||||||
webApp.getClassPathFiles().addAll( dependencyProjects );
|
|
||||||
List<Resource> dependencyResources = //
|
|
||||||
dependencyProjects.stream() //
|
|
||||||
.map( file -> Resource.newResource( file ) ) //
|
|
||||||
.collect( Collectors.toList() );
|
|
||||||
webApp.getMetaData().getContainerResources().addAll( dependencyResources );
|
|
||||||
webApp.setWebInfLib (getDependencyFiles());
|
|
||||||
// webApp.getWebInfLib().addAll( dependencyResources //
|
|
||||||
// .stream() //
|
|
||||||
// .map( resource -> toFile(resource) ) //
|
|
||||||
// .collect( Collectors.toList() ) );
|
|
||||||
webApp.getDependentProjects().addAll( dependencyResources );
|
|
||||||
//get copy of a list of war artifacts
|
//get copy of a list of war artifacts
|
||||||
Set<Artifact> matchedWarArtifacts = new HashSet<Artifact>();
|
Set<Artifact> matchedWarArtifacts = new HashSet<Artifact>();
|
||||||
|
|
||||||
//process any overlays and the war type artifacts
|
//process any overlays and the war type artifacts
|
||||||
List<Overlay> overlays = new ArrayList<Overlay>();
|
List<Overlay> overlays = new ArrayList<>();
|
||||||
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
||||||
{
|
{
|
||||||
//overlays can be individually skipped
|
//overlays can be individually skipped
|
||||||
|
@ -596,8 +585,10 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getProjectReferences( artifact, project )!=null)
|
MavenProject mavenProject = getProjectReferences( artifact, project );
|
||||||
|
if (mavenProject != null)
|
||||||
{
|
{
|
||||||
|
dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,38 +605,6 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
return dependencyFiles;
|
return dependencyFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<File> getDependencyProjects()
|
|
||||||
{
|
|
||||||
List<File> dependencyFiles = new ArrayList<>();
|
|
||||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
|
||||||
{
|
|
||||||
Artifact artifact = iter.next();
|
|
||||||
|
|
||||||
// Include runtime and compile time libraries, and possibly test libs too
|
|
||||||
if(artifact.getType().equals("war"))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
|
|
||||||
continue; //never add dependencies of scope=provided to the webapp's classpath (see also <useProvidedScope> param)
|
|
||||||
|
|
||||||
if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
|
|
||||||
continue; //only add dependencies of scope=test if explicitly required
|
|
||||||
|
|
||||||
MavenProject mavenProject = getProjectReferences( artifact, project );
|
|
||||||
if (mavenProject != null)
|
|
||||||
{
|
|
||||||
dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
|
|
||||||
getLog().debug( "Adding project reference " + mavenProject.getBuild().getOutputDirectory()
|
|
||||||
+ " for WEB-INF/classes " );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dependencyFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||||
{
|
{
|
||||||
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
|
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
||||||
public void preConfigure(WebAppContext context) throws Exception
|
public void preConfigure(WebAppContext context) throws Exception
|
||||||
{
|
{
|
||||||
super.preConfigure(context);
|
super.preConfigure(context);
|
||||||
((JettyWebAppContext)context).getDependentProjects()
|
// ((JettyWebAppContext)context).getDependentProjects()
|
||||||
.stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
|
// .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue