-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-73282] Run PCT with a Jetty 12 EE 8 test harness when core is Jetty 12 EE 8 #675
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/main/java/org/jenkins/tools/test/hook/Jetty12Hook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.jenkins.tools.test.hook; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.util.VersionNumber; | ||
import java.io.BufferedInputStream; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UncheckedIOException; | ||
import java.util.jar.JarFile; | ||
import java.util.jar.JarInputStream; | ||
import java.util.jar.Manifest; | ||
import java.util.zip.ZipEntry; | ||
import org.jenkins.tools.test.model.hook.BeforeExecutionContext; | ||
import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeExecution; | ||
import org.kohsuke.MetaInfServices; | ||
|
||
/** | ||
* Ensure that if the core is on Jetty 12, that the test harness is on Jetty 12 as well. | ||
*/ | ||
@MetaInfServices(PluginCompatTesterHookBeforeExecution.class) | ||
public class Jetty12Hook extends PropertyVersionHook { | ||
|
||
@Override | ||
public String getProperty() { | ||
return "jenkins-test-harness.version"; | ||
} | ||
|
||
@Override | ||
public String getMinimumVersion() { | ||
return "2230.v4fa_477b_634f4"; | ||
} | ||
|
||
@Override | ||
public boolean check(@NonNull BeforeExecutionContext context) { | ||
VersionNumber winstoneVersion = getWinstoneVersion(context.getConfig().getWar()); | ||
if (winstoneVersion.getDigitAt(0) < 7) { | ||
return false; | ||
} | ||
return super.check(context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. … but otherwise invoke the logic in the superclass, which dynamically updates |
||
} | ||
|
||
private VersionNumber getWinstoneVersion(File war) { | ||
try (JarFile jarFile = new JarFile(war)) { | ||
ZipEntry zipEntry = jarFile.getEntry("executable/winstone.jar"); | ||
if (zipEntry == null) { | ||
throw new IllegalArgumentException("Failed to find winstone.jar in " + war); | ||
} | ||
try (InputStream is = jarFile.getInputStream(zipEntry); | ||
BufferedInputStream bis = new BufferedInputStream(is); | ||
JarInputStream jis = new JarInputStream(bis)) { | ||
Manifest manifest = jis.getManifest(); | ||
if (manifest == null) { | ||
throw new IllegalArgumentException("Failed to read manifest in " + war); | ||
} | ||
String version = manifest.getMainAttributes().getValue("Implementation-Version"); | ||
if (version == null) { | ||
throw new IllegalArgumentException("Failed to read Winstone version from manifest in " + war); | ||
} | ||
return new VersionNumber(version); | ||
} | ||
} catch (IOException e) { | ||
throw new UncheckedIOException("Failed to read Winstone version in " + war, e); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do nothing if Winstone is Jetty 10 …