Merge remote-tracking branch 'origin/jetty-8'

This commit is contained in:
Greg Wilkins 2012-10-18 09:57:53 +11:00
commit 3146a83372
3 changed files with 41 additions and 3 deletions

View File

@ -136,7 +136,7 @@ public class FragmentDescriptor extends WebDescriptor
node = (XmlParser.Node) o; node = (XmlParser.Node) o;
if (node.getTag().equalsIgnoreCase("others")) if (node.getTag().equalsIgnoreCase("others"))
{ {
if (_otherType != OtherType.After) if (_otherType != OtherType.None)
throw new IllegalStateException("Duplicate <other> clause detected in "+_xml.getURI()); throw new IllegalStateException("Duplicate <other> clause detected in "+_xml.getURI());
_otherType = OtherType.After; _otherType = OtherType.After;

View File

@ -852,6 +852,44 @@ public class OrderingTest
fail ("No outcome matched "+result); fail ("No outcome matched "+result);
} }
@Test
public void testRelativeOrderingWithPlainJars2 ()
throws Exception
{
//web.xml has no ordering, jar A has fragment after others, jar B is plain, jar C is plain
List<Resource> resources = new ArrayList<Resource>();
WebAppContext wac = new WebAppContext();
MetaData metaData = new MetaData();
metaData._ordering = new RelativeOrdering(metaData);
//A has after others
TestResource jar1 = new TestResource("A");
resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1);
f1._otherType = FragmentDescriptor.OtherType.After;
//No fragment jar B
TestResource r4 = new TestResource("plainB");
resources.add(r4);
//No fragment jar C
TestResource r5 = new TestResource("plainC");
resources.add(r5);
List<Resource> orderedList = metaData._ordering.order(resources);
String[] outcomes = {"plainBplainCA"};
String result = "";
for (Resource r:orderedList)
result+=(((TestResource)r)._name);
if (!checkResult(result, outcomes))
fail ("No outcome matched "+result);
}
@Test @Test
public void testAbsoluteOrderingWithPlainJars() public void testAbsoluteOrderingWithPlainJars()
throws Exception throws Exception

View File

@ -79,14 +79,14 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
ServletSecurity.TransportGuarantee.NONE, new String[]{"admin"}); ServletSecurity.TransportGuarantee.NONE, new String[]{"admin"});
ServletSecurityElement securityElement = new ServletSecurityElement(constraintElement, null); ServletSecurityElement securityElement = new ServletSecurityElement(constraintElement, null);
Set<String> unchanged = rego.setServletSecurity(securityElement); Set<String> unchanged = rego.setServletSecurity(securityElement);
System.err.println("Security constraints registered: "+unchanged.isEmpty()); //System.err.println("Security constraints registered: "+unchanged.isEmpty());
//Test that a security constraint from web.xml can't be overridden programmatically //Test that a security constraint from web.xml can't be overridden programmatically
ServletRegistration.Dynamic rego2 = sce.getServletContext().addServlet("RegoTest2", RegTest.class.getName()); ServletRegistration.Dynamic rego2 = sce.getServletContext().addServlet("RegoTest2", RegTest.class.getName());
rego2.addMapping("/rego2/*"); rego2.addMapping("/rego2/*");
securityElement = new ServletSecurityElement(constraintElement, null); securityElement = new ServletSecurityElement(constraintElement, null);
unchanged = rego2.setServletSecurity(securityElement); unchanged = rego2.setServletSecurity(securityElement);
System.err.println("Overridding web.xml constraints not possible:" +!unchanged.isEmpty()); //System.err.println("Overridding web.xml constraints not possible:" +!unchanged.isEmpty());
/* For servlet 3.0 */ /* For servlet 3.0 */
FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName()); FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());