Merge branch 'jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
olivier lamy 2019-05-09 07:12:27 +10:00
commit 2ba8542ed1
8 changed files with 241 additions and 6 deletions

View File

@ -26,6 +26,11 @@
<version>@servlet.api.version@</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>

View File

@ -0,0 +1,45 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.its.jetty_run_mojo_it_test;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
*
*/
@WebServlet("/testhello")
public class HelloTestServlet
extends HttpServlet
{
@Override
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
throws ServletException, IOException
{
String who = req.getParameter( "name" );
resp.getWriter().write( "Hello from test " + (who == null ? "unknown" : who) );
}
}

View File

@ -23,26 +23,44 @@
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
@ -73,6 +91,7 @@
<jetty.port.file>${jetty.port.file}</jetty.port.file>
<pingServlet>true</pingServlet>
<helloServlet>true</helloServlet>
<helloTestServlet>true</helloTestServlet>
<maven.it.name>${project.groupId}:${project.artifactId}</maven.it.name>
</systemPropertyVariables>
<dependenciesToScan>
@ -99,6 +118,7 @@
</systemProperties>
<nonBlocking>true</nonBlocking>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
<useTestScope>true</useTestScope>
</configuration>
</execution>
</executions>

View File

@ -35,6 +35,13 @@
<artifactId>jetty-simple-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -41,6 +41,7 @@ import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.jetty.util.PathWatcher;
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.WebAppContext;
@ -541,16 +542,19 @@ public class JettyRunMojo extends AbstractJettyMojo
continue; //only add dependencies of scope=test if explicitly required
MavenProject mavenProject = getProjectReference( artifact, project );
if (mavenProject != null)
{
File projectPath = Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile();
File projectPath = "test-jar".equals( artifact.getType() )?
Paths.get( mavenProject.getBuild().getTestOutputDirectory() ).toFile()
: Paths.get( mavenProject.getBuild().getOutputDirectory() ).toFile();
getLog().debug( "Adding project directory " + projectPath.toString() );
dependencyFiles.add( projectPath );
continue;
}
dependencyFiles.add(artifact.getFile());
getLog().debug( "Adding artifact " + artifact.getFile().getName() + " with scope "+artifact.getScope()+" for WEB-INF/lib " );
getLog().debug( "Adding artifact " + artifact.getFile().getName() + " with scope "+artifact.getScope()+" for WEB-INF/lib " );
}
return dependencyFiles;
@ -569,6 +573,16 @@ public class JettyRunMojo extends AbstractJettyMojo
{
return mavenProject;
}
if("test-jar".equals(artifact.getType()))
{
// getId use type so comparing getId will fail in case of test-jar dependency
if ( StringUtils.equals( mavenProject.getGroupId(), artifact.getGroupId() )
&& StringUtils.equals( mavenProject.getArtifactId(), artifact.getArtifactId() )
&& StringUtils.equals( mavenProject.getVersion(), artifact.getBaseVersion()) )
{
return mavenProject;
}
}
}
return null;
}

View File

@ -77,6 +77,14 @@ public class TestGetContent
+ ", response not contentCheck: " + contentCheck + ", response:" + response);
System.out.println( "contentCheck" );
}
if (Boolean.getBoolean( "helloTestServlet" ))
{
String response = httpClient.GET( "http://localhost:" + port + "/testhello?name=beer" ).getContentAsString();
assertEquals( "Hello from test beer", response.trim(), "it test " + System.getProperty( "maven.it.name" ) );
response = httpClient.GET( "http://localhost:" + port + "/testhello?name=foo" ).getContentAsString();
assertEquals( "Hello from test foo", response.trim(), "it test " + System.getProperty( "maven.it.name" ) );
System.out.println( "helloServlet" );
}
}
finally
{

View File

@ -0,0 +1,47 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.plus.jndi;
import org.junit.jupiter.api.Test;
import javax.naming.NamingException;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Unit tests for class {@link NamingEntryUtil}.
*
* @see NamingEntryUtil
*
*/
public class NamingEntryUtilTest{
@Test
public void testBindToENCWithEmptyStringAndBindToENCThrowsNamingException()
{
assertThrows(NamingException.class, () -> NamingEntryUtil.bindToENC(new Object(), "", ""));
}
@Test
public void testBindToENCWithNullAndNullThrowsNamingException()
{
assertThrows( NamingException.class, () -> NamingEntryUtil.bindToENC( null, null, "@=<9"));
}
}

View File

@ -0,0 +1,89 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.start;
import org.junit.jupiter.api.Test;
import java.util.Collection;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit tests for class {@link Utils}.
*
* @see Utils
*/
public class UtilsTest
{
@Test
public void testIsNotBlankReturningTrue()
{
assertTrue(Utils.isNotBlank(" @t;3/|O)t"));
}
@Test
public void testIsNotBlankReturningFalse()
{
assertFalse(Utils.isNotBlank(null));
}
@Test
public void testIsBlank()
{
assertFalse(Utils.isBlank(" i3o0e!#4u%QW"));
}
@Test
public void testIsBlankUsingNull()
{
assertTrue(Utils.isBlank(null));
}
@Test
public void testJoin()
{
assertEquals("", Utils.join((Collection<?>)null, "V9ewe2K"));
}
@Test
public void testJoinTaking4ArgumentsAndReturningEmptyString()
{
assertEquals("", Utils.join((Object[])null, (-3563), 1051, ""));
}
@Test
public void testJoinUsingObjectArrayOne()
{
assertEquals("", Utils.join((Object[])null, ""));
}
@Test
public void testJoinUsingObjectArrayTwo()
{
Object[] objectArray = new Object[8];
String joinedString = Utils.join(objectArray, "%.g[{2G<1");
assertEquals(8, objectArray.length);
assertEquals("null%.g[{2G<1null%.g[{2G<1null%.g[{2G<1null%.g[{2G<1null%.g[{2G<1null%.g[{2G<1null%.g[{2G<1null", joinedString);
}
}