|
34 | 34 | import aQute.bnd.build.model.clauses.HeaderClause; |
35 | 35 | import aQute.bnd.build.model.clauses.VersionedClause; |
36 | 36 | import aQute.bnd.build.model.conversions.NoopConverter; |
| 37 | +import aQute.bnd.header.Parameters; |
37 | 38 | import aQute.bnd.help.instructions.ResolutionInstructions.Runorder; |
38 | 39 | import aQute.bnd.osgi.Constants; |
39 | 40 | import aQute.bnd.result.Result; |
@@ -517,24 +518,34 @@ public void testPrintHumanReadableDifference() throws Exception { |
517 | 518 | } |
518 | 519 |
|
519 | 520 | @Test |
520 | | - public void testStartLevelDecoration() throws Exception { |
521 | | - Bndrun bndrun = Bndrun.createBndrun(workspace, IO.getFile(ws.toFile(), "test.simple/resolve.bndrun")); |
| 521 | + public void testStartLevelDecoration(SoftAssertions softly) throws Exception { |
| 522 | + Bndrun bndrun = Bndrun.createBndrun(workspace, IO.getFile(ws.toFile(), "test.simple/resolveduplicates.bndrun")); |
522 | 523 | bndrun.setProperty("-runstartlevel", "order=leastdependenciesfirst,begin=100,step=10"); |
523 | 524 |
|
524 | 525 | // Decorate test.simple to get startlevel 90 (which would otherwise be 110 within the assigned runstartlevel). |
525 | 526 | bndrun.setProperty("-runbundles+", "test.simple;startlevel=90"); |
526 | 527 |
|
527 | 528 | List<? extends HeaderClause> runBundles = List.copyOf(bndrun.resolve(false, false, new NoopConverter<>())); |
528 | 529 |
|
529 | | - assertThat(runBundles).hasSize(2); |
530 | | - assertThat(runBundles.get(0) |
531 | | - .getName()).isEqualTo("osgi.enroute.junit.wrapper"); |
532 | | - assertThat(runBundles.get(0) |
533 | | - .getAttribs()).containsEntry(Constants.RUNBUNDLES_STARTLEVEL_ATTRIBUTE, "100"); |
534 | | - assertThat(runBundles.get(1) |
535 | | - .getName()).isEqualTo("test.simple"); |
536 | | - assertThat(runBundles.get(1) |
537 | | - .getAttribs()).containsEntry(Constants.RUNBUNDLES_STARTLEVEL_ATTRIBUTE, "90"); |
| 530 | + softly.assertThat(runBundles).hasSize(4); |
| 531 | + softly.assertThat(runBundles.stream() |
| 532 | + .map(rb -> rb.toString()) |
| 533 | + .toList()) |
| 534 | + .containsExactlyInAnyOrder("org.apache.felix.gogo.runtime;version='[0.12.0,0.12.1)';startlevel=100", |
| 535 | + "org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)';startlevel=110", |
| 536 | + "osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)';startlevel=120", |
| 537 | + "test.simple;version=snapshot;startlevel=90"); |
| 538 | + |
| 539 | + // check that HeaderClause.toParameters does not remove duplicates |
| 540 | + // this kind of happens inside bndrun.resolve() let's test explicitly |
| 541 | + // again |
| 542 | + Parameters params = HeaderClause.toParameters(runBundles); |
| 543 | + softly.assertThat(params) |
| 544 | + .hasSize(4); |
| 545 | + softly.assertThat(params.toString()) |
| 546 | + .isEqualTo( |
| 547 | + "org.apache.felix.gogo.runtime;version=\"[0.12.0,0.12.1)\";startlevel=100,org.apache.felix.gogo.runtime;version=\"[0.10.0,0.10.1)\";startlevel=110,osgi.enroute.junit.wrapper;version=\"[4.12.0,4.12.1)\";startlevel=120,test.simple;version=snapshot;startlevel=90"); |
| 548 | + |
538 | 549 | } |
539 | 550 |
|
540 | 551 | @SuppressWarnings("resource") |
|
0 commit comments