diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index cf703c5863e..19c92057d6c 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -197,6 +197,10 @@ public class Modules implements Iterable Module dependency = _names.get(name); if (dependency!=null) sort.addDependency(module,dependency); + + Set provided = _provided.get(name); + if (provided!=null) + provided.forEach(p->sort.addDependency(module,p)); }; module.getDepends().forEach(add); module.getOptional().forEach(add); diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java index a8f324cb40f..74fa83a8af2 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java @@ -35,6 +35,7 @@ import java.util.Set; import org.eclipse.jetty.start.Props.Prop; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.hamcrest.Matchers; import org.junit.Assert; public class ConfigurationAssert @@ -191,113 +192,34 @@ public class ConfigurationAssert public static void assertContainsUnordered(String msg, Collection expectedSet, Collection actualSet) { - // same size? - boolean mismatch = expectedSet.size() != actualSet.size(); - - // test content - Set missing = new HashSet<>(); - for (String expected : expectedSet) + try { - if (!actualSet.contains(expected)) - { - missing.add(expected); - } + Assert.assertEquals(msg,expectedSet.size(),actualSet.size()); + if (!expectedSet.isEmpty()) + Assert.assertThat(msg,actualSet,Matchers.containsInAnyOrder(expectedSet.toArray())); } - - if (mismatch || missing.size() > 0) + catch(AssertionError e) { - // build up detailed error message - StringWriter message = new StringWriter(); - PrintWriter err = new PrintWriter(message); - - err.printf("%s: Assert Contains (Unordered)",msg); - if (mismatch) - { - err.print(" [size mismatch]"); - } - if (missing.size() >= 0) - { - err.printf(" [%d entries missing]",missing.size()); - } - err.println(); - err.printf("Actual Entries (size: %d)%n",actualSet.size()); - for (String actual : actualSet) - { - char indicator = expectedSet.contains(actual)?' ':'>'; - err.printf("%s| %s%n",indicator,actual); - } - err.printf("Expected Entries (size: %d)%n",expectedSet.size()); - for (String expected : expectedSet) - { - char indicator = actualSet.contains(expected)?' ':'>'; - err.printf("%s| %s%n",indicator,expected); - } - err.flush(); - Assert.fail(message.toString()); + System.err.println("Expected: "+expectedSet); + System.err.println("Actual : "+actualSet); + throw e; } + } public static void assertOrdered(String msg, List expectedList, List actualList) { - // same size? - boolean size_mismatch = expectedList.size() != actualList.size(); - boolean mismatch=size_mismatch; - - // test content - List badEntries = new ArrayList<>(); - int min = Math.min(expectedList.size(),actualList.size()); - int max = Math.max(expectedList.size(),actualList.size()); - for (int i = 0; i < min; i++) + try { - if (!expectedList.get(i).equals(actualList.get(i))) - { - badEntries.add(i); - } + Assert.assertEquals(msg,expectedList.size(),actualList.size()); + if (!expectedList.isEmpty()) + Assert.assertThat(msg,actualList,Matchers.contains(expectedList.toArray())); } - for (int i = min; i < max; i++) + catch(AssertionError e) { - badEntries.add(i); - } - - if (mismatch || badEntries.size() > 0) - { - // build up detailed error message - StringWriter message = new StringWriter(); - PrintWriter err = new PrintWriter(message); - - if (!size_mismatch) - err.println("WARNING ONLY: Ordering tests need review!"); - - err.printf("%s: Assert Contains (Unordered)",msg); - if (mismatch) - { - err.print(" [size mismatch]"); - } - if (badEntries.size() >= 0) - { - err.printf(" [%d entries not matched]",badEntries.size()); - } - err.println(); - err.printf("Actual Entries (size: %d)%n",actualList.size()); - for (int i = 0; i < actualList.size(); i++) - { - String actual = actualList.get(i); - char indicator = badEntries.contains(i)?'>':' '; - err.printf("%s[%d] %s%n",indicator,i,actual); - } - - err.printf("Expected Entries (size: %d)%n",expectedList.size()); - for (int i = 0; i < expectedList.size(); i++) - { - String expected = expectedList.get(i); - char indicator = badEntries.contains(i)?'>':' '; - err.printf("%s[%d] %s%n",indicator,i,expected); - } - err.flush(); - - // TODO fix the order checking to allow alternate orders that comply with graph - if (size_mismatch) - Assert.fail(message.toString()); + System.err.println("Expected: "+expectedList); + System.err.println("Actual : "+actualList); + throw e; } } diff --git a/jetty-start/src/test/resources/usecases/barebones.addToStart.assert.txt b/jetty-start/src/test/resources/usecases/barebones.addToStart.assert.txt index 53429927081..bb27ac14b03 100644 --- a/jetty-start/src/test/resources/usecases/barebones.addToStart.assert.txt +++ b/jetty-start/src/test/resources/usecases/barebones.addToStart.assert.txt @@ -1,7 +1,7 @@ ## The XMLs we expect (order is important) +XML|${jetty.home}/etc/optional.xml XML|${jetty.home}/etc/base.xml XML|${jetty.home}/etc/main.xml -XML|etc/optional.xml # The LIBs we expect (order is irrelevant) LIB|${jetty.home}/lib/base.jar diff --git a/jetty-start/src/test/resources/usecases/ordered-provided.0.assert.txt b/jetty-start/src/test/resources/usecases/ordered-provided.0.assert.txt new file mode 100644 index 00000000000..d56b1b3c87b --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided.0.assert.txt @@ -0,0 +1,7 @@ + +PROP|implA=implA +PROP|implB=implB + +## The XMLs we expect (order is important) +XML|${jetty.base}/etc/implB.xml +XML|${jetty.base}/etc/implA.xml diff --git a/jetty-start/src/test/resources/usecases/ordered-provided.0.prepare.txt b/jetty-start/src/test/resources/usecases/ordered-provided.0.prepare.txt new file mode 100644 index 00000000000..94d4bf924fe --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided.0.prepare.txt @@ -0,0 +1 @@ +--add-to-startd=abstractB,abstractA diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/etc/implA.xml b/jetty-start/src/test/resources/usecases/ordered-provided/etc/implA.xml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/etc/implB.xml b/jetty-start/src/test/resources/usecases/ordered-provided/etc/implB.xml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractA.mod b/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractA.mod new file mode 100644 index 00000000000..9c5870750db --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractA.mod @@ -0,0 +1,9 @@ + +[depend] +dynamic/${implA} + +[ini] +implA=implA + +[ini-template] +implA=implA diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractB.mod b/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractB.mod new file mode 100644 index 00000000000..65a07296272 --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided/modules/abstractB.mod @@ -0,0 +1,12 @@ + +[depend] +dynamic/${implB} + +[provide] +provided + +[ini] +implB=implB + +[ini-template] +implB=implB diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implA.mod b/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implA.mod new file mode 100644 index 00000000000..7665d845a96 --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implA.mod @@ -0,0 +1,6 @@ + +[depend] +provided + +[xml] +etc/implA.xml diff --git a/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implB.mod b/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implB.mod new file mode 100644 index 00000000000..58740f4bde2 --- /dev/null +++ b/jetty-start/src/test/resources/usecases/ordered-provided/modules/dynamic/implB.mod @@ -0,0 +1,3 @@ + +[xml] +etc/implB.xml diff --git a/jetty-start/src/test/resources/usecases/ordered.0.assert.txt b/jetty-start/src/test/resources/usecases/ordered.0.assert.txt index 17119c30a6c..985deb25075 100644 --- a/jetty-start/src/test/resources/usecases/ordered.0.assert.txt +++ b/jetty-start/src/test/resources/usecases/ordered.0.assert.txt @@ -1,3 +1,3 @@ ## The XMLs we expect (order is important) -XML|${jetty.base}/etc/dependent.xml XML|${jetty.base}/etc/alternateA.xml +XML|${jetty.base}/etc/dependent.xml diff --git a/jetty-start/src/test/resources/usecases/ordered.1.assert.txt b/jetty-start/src/test/resources/usecases/ordered.1.assert.txt index 17119c30a6c..985deb25075 100644 --- a/jetty-start/src/test/resources/usecases/ordered.1.assert.txt +++ b/jetty-start/src/test/resources/usecases/ordered.1.assert.txt @@ -1,3 +1,3 @@ ## The XMLs we expect (order is important) -XML|${jetty.base}/etc/dependent.xml XML|${jetty.base}/etc/alternateA.xml +XML|${jetty.base}/etc/dependent.xml diff --git a/jetty-start/src/test/resources/usecases/transientWithIniTemplate.assert.txt b/jetty-start/src/test/resources/usecases/transientWithIniTemplate.assert.txt index 63c290d7c3e..423651e0ce8 100644 --- a/jetty-start/src/test/resources/usecases/transientWithIniTemplate.assert.txt +++ b/jetty-start/src/test/resources/usecases/transientWithIniTemplate.assert.txt @@ -1,8 +1,8 @@ ## The XMLs we expect (order is important) XML|${jetty.home}/etc/base.xml XML|${jetty.home}/etc/main.xml -XML|etc/t.xml -XML|etc/d.xml +XML|${jetty.base}/etc/t.xml +XML|${jetty.base}/etc/d.xml # The LIBs we expect (order is irrelevant) LIB|${jetty.home}/lib/base.jar diff --git a/jetty-start/src/test/resources/usecases/transientWithoutIniTemplate.assert.txt b/jetty-start/src/test/resources/usecases/transientWithoutIniTemplate.assert.txt index 47c3bfc0102..a72ab1eedf6 100644 --- a/jetty-start/src/test/resources/usecases/transientWithoutIniTemplate.assert.txt +++ b/jetty-start/src/test/resources/usecases/transientWithoutIniTemplate.assert.txt @@ -1,8 +1,8 @@ ## The XMLs we expect (order is important) XML|${jetty.home}/etc/base.xml XML|${jetty.home}/etc/main.xml -XML|etc/t.xml -XML|etc/d.xml +XML|${jetty.base}/etc/t.xml +XML|${jetty.base}/etc/d.xml # The LIBs we expect (order is irrelevant) LIB|${jetty.home}/lib/base.jar