Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
e1c8a0e8b8
|
@ -135,7 +135,7 @@
|
|||
<!-- ensure we don't have legacy comments that confuse javadoc tooling -->
|
||||
<module name="Regexp">
|
||||
<property name="id" value="LegacyMethodSeparators"/>
|
||||
<property name="format" value="/\*\s*[=*-]*\s*\*/"/>
|
||||
<property name="format" value="/\*\s*[=*-]+\s*\*/" />
|
||||
<property name="illegalPattern" value="true"/>
|
||||
<property name="ignoreComments" value="false"/>
|
||||
<property name="message" value="Legacy Method Separators"/>
|
||||
|
|
|
@ -54,23 +54,28 @@ public class TestSecurityAnnotationConversions
|
|||
{
|
||||
}
|
||||
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
||||
"tom", "dick", "harry"
|
||||
}))
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed =
|
||||
{
|
||||
"tom", "dick", "harry"
|
||||
}))
|
||||
public static class RolesServlet extends HttpServlet
|
||||
{
|
||||
}
|
||||
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
||||
"tom", "dick", "harry"
|
||||
}), httpMethodConstraints = {@HttpMethodConstraint(value = "GET")})
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed =
|
||||
{
|
||||
"tom", "dick", "harry"
|
||||
}), httpMethodConstraints = {@HttpMethodConstraint(value = "GET")})
|
||||
public static class Method1Servlet extends HttpServlet
|
||||
{
|
||||
}
|
||||
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
||||
"tom", "dick", "harry"
|
||||
}), httpMethodConstraints = {@HttpMethodConstraint(value = "GET", transportGuarantee = TransportGuarantee.CONFIDENTIAL)})
|
||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed =
|
||||
{
|
||||
"tom", "dick", "harry"
|
||||
}), httpMethodConstraints = {
|
||||
@HttpMethodConstraint(value = "GET", transportGuarantee = TransportGuarantee.CONFIDENTIAL)
|
||||
})
|
||||
public static class Method2Servlet extends HttpServlet
|
||||
{
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -37,11 +36,11 @@ public class HttpCookie
|
|||
private static final String __01Jan1970_COOKIE = DateGenerator.formatCookieDate(0).trim();
|
||||
|
||||
/**
|
||||
*If this string is found within the comment parsed with {@link #isHttpOnlyInComment(String)} the check will return true
|
||||
* If this string is found within the comment parsed with {@link #isHttpOnlyInComment(String)} the check will return true
|
||||
**/
|
||||
public static final String HTTP_ONLY_COMMENT = "__HTTP_ONLY__";
|
||||
/**
|
||||
*These strings are used by {@link #getSameSiteFromComment(String)} to check for a SameSite specifier in the comment
|
||||
* These strings are used by {@link #getSameSiteFromComment(String)} to check for a SameSite specifier in the comment
|
||||
**/
|
||||
private static final String SAME_SITE_COMMENT = "__SAME_SITE_";
|
||||
public static final String SAME_SITE_NONE_COMMENT = SAME_SITE_COMMENT + "NONE__";
|
||||
|
@ -474,10 +473,10 @@ public class HttpCookie
|
|||
LOG.debug("No default value for SameSite");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (o instanceof SameSite)
|
||||
return (SameSite)o;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
SameSite samesite = Enum.valueOf(SameSite.class, o.toString().trim().toUpperCase(Locale.ENGLISH));
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.plus.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.eclipse.jetty.plus.webapp.PlusDecorator;
|
||||
|
@ -41,12 +40,12 @@ public class LifeCycleCallbackCollectionTest
|
|||
{
|
||||
public static int postConstructCount = 0;
|
||||
public static int preDestroyCount = 0;
|
||||
|
||||
|
||||
public void postconstruct()
|
||||
{
|
||||
++postConstructCount;
|
||||
}
|
||||
|
||||
|
||||
public void predestroy()
|
||||
{
|
||||
++preDestroyCount;
|
||||
|
@ -55,7 +54,6 @@ public class LifeCycleCallbackCollectionTest
|
|||
|
||||
/**
|
||||
* An unsupported lifecycle callback type
|
||||
*
|
||||
*/
|
||||
public class TestLifeCycleCallback extends LifeCycleCallback
|
||||
{
|
||||
|
@ -79,7 +77,6 @@ public class LifeCycleCallbackCollectionTest
|
|||
/**
|
||||
* A class that we can use to simulate having PostConstruct and
|
||||
* PreDestroy annotations on.
|
||||
*
|
||||
*/
|
||||
public class SomeTestClass
|
||||
{
|
||||
|
@ -177,7 +174,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
//expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testServletPostConstructPreDestroy() throws Exception
|
||||
{
|
||||
|
@ -186,7 +183,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
context.setResourceBase(MavenTestingUtils.getTargetTestingDir("predestroy-test").toURI().toURL().toString());
|
||||
context.setContextPath("/");
|
||||
server.setHandler(context);
|
||||
|
||||
|
||||
//add a non-async servlet
|
||||
ServletHolder notAsync = new ServletHolder();
|
||||
notAsync.setHeldClass(TestServlet.class);
|
||||
|
@ -194,7 +191,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
notAsync.setAsyncSupported(false);
|
||||
notAsync.setInitOrder(1);
|
||||
context.getServletHandler().addServletWithMapping(notAsync, "/notasync/*");
|
||||
|
||||
|
||||
//add an async servlet
|
||||
ServletHolder async = new ServletHolder();
|
||||
async.setHeldClass(TestServlet.class);
|
||||
|
@ -202,7 +199,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
async.setAsyncSupported(true);
|
||||
async.setInitOrder(1);
|
||||
context.getServletHandler().addServletWithMapping(async, "/async/*");
|
||||
|
||||
|
||||
//add a run-as servlet
|
||||
ServletHolder runas = new ServletHolder();
|
||||
runas.setHeldClass(TestServlet.class);
|
||||
|
@ -210,7 +207,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
runas.setRunAsRole("admin");
|
||||
runas.setInitOrder(1);
|
||||
context.getServletHandler().addServletWithMapping(runas, "/runas/*");
|
||||
|
||||
|
||||
//add both run-as and non async servlet
|
||||
ServletHolder both = new ServletHolder();
|
||||
both.setHeldClass(TestServlet.class);
|
||||
|
@ -219,7 +216,7 @@ public class LifeCycleCallbackCollectionTest
|
|||
both.setAsyncSupported(false);
|
||||
both.setInitOrder(1);
|
||||
context.getServletHandler().addServletWithMapping(both, "/both/*");
|
||||
|
||||
|
||||
//Make fake lifecycle callbacks for all servlets
|
||||
LifeCycleCallbackCollection collection = new LifeCycleCallbackCollection();
|
||||
context.setAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION, collection);
|
||||
|
@ -227,28 +224,28 @@ public class LifeCycleCallbackCollectionTest
|
|||
collection.add(pcNotAsync);
|
||||
PreDestroyCallback pdNotAsync = new PreDestroyCallback(TestServlet.class, "predestroy");
|
||||
collection.add(pdNotAsync);
|
||||
|
||||
|
||||
PostConstructCallback pcAsync = new PostConstructCallback(TestServlet.class, "postconstruct");
|
||||
collection.add(pcAsync);
|
||||
PreDestroyCallback pdAsync = new PreDestroyCallback(TestServlet.class, "predestroy");
|
||||
collection.add(pdAsync);
|
||||
|
||||
|
||||
PostConstructCallback pcRunAs = new PostConstructCallback(TestServlet.class, "postconstruct");
|
||||
collection.add(pcRunAs);
|
||||
PreDestroyCallback pdRunAs = new PreDestroyCallback(TestServlet.class, "predestroy");
|
||||
collection.add(pdRunAs);
|
||||
|
||||
|
||||
PostConstructCallback pcBoth = new PostConstructCallback(TestServlet.class, "postconstruct");
|
||||
collection.add(pcBoth);
|
||||
PreDestroyCallback pdBoth = new PreDestroyCallback(TestServlet.class, "predestroy");
|
||||
collection.add(pdBoth);
|
||||
|
||||
|
||||
server.start();
|
||||
|
||||
|
||||
assertEquals(4, TestServlet.postConstructCount);
|
||||
|
||||
|
||||
server.stop();
|
||||
|
||||
|
||||
assertEquals(4, TestServlet.preDestroyCount);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.server;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
|
|
|
@ -414,7 +414,7 @@ public class ResponseTest
|
|||
|
||||
@Test
|
||||
public void testResponseCharacterEncoding() throws Exception
|
||||
{
|
||||
{
|
||||
_server.stop();
|
||||
ContextHandler handler = new CharEncodingContextHandler();
|
||||
_server.setHandler(handler);
|
||||
|
@ -429,7 +429,7 @@ public class ResponseTest
|
|||
|
||||
_channel.getRequest().setContext(null, "/");
|
||||
response.recycle();
|
||||
|
||||
|
||||
//test that explicit overrides default
|
||||
response = getResponse();
|
||||
_channel.getRequest().setContext(handler.getServletContext(), "/");
|
||||
|
@ -438,10 +438,10 @@ public class ResponseTest
|
|||
//getWriter should not change explicit character encoding
|
||||
response.getWriter();
|
||||
assertThat("ascii", Matchers.equalTo(response.getCharacterEncoding()));
|
||||
|
||||
|
||||
_channel.getRequest().setContext(null, "/");
|
||||
response.recycle();
|
||||
|
||||
|
||||
//test that assumed overrides default
|
||||
response = getResponse();
|
||||
_channel.getRequest().setContext(handler.getServletContext(), "/");
|
||||
|
@ -450,10 +450,10 @@ public class ResponseTest
|
|||
response.getWriter();
|
||||
//getWriter should not have modified character encoding
|
||||
assertThat("utf-8", Matchers.equalTo(response.getCharacterEncoding()));
|
||||
|
||||
|
||||
_channel.getRequest().setContext(null, "/");
|
||||
response.recycle();
|
||||
|
||||
|
||||
//test that inferred overrides default
|
||||
response = getResponse();
|
||||
_channel.getRequest().setContext(handler.getServletContext(), "/");
|
||||
|
@ -462,10 +462,10 @@ public class ResponseTest
|
|||
//getWriter should not have modified character encoding
|
||||
response.getWriter();
|
||||
assertThat("utf-8", Matchers.equalTo(response.getCharacterEncoding()));
|
||||
|
||||
|
||||
_channel.getRequest().setContext(null, "/");
|
||||
response.recycle();
|
||||
|
||||
|
||||
//test that without a default or any content type, use iso-8859-1
|
||||
response = getResponse();
|
||||
assertThat("iso-8859-1", Matchers.equalTo(response.getCharacterEncoding()));
|
||||
|
@ -473,7 +473,7 @@ public class ResponseTest
|
|||
response.getWriter();
|
||||
assertThat("iso-8859-1", Matchers.equalTo(response.getCharacterEncoding()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLocaleAndContentTypeEncoding() throws Exception
|
||||
{
|
||||
|
@ -488,7 +488,7 @@ public class ResponseTest
|
|||
|
||||
Response response = getResponse();
|
||||
response.getHttpChannel().getRequest().setContext(handler.getServletContext(), "/");
|
||||
|
||||
|
||||
response.setContentType("text/html");
|
||||
assertEquals("iso-8859-1", response.getCharacterEncoding());
|
||||
|
||||
|
@ -562,14 +562,14 @@ public class ResponseTest
|
|||
response.setCharacterEncoding("ISO-8859-1");
|
||||
assertEquals("text/xml;charset=utf-8", response.getContentType());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContentEncodingViaContentTypeChange() throws Exception
|
||||
{
|
||||
Response response = getResponse();
|
||||
response.setContentType("text/html;charset=Shift_Jis");
|
||||
assertEquals("Shift_Jis", response.getCharacterEncoding());
|
||||
|
||||
|
||||
response.setContentType("text/xml");
|
||||
assertEquals("Shift_Jis", response.getCharacterEncoding());
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ public class ResponseTest
|
|||
|
||||
assertEquals("name=value; Path=/path; Domain=domain; Secure; HttpOnly", set);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddCookieInInclude() throws Exception
|
||||
{
|
||||
|
@ -1128,7 +1128,7 @@ public class ResponseTest
|
|||
|
||||
assertNull(response.getHttpFields().get("Set-Cookie"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddCookieSameSiteDefault() throws Exception
|
||||
{
|
||||
|
@ -1145,12 +1145,12 @@ public class ResponseTest
|
|||
response.addCookie(cookie);
|
||||
String set = response.getHttpFields().get("Set-Cookie");
|
||||
assertEquals("name=value; Path=/path; Domain=domain; Secure; HttpOnly; SameSite=Strict", set);
|
||||
|
||||
|
||||
response.getHttpFields().remove("Set-Cookie");
|
||||
|
||||
|
||||
//test bad default samesite value
|
||||
context.setAttribute(HttpCookie.SAME_SITE_DEFAULT_ATTRIBUTE, "FooBar");
|
||||
|
||||
|
||||
assertThrows(IllegalStateException.class,
|
||||
() -> response.addCookie(cookie));
|
||||
}
|
||||
|
@ -1225,7 +1225,7 @@ public class ResponseTest
|
|||
|
||||
response.setContentType("some/type");
|
||||
response.setContentLength(3);
|
||||
response.setHeader(HttpHeader.EXPIRES,"never");
|
||||
response.setHeader(HttpHeader.EXPIRES, "never");
|
||||
|
||||
response.setHeader("SomeHeader", "SomeValue");
|
||||
|
||||
|
@ -1293,7 +1293,7 @@ public class ResponseTest
|
|||
List<String> actual = Collections.list(response.getHttpFields().getValues("Set-Cookie"));
|
||||
assertThat("HttpCookie order", actual, hasItems(expected));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReplaceHttpCookieSameSite()
|
||||
{
|
||||
|
@ -1335,7 +1335,7 @@ public class ResponseTest
|
|||
actual = Collections.list(response.getHttpFields().getValues("Set-Cookie"));
|
||||
assertThat(actual, hasItems(new String[]{"Foo=replaced; Path=/path; Domain=Bah"}));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReplaceParsedHttpCookieSiteDefault()
|
||||
{
|
||||
|
@ -1378,7 +1378,7 @@ public class ResponseTest
|
|||
super(handler, new SessionData(id, "", "0.0.0.0", 0, 0, 0, 300));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestServletContextHandler extends ContextHandler
|
||||
{
|
||||
private class Context extends ContextHandler.Context
|
||||
|
@ -1400,7 +1400,7 @@ public class ResponseTest
|
|||
@Override
|
||||
public void setAttribute(String name, Object object)
|
||||
{
|
||||
_attributes.put(name,object);
|
||||
_attributes.put(name, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -447,7 +447,7 @@ public class ContextHandlerTest
|
|||
assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContextInitializationDestruction() throws Exception
|
||||
{
|
||||
|
@ -858,12 +858,12 @@ public class ContextHandlerTest
|
|||
writer.println("ctx='" + request.getContextPath() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestServletContextListener implements ServletContextListener
|
||||
{
|
||||
public int initialized = 0;
|
||||
public int destroyed = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce)
|
||||
{
|
||||
|
|
|
@ -110,12 +110,12 @@ public class ServletContextHandlerTest
|
|||
private static final AtomicInteger __testServlets = new AtomicInteger();
|
||||
private static int __initIndex = 0;
|
||||
private static int __destroyIndex = 0;
|
||||
|
||||
|
||||
public class StopTestFilter implements Filter
|
||||
{
|
||||
int _initIndex;
|
||||
int _destroyIndex;
|
||||
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ public class ServletContextHandlerTest
|
|||
}
|
||||
|
||||
public class StopTestServlet extends GenericServlet
|
||||
{
|
||||
{
|
||||
int _initIndex;
|
||||
int _destroyIndex;
|
||||
|
||||
|
@ -182,18 +182,18 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
boolean callSessionTimeouts;
|
||||
int timeout;
|
||||
|
||||
|
||||
public MySCI(boolean callSessionTimeouts, int timeout)
|
||||
{
|
||||
this.callSessionTimeouts = callSessionTimeouts;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
|
||||
public MySCI()
|
||||
{
|
||||
this(false, -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException
|
||||
{
|
||||
|
@ -274,24 +274,24 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
boolean callSessionTimeouts;
|
||||
int timeout;
|
||||
|
||||
|
||||
public MyContextListener(boolean callSessionTimeouts, int timeout)
|
||||
{
|
||||
this.callSessionTimeouts = callSessionTimeouts;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
|
||||
public MyContextListener()
|
||||
{
|
||||
this(false, -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce)
|
||||
{
|
||||
assertNull(sce.getServletContext().getAttribute("MyContextListener.contextInitialized"));
|
||||
sce.getServletContext().setAttribute("MyContextListener.contextInitialized", Boolean.TRUE);
|
||||
|
||||
|
||||
assertNull(sce.getServletContext().getAttribute("MyContextListener.defaultSessionTrackingModes"));
|
||||
try
|
||||
{
|
||||
|
@ -301,9 +301,9 @@ public class ServletContextHandlerTest
|
|||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
//Should NOT be able to call getDefaultSessionTrackingModes from programmatic SCL
|
||||
sce.getServletContext().setAttribute("MyContextListener.defaultSessionTrackingModes", Boolean.TRUE);
|
||||
sce.getServletContext().setAttribute("MyContextListener.defaultSessionTrackingModes", Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
assertNull(sce.getServletContext().getAttribute("MyContextListener.effectiveSessionTrackingModes"));
|
||||
try
|
||||
{
|
||||
|
@ -313,9 +313,9 @@ public class ServletContextHandlerTest
|
|||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
//Should NOT be able to call getEffectiveSessionTrackingModes from programmatic SCL
|
||||
sce.getServletContext().setAttribute("MyContextListener.effectiveSessionTrackingModes", Boolean.TRUE);
|
||||
sce.getServletContext().setAttribute("MyContextListener.effectiveSessionTrackingModes", Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
assertNull(sce.getServletContext().getAttribute("MyContextListener.setSessionTrackingModes"));
|
||||
try
|
||||
{
|
||||
|
@ -325,9 +325,9 @@ public class ServletContextHandlerTest
|
|||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
//Should NOT be able to call setSessionTrackingModes from programmatic SCL
|
||||
sce.getServletContext().setAttribute("MyContextListener.setSessionTrackingModes", Boolean.TRUE);
|
||||
sce.getServletContext().setAttribute("MyContextListener.setSessionTrackingModes", Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (callSessionTimeouts)
|
||||
{
|
||||
try
|
||||
|
@ -338,9 +338,9 @@ public class ServletContextHandlerTest
|
|||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
//Should NOT be able to call setSessionTimeout from this SCL
|
||||
sce.getServletContext().setAttribute("MyContextListener.setSessionTimeout", Boolean.TRUE);
|
||||
sce.getServletContext().setAttribute("MyContextListener.setSessionTimeout", Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
sce.getServletContext().getSessionTimeout();
|
||||
|
@ -349,7 +349,7 @@ public class ServletContextHandlerTest
|
|||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
//Should NOT be able to call getSessionTimeout from this SCL
|
||||
sce.getServletContext().setAttribute("MyContextListener.getSessionTimeout", Boolean.TRUE);
|
||||
sce.getServletContext().setAttribute("MyContextListener.getSessionTimeout", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ public class ServletContextHandlerTest
|
|||
}
|
||||
|
||||
public static class MyTestSessionListener implements HttpSessionAttributeListener, HttpSessionListener
|
||||
{
|
||||
{
|
||||
@Override
|
||||
public void sessionCreated(HttpSessionEvent se)
|
||||
{
|
||||
|
@ -410,13 +410,13 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MySCAListener implements ServletContextAttributeListener
|
||||
{
|
||||
public static int adds = 0;
|
||||
public static int removes = 0;
|
||||
public static int replaces = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void attributeAdded(ServletContextAttributeEvent event)
|
||||
{
|
||||
|
@ -443,7 +443,7 @@ public class ServletContextHandlerTest
|
|||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre)
|
||||
{
|
||||
{
|
||||
++destroys;
|
||||
}
|
||||
|
||||
|
@ -453,13 +453,13 @@ public class ServletContextHandlerTest
|
|||
++inits;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyRAListener implements ServletRequestAttributeListener
|
||||
{
|
||||
public static int adds = 0;
|
||||
public static int removes = 0;
|
||||
public static int replaces = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void attributeAdded(ServletRequestAttributeEvent srae)
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ public class ServletContextHandlerTest
|
|||
++replaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MySListener implements HttpSessionListener
|
||||
{
|
||||
public static int creates = 0;
|
||||
|
@ -495,15 +495,14 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
++destroys;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class MySAListener implements HttpSessionAttributeListener
|
||||
{
|
||||
public static int adds = 0;
|
||||
public static int removes = 0;
|
||||
public static int replaces = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void attributeAdded(HttpSessionBindingEvent event)
|
||||
{
|
||||
|
@ -520,20 +519,20 @@ public class ServletContextHandlerTest
|
|||
public void attributeReplaced(HttpSessionBindingEvent event)
|
||||
{
|
||||
++replaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MySIListener implements HttpSessionIdListener
|
||||
{
|
||||
public static int changes = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void sessionIdChanged(HttpSessionEvent event, String oldSessionId)
|
||||
{
|
||||
++changes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ServletContextListener that is designed to be added programmatically,
|
||||
* which should make all of the createListener, createServlet, createFilter
|
||||
|
@ -558,7 +557,7 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
fail(e);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
sce.getServletContext().createServlet(HelloServlet.class);
|
||||
|
@ -572,7 +571,7 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
fail(e);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
sce.getServletContext().createListener(MyContextListener.class);
|
||||
|
@ -587,13 +586,13 @@ public class ServletContextHandlerTest
|
|||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce)
|
||||
{
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class InitialListener implements ServletContextListener
|
||||
{
|
||||
@Override
|
||||
|
@ -639,16 +638,15 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
fail(x);
|
||||
}
|
||||
|
||||
|
||||
sce.getServletContext().setAttribute("foo", "bar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
@ -667,7 +665,7 @@ public class ServletContextHandlerTest
|
|||
_server.stop();
|
||||
_server.join();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInitParams() throws Exception
|
||||
{
|
||||
|
@ -681,7 +679,7 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
sce.getServletContext().setInitParameter("foo", "bar");
|
||||
assertEquals("bar", sce.getServletContext().getInitParameter("foo"));
|
||||
assertThrows(NullPointerException.class,
|
||||
assertThrows(NullPointerException.class,
|
||||
() -> sce.getServletContext().setInitParameter(null, "bad")
|
||||
);
|
||||
assertThrows(NullPointerException.class,
|
||||
|
@ -689,11 +687,11 @@ public class ServletContextHandlerTest
|
|||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
root.getServletHandler().addListener(initialListener);
|
||||
_server.start();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetSetSessionTimeout() throws Exception
|
||||
{
|
||||
|
@ -706,7 +704,7 @@ public class ServletContextHandlerTest
|
|||
root.getSessionHandler().setMaxInactiveInterval((int)TimeUnit.MINUTES.toSeconds(startMin));
|
||||
root.addBean(new MySCIStarter(root.getServletContext(), new MySCI(true, timeout.intValue())), true);
|
||||
_server.start();
|
||||
|
||||
|
||||
//test starting value of setSessionTimeout
|
||||
assertEquals(startMin, (Integer)root.getServletContext().getAttribute("MYSCI.startSessionTimeout"));
|
||||
//test can set session timeout from ServletContainerInitializer
|
||||
|
@ -741,7 +739,7 @@ public class ServletContextHandlerTest
|
|||
root.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
_server.start();
|
||||
_server.stop();
|
||||
|
||||
|
||||
assertEquals(0, stopTestListener._initIndex); //listeners contextInitialized called first
|
||||
assertEquals(1, stopTestFilter._initIndex); //filters init
|
||||
assertEquals(2, stopTestServlet._initIndex); //servlets init
|
||||
|
@ -750,7 +748,7 @@ public class ServletContextHandlerTest
|
|||
assertEquals(1, stopTestServlet._destroyIndex); //servlets destroyed next
|
||||
assertEquals(2, stopTestListener._destroyIndex); //listener contextDestroyed last
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddSessionListener() throws Exception
|
||||
{
|
||||
|
@ -787,7 +785,7 @@ public class ServletContextHandlerTest
|
|||
assertTrue((Boolean)root.getServletContext().getAttribute("MyContextListener.effectiveSessionTrackingModes"));
|
||||
assertTrue((Boolean)root.getServletContext().getAttribute("MyContextListener.setSessionTrackingModes"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContextInitializationDestruction() throws Exception
|
||||
{
|
||||
|
@ -800,7 +798,7 @@ public class ServletContextHandlerTest
|
|||
{
|
||||
public int initialized = 0;
|
||||
public int destroyed = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce)
|
||||
{
|
||||
|
@ -813,7 +811,7 @@ public class ServletContextHandlerTest
|
|||
destroyed++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TestServletContextListener listener = new TestServletContextListener();
|
||||
root.addEventListener(listener);
|
||||
server.start();
|
||||
|
@ -822,7 +820,7 @@ public class ServletContextHandlerTest
|
|||
server.stop();
|
||||
assertEquals(1, listener.destroyed);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testListenersFromContextListener() throws Exception
|
||||
{
|
||||
|
@ -835,7 +833,7 @@ public class ServletContextHandlerTest
|
|||
root.getServletHandler().addListener(initialListener);
|
||||
ServletHolder holder0 = root.addServlet(TestServlet.class, "/test");
|
||||
_server.start();
|
||||
|
||||
|
||||
ListenerHolder[] listenerHolders = root.getServletHandler().getListeners();
|
||||
assertNotNull(listenerHolders);
|
||||
for (ListenerHolder l : listenerHolders)
|
||||
|
@ -852,22 +850,24 @@ public class ServletContextHandlerTest
|
|||
|
||||
List<String> listenerClassNames = new ArrayList<>();
|
||||
for (EventListener l : root.getEventListeners())
|
||||
{
|
||||
listenerClassNames.add(l.getClass().getName());
|
||||
|
||||
}
|
||||
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MySCAListener"));
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MyRequestListener"));
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MyRAListener"));
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MySListener"));
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MySAListener"));
|
||||
assertTrue(listenerClassNames.contains("org.eclipse.jetty.servlet.ServletContextHandlerTest$MySIListener"));
|
||||
|
||||
|
||||
//test ServletRequestAttributeListener
|
||||
String response = _connector.getResponse("GET /test?req=all HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, Matchers.containsString("200 OK"));
|
||||
assertEquals(1, MyRAListener.adds);
|
||||
assertEquals(1, MyRAListener.replaces);
|
||||
assertEquals(1, MyRAListener.removes);
|
||||
|
||||
|
||||
//test HttpSessionAttributeListener
|
||||
response = _connector.getResponse("GET /test?session=create HTTP/1.0\r\n\r\n");
|
||||
String sessionid = response.substring(response.indexOf("JSESSIONID"), response.indexOf(";"));
|
||||
|
@ -898,7 +898,7 @@ public class ServletContextHandlerTest
|
|||
assertEquals(1, MySAListener.adds);
|
||||
assertEquals(1, MySAListener.replaces);
|
||||
assertEquals(1, MySAListener.removes);
|
||||
|
||||
|
||||
//test HttpSessionIdListener.sessionIdChanged
|
||||
request = new StringBuffer();
|
||||
request.append("GET /test?session=change HTTP/1.0\n");
|
||||
|
@ -909,7 +909,7 @@ public class ServletContextHandlerTest
|
|||
assertThat(response, Matchers.containsString("200 OK"));
|
||||
assertEquals(1, MySIListener.changes);
|
||||
sessionid = response.substring(response.indexOf("JSESSIONID"), response.indexOf(";"));
|
||||
|
||||
|
||||
//test HttpServletListener.sessionDestroyed
|
||||
request = new StringBuffer();
|
||||
request.append("GET /test?session=delete HTTP/1.0\n");
|
||||
|
@ -919,7 +919,7 @@ public class ServletContextHandlerTest
|
|||
response = _connector.getResponse(request.toString());
|
||||
assertThat(response, Matchers.containsString("200 OK"));
|
||||
assertEquals(1, MySListener.destroys);
|
||||
|
||||
|
||||
//test ServletContextAttributeListener
|
||||
//attribute was set when context listener registered
|
||||
assertEquals(1, MySCAListener.adds);
|
||||
|
@ -1018,10 +1018,10 @@ public class ServletContextHandlerTest
|
|||
assertTrue(e.getCause() instanceof IllegalStateException);
|
||||
}
|
||||
else
|
||||
fail(e);
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateMethodsFromSCI() throws Exception
|
||||
{
|
||||
|
@ -1063,11 +1063,11 @@ public class ServletContextHandlerTest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
root.addBean(new MySCIStarter(root.getServletContext(), new FilterCreatingSCI()), true);
|
||||
_server.start();
|
||||
_server.start();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateMethodsFromSCL() throws Exception
|
||||
{
|
||||
|
@ -1084,7 +1084,7 @@ public class ServletContextHandlerTest
|
|||
ctx.addListener(new CreatingSCL());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
root.addBean(new MySCIStarter(root.getServletContext(), new ListenerCreatingSCI()), true);
|
||||
_server.start();
|
||||
assertTrue((Boolean)root.getServletContext().getAttribute("CreatingSCL.filter"));
|
||||
|
@ -1148,9 +1148,8 @@ public class ServletContextHandlerTest
|
|||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
});
|
||||
context.addFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
context.getServletHandler().setStartWithUnavailable(false);
|
||||
|
@ -1200,9 +1199,8 @@ public class ServletContextHandlerTest
|
|||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
});
|
||||
context.addFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
context.getServletHandler().setStartWithUnavailable(false);
|
||||
|
@ -1252,9 +1250,8 @@ public class ServletContextHandlerTest
|
|||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
});
|
||||
context.addFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
context.getServletHandler().setStartWithUnavailable(false);
|
||||
|
@ -1275,7 +1272,7 @@ public class ServletContextHandlerTest
|
|||
fail(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddServletFromSCL() throws Exception
|
||||
|
@ -1296,9 +1293,8 @@ public class ServletContextHandlerTest
|
|||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
});
|
||||
_server.setHandler(context);
|
||||
_server.start();
|
||||
|
@ -1329,10 +1325,10 @@ public class ServletContextHandlerTest
|
|||
rego.addMapping("/hello/*");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
root.addBean(new MySCIStarter(root.getServletContext(), new ServletAddingSCI()), true);
|
||||
_server.start();
|
||||
|
||||
|
||||
StringBuffer request = new StringBuffer();
|
||||
request.append("GET /hello HTTP/1.0\n");
|
||||
request.append("Host: localhost\n");
|
||||
|
@ -1455,7 +1451,7 @@ public class ServletContextHandlerTest
|
|||
assertNotNull(mappedServlet.getServletHolder());
|
||||
assertEquals("some.jsp", mappedServlet.getServletHolder().getName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddServletAfterStart() throws Exception
|
||||
{
|
||||
|
@ -1483,7 +1479,7 @@ public class ServletContextHandlerTest
|
|||
response = _connector.getResponse(request.toString());
|
||||
assertThat("Response", response, containsString("Hello World"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testServletRegistrationByClass() throws Exception
|
||||
{
|
||||
|
@ -1523,7 +1519,7 @@ public class ServletContextHandlerTest
|
|||
String response = _connector.getResponse(request.toString());
|
||||
assertThat("Response", response, containsString("Test"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPartialServletRegistrationByName() throws Exception
|
||||
{
|
||||
|
@ -1532,7 +1528,7 @@ public class ServletContextHandlerTest
|
|||
ServletHolder partial = new ServletHolder();
|
||||
partial.setName("test");
|
||||
context.addServlet(partial, "/test");
|
||||
|
||||
|
||||
//complete partial servlet registration by providing name of the servlet class
|
||||
ServletRegistration reg = context.getServletContext().addServlet("test", TestServlet.class.getName());
|
||||
assertNotNull(reg);
|
||||
|
@ -1549,7 +1545,7 @@ public class ServletContextHandlerTest
|
|||
String response = _connector.getResponse(request.toString());
|
||||
assertThat("Response", response, containsString("Test"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPartialServletRegistrationByClass() throws Exception
|
||||
{
|
||||
|
@ -1558,7 +1554,7 @@ public class ServletContextHandlerTest
|
|||
ServletHolder partial = new ServletHolder();
|
||||
partial.setName("test");
|
||||
context.addServlet(partial, "/test");
|
||||
|
||||
|
||||
//complete partial servlet registration by providing the servlet class
|
||||
ServletRegistration reg = context.getServletContext().addServlet("test", TestServlet.class);
|
||||
assertNotNull(reg);
|
||||
|
@ -1576,7 +1572,7 @@ public class ServletContextHandlerTest
|
|||
String response = _connector.getResponse(request.toString());
|
||||
assertThat("Response", response, containsString("Test"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNullServletRegistration() throws Exception
|
||||
{
|
||||
|
@ -1586,7 +1582,7 @@ public class ServletContextHandlerTest
|
|||
full.setName("test");
|
||||
full.setHeldClass(TestServlet.class);
|
||||
context.addServlet(full, "/test");
|
||||
|
||||
|
||||
//Must return null if the servlet has been fully defined previously
|
||||
ServletRegistration reg = context.getServletContext().addServlet("test", TestServlet.class);
|
||||
assertNull(reg);
|
||||
|
@ -1602,7 +1598,7 @@ public class ServletContextHandlerTest
|
|||
String response = _connector.getResponse(request.toString());
|
||||
assertThat("Response", response, containsString("Test"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHandlerBeforeServletHandler() throws Exception
|
||||
{
|
||||
|
@ -1701,23 +1697,23 @@ public class ServletContextHandlerTest
|
|||
@Override
|
||||
protected boolean checkWebResourcePermissions(String pathInContext, Request request, Response response,
|
||||
Object constraintInfo, UserIdentity userIdentity)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//check the linking order
|
||||
context.setSecurityHandler(myHandler);
|
||||
assertSame(myHandler, context.getSecurityHandler());
|
||||
|
||||
|
||||
h = (HandlerWrapper)context.getHandler();
|
||||
assertSame(h, sessionHandler);
|
||||
|
||||
h = (HandlerWrapper)h.getHandler();
|
||||
assertSame(h, myHandler);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReplaceServletHandlerWithoutServlet() throws Exception
|
||||
{
|
||||
|
@ -1857,13 +1853,13 @@ public class ServletContextHandlerTest
|
|||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
{
|
||||
resp.setStatus(HttpServletResponse.SC_OK);
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.write("Hello World");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyFilter implements Filter
|
||||
{
|
||||
|
||||
|
@ -1931,10 +1927,10 @@ public class ServletContextHandlerTest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class FakeJspServlet extends HttpServlet
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class ServletAddingServlet extends HttpServlet
|
||||
|
@ -1953,7 +1949,7 @@ public class ServletContextHandlerTest
|
|||
dynamic.addMapping("/added/*");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class FilterAddingServlet extends HttpServlet
|
||||
{
|
||||
@Override
|
||||
|
@ -2006,7 +2002,7 @@ public class ServletContextHandlerTest
|
|||
resp.setStatus(HttpServletResponse.SC_OK);
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.write("Test");
|
||||
|
||||
|
||||
String action = req.getParameter("session");
|
||||
if (!Objects.isNull(action))
|
||||
{
|
||||
|
@ -2038,7 +2034,7 @@ public class ServletContextHandlerTest
|
|||
}
|
||||
else
|
||||
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2049,10 +2045,10 @@ public class ServletContextHandlerTest
|
|||
req.setAttribute("some", "value");
|
||||
req.setAttribute("some", "other");
|
||||
req.removeAttribute("some");
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
action = req.getParameter("ctx");
|
||||
if (!Objects.isNull(action))
|
||||
{
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -18,7 +18,7 @@
|
|||
<jetty.url>http://www.eclipse.org/jetty</jetty.url>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<build-support.version>1.4</build-support.version>
|
||||
<checkstyle.version>8.20</checkstyle.version>
|
||||
<checkstyle.version>8.29</checkstyle.version>
|
||||
<slf4j.version>2.0.0-alpha1</slf4j.version>
|
||||
<log4j2.version>2.13.0</log4j2.version>
|
||||
<logback.version>1.3.0-alpha5</logback.version>
|
||||
|
|
|
@ -85,14 +85,14 @@ public class DuplicateCookieTest
|
|||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMultipleSessionCookiesOnlyOneValid() throws Exception
|
||||
{
|
||||
String contextPath = "";
|
||||
String servletMapping = "/server";
|
||||
HttpClient client = null;
|
||||
|
||||
|
||||
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
|
||||
SessionDataStoreFactory storeFactory = new TestSessionDataStoreFactory();
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class DuplicateCookieTest
|
|||
createInvalidSession(contextHandler.getSessionHandler().getSessionCache(),
|
||||
contextHandler.getSessionHandler().getSessionCache().getSessionDataStore(),
|
||||
"2233");
|
||||
|
||||
|
||||
client = new HttpClient();
|
||||
client.start();
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class DuplicateCookieTest
|
|||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMultipleSessionCookiesMultipleExists() throws Exception
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ public class DuplicateCookieTest
|
|||
createUnExpiredSession(contextHandler.getSessionHandler().getSessionCache(),
|
||||
contextHandler.getSessionHandler().getSessionCache().getSessionDataStore(),
|
||||
"9111");
|
||||
|
||||
|
||||
client = new HttpClient();
|
||||
client.start();
|
||||
|
||||
|
@ -190,14 +190,14 @@ public class DuplicateCookieTest
|
|||
cache.add(id, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public Session createInvalidSession(SessionCache cache, SessionDataStore store, String id) throws Exception
|
||||
{
|
||||
Session session = createUnExpiredSession(cache, store, id);
|
||||
session._state = Session.State.INVALID;
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
public static class TestServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SessionInvalidationTest
|
|||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TestServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -117,7 +117,7 @@ public class SessionInvalidationTest
|
|||
|
||||
//invalidate existing session
|
||||
session.invalidate();
|
||||
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> session.invalidate());
|
||||
assertThrows(IllegalStateException.class, () -> session.getLastAccessedTime());
|
||||
assertThrows(IllegalStateException.class, () -> session.getCreationTime());
|
||||
|
@ -130,7 +130,6 @@ public class SessionInvalidationTest
|
|||
assertThrows(IllegalStateException.class, () -> session.removeValue("foo"));
|
||||
assertThrows(IllegalStateException.class, () -> session.setAttribute("a", "b"));
|
||||
assertDoesNotThrow(() -> session.getId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue