Skip to content

Commit

Permalink
Create test case for EE baseline warnings due to missing Manifest header
Browse files Browse the repository at this point in the history
This checks whether no error is produced when both, the
Bundle-RequiredExecutionEvironment header as well as an 'osgi.ee'
element for the Require-Capability are missing from the manifest.

See #1386
  • Loading branch information
ptziegler authored and HannesWell committed Sep 6, 2024
1 parent 1b87cbf commit 644a430
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
Expand Down Expand Up @@ -178,6 +179,20 @@ public void testExecutionEnvironment() throws CoreException {
new String[] { "JavaSE-17" }, bundleB.getExecutionEnvironments()); //$NON-NLS-1$
}

/**
* Tests whether missing execution environments in the manifest are detected
* correctly.
*/
public void testNoExecutionEnvironment() throws CoreException {
// Verify that the test-project is an existing java project in order to
// ensure it gets the EE of the bound JDK injected (because it does not
// declare an EE in its Manifest).
assertTrue(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("bundle.c")).exists()); //$NON-NLS-1$
IApiComponent bundleC = getComponent("bundle.c"); //$NON-NLS-1$
assertArrayEquals("Expected no EE because none is specified in the Manifest", //$NON-NLS-1$
new String[] {}, bundleC.getExecutionEnvironments());
}

/**
* Tests all packages are returned.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bundle.b</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: API Tools Tests Plug-in C
Bundle-SymbolicName: bundle.c
Bundle-Version: 1.0.0
Export-Package: test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

0 comments on commit 644a430

Please sign in to comment.