From 6d26b45afed18dd5fe1211ccfbac7eb2587aa9a9 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 15 Oct 2012 12:12:53 +1100 Subject: [PATCH 1/2] 391877 org.eclipse.jetty.webapp.FragmentDescriptor incorrectly reporting duplicate others for after ordering --- .../jetty/webapp/FragmentDescriptor.java | 2 +- .../eclipse/jetty/webapp/OrderingTest.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/FragmentDescriptor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/FragmentDescriptor.java index 884301ba132..3f185df4492 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/FragmentDescriptor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/FragmentDescriptor.java @@ -136,7 +136,7 @@ public class FragmentDescriptor extends WebDescriptor node = (XmlParser.Node) o; if (node.getTag().equalsIgnoreCase("others")) { - if (_otherType != OtherType.After) + if (_otherType != OtherType.None) throw new IllegalStateException("Duplicate clause detected in "+_xml.getURI()); _otherType = OtherType.After; diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/OrderingTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/OrderingTest.java index 529cae4a758..fe109c48cee 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/OrderingTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/OrderingTest.java @@ -852,6 +852,44 @@ public class OrderingTest 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 resources = new ArrayList(); + 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 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 public void testAbsoluteOrderingWithPlainJars() throws Exception From 3920146bf0e1ec2323c588a17b05e0e74a4755f6 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 15 Oct 2012 16:06:07 +1100 Subject: [PATCH 2/2] Remove printlns --- test-jetty-webapp/src/main/java/com/acme/TestListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-jetty-webapp/src/main/java/com/acme/TestListener.java b/test-jetty-webapp/src/main/java/com/acme/TestListener.java index cf950edb7da..02674b48820 100644 --- a/test-jetty-webapp/src/main/java/com/acme/TestListener.java +++ b/test-jetty-webapp/src/main/java/com/acme/TestListener.java @@ -79,14 +79,14 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL ServletSecurity.TransportGuarantee.NONE, new String[]{"admin"}); ServletSecurityElement securityElement = new ServletSecurityElement(constraintElement, null); Set 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 ServletRegistration.Dynamic rego2 = sce.getServletContext().addServlet("RegoTest2", RegTest.class.getName()); rego2.addMapping("/rego2/*"); securityElement = new ServletSecurityElement(constraintElement, null); 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 */ FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());