Skip to content

Commit ff2fa83

Browse files
committed
Fix TargetDefinitionResolutionTests
Test is supposed to verify that the corresponding source bundles are there and this should be independent of whether it's coming from source feature or not. Test has been extended to actually check that there are source bundles for every bundle in the feature as it was only checking that there are target bundles for all source bundles but if a source bundle was missing that could have easily be missed. Side effect assertion about non-source bundle in source feature is being dropped as source features are on their way out. Fixes #1838 .
1 parent 6fe40d8 commit ff2fa83

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionResolutionTests.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009, 2023 IBM Corporation and others.
2+
* Copyright (c) 2009, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -22,6 +22,8 @@
2222
import java.io.File;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25+
import java.util.List;
26+
import java.util.stream.Stream;
2527

2628
import org.eclipse.core.runtime.IStatus;
2729
import org.eclipse.equinox.frameworkadmin.BundleInfo;
@@ -437,13 +439,12 @@ public void testSourceBundleRecognition() throws Exception {
437439
featureWithCorrespondingSourceFeature,
438440
null);
439441

440-
ITargetLocation featureContainer2 = getTargetService().newFeatureLocation(defaultLocation,
441-
featureWithCorrespondingSourceFeature + ".source", null);
442-
443-
definition.setTargetLocations(new ITargetLocation[]{directoryContainer, profileContainer, featureContainer, featureContainer2});
442+
definition.setTargetLocations(
443+
new ITargetLocation[] { directoryContainer, profileContainer, featureContainer });
444444
definition.resolve(null);
445445

446446
TargetBundle[] bundles = definition.getBundles();
447+
List<String> bundleNames = Stream.of(bundles).map(bundle -> bundle.getBundleInfo().getSymbolicName()).toList();
447448

448449
assertNotNull("Target didn't resolve",bundles);
449450

@@ -460,12 +461,17 @@ public void testSourceBundleRecognition() throws Exception {
460461
}
461462
}
462463

463-
// Everything in the JDT feature has an equivalent named source bundle
464-
bundles = featureContainer2.getBundles();
465-
for (TargetBundle bundle : bundles) {
466-
if (bundle.getBundleInfo().getSymbolicName().indexOf("doc") == -1){
467-
assertTrue("Non-source bundle in source feature", bundle.isSourceBundle());
468-
assertEquals("Incorrect source target", bundle.getBundleInfo().getSymbolicName(),bundle.getSourceTarget().getSymbolicName()+".source");
464+
// Everything in the feature has an equivalent named source bundle
465+
for (TargetBundle bundle : featureContainer.getBundles()) {
466+
if (bundle.getBundleInfo().getSymbolicName().indexOf("doc") != -1) {
467+
return;
468+
}
469+
if (bundle.isSourceBundle()) {
470+
assertEquals("Incorrect source target", bundle.getBundleInfo().getSymbolicName(),
471+
bundle.getSourceTarget().getSymbolicName() + ".source");
472+
} else {
473+
assertTrue("Missing source for bundle " + bundle.getBundleInfo().getSymbolicName(),
474+
bundleNames.contains(bundle.getBundleInfo().getSymbolicName() + ".source"));
469475
}
470476
}
471477
}

0 commit comments

Comments
 (0)