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

This commit is contained in:
Joakim Erdfelt 2016-12-27 13:33:41 -07:00
commit bfc21f23e0
4 changed files with 86 additions and 10 deletions

View File

@ -18,23 +18,33 @@
package org.eclipse.jetty.deploy.providers;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@Ignore("See issue #1200")
public class WebAppProviderTest
{
@Rule
public TestingDir testdir = new TestingDir();
private static XmlConfiguredJetty jetty;
private boolean symlinkSupported = false;
@Before
public void setupEnvironment() throws Exception
{
@ -45,6 +55,20 @@ public class WebAppProviderTest
// Setup initial context
jetty.copyWebapp("foo-webapp-1.war","foo.war");
// Make symlink
Path pathWar3 = MavenTestingUtils.getTestResourcePathFile("webapps/foo-webapp-3.war");
Path pathBar = jetty.getJettyDir("webapps/bar.war").toPath();
try
{
Files.createSymbolicLink(pathBar, pathWar3);
symlinkSupported = true;
} catch (UnsupportedOperationException | FileSystemException e)
{
// if unable to create symlink, no point testing that feature
// this is the path that Microsoft Windows takes.
symlinkSupported = false;
}
// Should not throw an Exception
jetty.load();
@ -64,18 +88,34 @@ public class WebAppProviderTest
public void testStartupContext()
{
// Check Server for Handlers
jetty.assertWebAppContextsExists("/foo");
jetty.assertWebAppContextsExists("/bar", "/foo");
File workDir = jetty.getJettyDir("workish");
System.err.println("workDir="+workDir);
// Test for regressions
assertDirNotExists("root of work directory",workDir,"webinf");
assertDirNotExists("root of work directory",workDir,"jsp");
// Test for correct behaviour
Assert.assertTrue("Should have generated directory in work directory: " + workDir,hasJettyGeneratedPath(workDir,"foo.war"));
assertTrue("Should have generated directory in work directory: " + workDir,hasJettyGeneratedPath(workDir,"foo.war"));
}
@Test
public void testStartupSymlinkContext()
{
assumeTrue(symlinkSupported);
// Check for path
File barLink = jetty.getJettyDir("webapps/bar.war");
assertTrue("bar.war link exists: " + barLink.toString(), barLink.exists());
assertTrue("bar.war link isFile: " + barLink.toString(), barLink.isFile());
// Check Server for expected Handlers
jetty.assertWebAppContextsExists("/bar", "/foo");
// Test for expected work/temp directory behaviour
File workDir = jetty.getJettyDir("workish");
assertTrue("Should have generated directory in work directory: " + workDir,hasJettyGeneratedPath(workDir,"bar.war"));
}
private static boolean hasJettyGeneratedPath(File basedir, String expectedWarFilename)

View File

@ -75,7 +75,10 @@ server.setRequestLog(requestLog);
This configures a request log in `{$jetty.home}/logs` with filenames including the date.
Existing log files are appended to and the extended NCSA format is used in the GMT time zone.
You can customize the number of days you wish to keep request logs.
The above configuration enables Log Latency, which is the amount of time it took the server to handle the request.
This value is measured in milliseconds and is appended to the the log file for each request.
You can also customize the number of days you wish to keep request logs.
By default, log files are kept for 90 days before being deleted.
The value for `retainDays` (xml) or `setRetainDays` (Java) should be configured as _1 + n_ days.
For example, if you wanted to keep the logs for the current day and the day prior you would set the `retainDays` (or `setRetainDays`) value to 2.

View File

@ -53,6 +53,7 @@ import org.junit.Test;
/**
* Various connect condition testing
*/
@SuppressWarnings("Duplicates")
public class ClientConnectTest
{
@Rule
@ -161,7 +162,34 @@ public class ClientConnectTest
IBlockheadServerConnection connection = server.accept();
connection.upgrade();
}
@Test
public void testUpgradeWithAuthorizationHeader() throws Exception
{
JettyTrackingSocket wsocket = new JettyTrackingSocket();
URI wsUri = server.getWsUri();
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
// actual value for this test is irrelevant, its important that this
// header actually be sent with a value (the value specified)
upgradeRequest.setHeader("Authorization", "Bogus SHA1");
Future<Session> future = client.connect(wsocket,wsUri,upgradeRequest);
IBlockheadServerConnection connection = server.accept();
List<String> requestLines = connection.upgrade();
Session sess = future.get(30,TimeUnit.SECONDS);
sess.close();
String authLine = requestLines.stream()
.filter((line) -> line.startsWith("Authorization:"))
.findFirst().get();
assertThat("Request Container Authorization", authLine, is("Authorization: Bogus SHA1"));
assertThat("Connect.UpgradeRequest", wsocket.connectUpgradeRequest, notNullValue());
assertThat("Connect.UpgradeResponse", wsocket.connectUpgradeResponse, notNullValue());
}
@Test
public void testBadHandshake() throws Exception
{

View File

@ -66,6 +66,7 @@ GIT_USER_EMAIL=`git config --get user.email`
#fi
VER_CURRENT=`sed -e "s/xmlns/ignore/" pom.xml | xmllint --xpath "/project/version/text()" -`
echo "Current pom.xml Version: ${VER_CURRENT}"
read -e -p "Release Version ? " VER_RELEASE
read -e -p "Next Dev Version ? " VER_NEXT
# VER_RELEASE=9.3.5.v20151012
@ -87,8 +88,8 @@ if [ ! -d "$ALT_DEPLOY_DIR" ] ; then
mkdir -p "$ALT_DEPLOY_DIR"
fi
DEPLOY_OPTS="-Dmaven.test.failure.ignore=true"
# DEPLOY_OPTS="-Dtest=None"
# DEPLOY_OPTS="-Dmaven.test.failure.ignore=true"
DEPLOY_OPTS="-Dtest=None"
# DEPLOY_OPTS="$DEPLOY_OPTS -DaltDeploymentRepository=intarget::default::file://$ALT_DEPLOY_DIR/"
echo ""
@ -129,10 +130,13 @@ echo ""
if proceedyn "Are you sure you want to release using above? (y/N)" n; then
echo ""
if proceedyn "Update VERSION.txt for $VER_RELEASE? (Y/n)" y; then
mvn -N -Pupdate-version
mvn -N -Pupdate-version generate-resources
cp VERSION.txt VERSION.txt.backup
cat VERSION.txt.backup | sed -e "s/$VER_CURRENT/$VER_RELEASE/" > VERSION.txt
rm VERSION.txt.backup
echo "VERIFY the following files (in a different console window) before continuing."
echo " VERSION.txt - top section"
echo " target/vers-tag.txt - for the tag commit message"
fi
# This is equivalent to 'mvn release:prepare'
@ -146,7 +150,8 @@ if proceedyn "Are you sure you want to release using above? (y/N)" n; then
fi
if proceedyn "Create Tag $TAG_NAME? (Y/n)" y; then
echo "TODO: Sign tags with GIT_USER_EMAIL=$GIT_USER_EMAIL"
git tag -m "Creating tag $TAG_NAME" $TAG_NAME
echo "Using target/vers-tag.txt as tag text"
git tag --file=target/vers-tag.txt $TAG_NAME
fi
# This is equivalent to 'mvn release:perform'