Merge remote-tracking branch 'origin/master' into servlet-3.1-api

This commit is contained in:
Greg Wilkins 2013-06-11 14:07:46 +10:00
commit f8e0764fa5
5 changed files with 38 additions and 20 deletions

View File

@ -25,10 +25,12 @@ import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager; import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty; import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.toolchain.test.TestingDir; import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.util.Scanner; import org.eclipse.jetty.util.Scanner;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
import org.junit.After; import org.junit.After;
import org.junit.Assume; import org.junit.Assume;
import org.junit.Before; import org.junit.Before;
@ -43,6 +45,9 @@ public class ScanningAppProviderRuntimeUpdatesTest
{ {
private static final Logger LOG = Log.getLogger(ScanningAppProviderRuntimeUpdatesTest.class); private static final Logger LOG = Log.getLogger(ScanningAppProviderRuntimeUpdatesTest.class);
@Rule
public TestTracker tracker = new TestTracker();
@Rule @Rule
public TestingDir testdir = new TestingDir(); public TestingDir testdir = new TestingDir();
private static XmlConfiguredJetty jetty; private static XmlConfiguredJetty jetty;
@ -52,6 +57,9 @@ public class ScanningAppProviderRuntimeUpdatesTest
@Before @Before
public void setupEnvironment() throws Exception public void setupEnvironment() throws Exception
{ {
testdir.ensureEmpty();
Resource.setDefaultUseCaches(false);
jetty = new XmlConfiguredJetty(testdir); jetty = new XmlConfiguredJetty(testdir);
jetty.addConfiguration("jetty.xml"); jetty.addConfiguration("jetty.xml");
jetty.addConfiguration("jetty-http.xml"); jetty.addConfiguration("jetty-http.xml");
@ -91,7 +99,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
public void waitForDirectoryScan() public void waitForDirectoryScan()
{ {
int scan=_scans.get()+2*_providers; int scan=_scans.get()+(2*_providers);
do do
{ {
try try

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.deploy.test; package org.eclipse.jetty.deploy.test;
import static org.hamcrest.Matchers.*;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -207,6 +209,7 @@ public class XmlConfiguredJetty
if (context.getContextPath().equals(expectedPath)) if (context.getContextPath().equals(expectedPath))
{ {
found = true; found = true;
Assert.assertThat("Context[" + context.getContextPath() + "].state", context.getState(), is("STARTED"));
break; break;
} }
} }

View File

@ -18,8 +18,10 @@
package org.eclipse.jetty.servlet; package org.eclipse.jetty.servlet;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -55,6 +57,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.UrlEncoded;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
@ -581,8 +584,15 @@ public class DispatcherTest
assertTrue(requestAttributeNames.containsAll(expectedAttributeNames)); assertTrue(requestAttributeNames.containsAll(expectedAttributeNames));
assertEquals(null, request.getPathInfo()); assertEquals(null, request.getPathInfo());
assertEquals(null, request.getPathTranslated()); assertEquals(null, request.getPathTranslated());
assertTrue(request.getQueryString().startsWith("do=end&else=%D0%B2%D1%8B%D0%B1%D1%80%D0%B0%D0%BD%D0%BE%3D%D0%A2%D0%B5%D0%BC%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D1%83%D1%80%D0%B0&test=1&foreign="));
UrlEncoded query = new UrlEncoded(request.getQueryString());
assertThat(query.getString("do"), is("end"));
// Russian for "selected=Temperature"
String russian = new UrlEncoded(query.getString("else")).encode();
assertThat(russian, is("%D0%B2%D1%8B%D0%B1%D1%80%D0%B0%D0%BD%D0%BE=%D0%A2%D0%B5%D0%BC%D0%BF%D0%B5%D1%80%D0%B0%D1%82%D1%83%D1%80%D0%B0"));
assertThat(query.getString("test"), is("1"));
assertThat(query.containsKey("foreign"), is(true));
String[] vals = request.getParameterValues("foreign"); String[] vals = request.getParameterValues("foreign");
assertTrue(vals!=null); assertTrue(vals!=null);

View File

@ -18,9 +18,7 @@
package org.eclipse.jetty.server.session; package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
@ -32,35 +30,32 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
/** /**
* ReloadedSessionMissingClassTest * ReloadedSessionMissingClassTest
*
*
*
*/ */
public class ReloadedSessionMissingClassTest public class ReloadedSessionMissingClassTest
{ {
@Rule
public TestingDir testdir = new TestingDir();
@Test @Test
public void testSessionReloadWithMissingClass() throws Exception public void testSessionReloadWithMissingClass() throws Exception
{ {
((StdErrLog)Log.getLogger(org.eclipse.jetty.server.session.JDBCSessionManager.class)).setHideStacks(true); ((StdErrLog)Log.getLogger(org.eclipse.jetty.server.session.JDBCSessionManager.class)).setHideStacks(true);
Resource.setDefaultUseCaches(false);
String contextPath = "/foo"; String contextPath = "/foo";
File srcDir = new File(System.getProperty("basedir"), "src");
File targetDir = new File(System.getProperty("basedir"), "target");
File testDir = new File (srcDir, "test");
File resourcesDir = new File (testDir, "resources");
File unpackedWarDir = new File (targetDir, "foo"); File unpackedWarDir = testdir.getDir();
if (unpackedWarDir.exists()) testdir.ensureEmpty();
IO.delete(unpackedWarDir);
unpackedWarDir.mkdir();
File webInfDir = new File (unpackedWarDir, "WEB-INF"); File webInfDir = new File (unpackedWarDir, "WEB-INF");
webInfDir.mkdir(); webInfDir.mkdir();
@ -81,8 +76,8 @@ public class ReloadedSessionMissingClassTest
w.write(xml); w.write(xml);
w.close(); w.close();
File foobarJar = new File (resourcesDir, "foobar.jar"); File foobarJar = MavenTestingUtils.getTestResourceFile("foobar.jar");
File foobarNOfooJar = new File (resourcesDir, "foobarNOfoo.jar"); File foobarNOfooJar = MavenTestingUtils.getTestResourceFile("foobarNOfoo.jar");
URL[] foobarUrls = new URL[]{foobarJar.toURI().toURL()}; URL[] foobarUrls = new URL[]{foobarJar.toURI().toURL()};
URL[] barUrls = new URL[]{foobarNOfooJar.toURI().toURL()}; URL[] barUrls = new URL[]{foobarNOfooJar.toURI().toURL()};

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.session; package org.eclipse.jetty.server.session;
import java.sql.DriverManager; import java.sql.DriverManager;
import org.eclipse.jetty.util.resource.Resource;
import java.sql.SQLException; import java.sql.SQLException;
import org.junit.After; import org.junit.After;
@ -34,6 +35,7 @@ public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest
public AbstractTestServer createServer(int port) public AbstractTestServer createServer(int port)
{ {
Resource.setDefaultUseCaches(false);
return new JdbcTestServer(port); return new JdbcTestServer(port);
} }