Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-13573] Added old 3.x ID of Eclipse parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Apr 24, 2012
1 parent 2c5e73c commit 87eee95
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
Expand Up @@ -51,9 +51,11 @@ public final class WarningsDescriptor extends PluginDescriptor implements Staple
static final String PLUGIN_ID = "warnings";
/** The URL of the result action. */
static final String RESULT_URL = PluginDescriptor.createResultUrlName(PLUGIN_ID);
/** Icon to use for the result and project action. */
/** Prefix of icons in this plug-in. */
public static final String IMAGE_PREFIX = "/plugin/warnings/icons/";
/** Icon to use for the sidebar links. */
public static final String SMALL_ICON_URL = IMAGE_PREFIX + "warnings-24x24.png";
/** Icon to use for the result summary. */
public static final String LARGE_ICON_URL = IMAGE_PREFIX + "warnings-48x48.png";

private final CopyOnWriteList<GroovyParser> groovyParsers = new CopyOnWriteList<GroovyParser>();
Expand Down
Expand Up @@ -77,6 +77,11 @@ protected String getSmallImage() {
return ParserRegistry.getParser(parserName).getSmallImage();
}

/**
* Returns the URL of the 48x48 image used in the build summary.
*
* @return the URL of the image
*/
public String getLargeImage() {
return ParserRegistry.getParser(parserName).getLargeImage();
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/warnings/parser/DiabCParser.java
Expand Up @@ -8,7 +8,7 @@
/**
* A parser for the Diab C++ compiler warnings.
*
* @author Ulli Hafner
* @author Yuta Namiki
*/
@Extension
public class DiabCParser extends RegexpLineParser {
Expand All @@ -21,9 +21,9 @@ public class DiabCParser extends RegexpLineParser {
*/
public DiabCParser() {
super(Messages._Warnings_diabc_ParserName(),
Messages._Warnings_diabc_LinkName(),
Messages._Warnings_diabc_TrendName(),
DIAB_CPP_WARNING_PATTERN);
Messages._Warnings_diabc_LinkName(),
Messages._Warnings_diabc_TrendName(),
DIAB_CPP_WARNING_PATTERN);
}

@Override
Expand Down
Expand Up @@ -27,6 +27,11 @@ public EclipseParser() {
ANT_ECLIPSE_WARNING_PATTERN, true);
}

@Override
protected String getId() {
return "Eclipse Java Compiler";
}

@Override
public String getSmallImage() {
return JavacParser.JAVA_SMALL_ICON;
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @author Ulli Hafner
*/
public class ParserRegistryIntegrationTest extends HudsonTestCase {
private static final String OLD_ID_ECLIPSE_JAVA_COMPILER = "Eclipse Java Compiler";
private static final String JAVA_WARNINGS_FILE = "deprecations.txt";
private static final String OLD_ID_JAVA_COMPILER = "Java Compiler";
private static final String MIXED_API = "Both APIs";
Expand Down Expand Up @@ -66,6 +67,24 @@ public void testOldJavaSerializationActualParsing() throws IOException {
assertEquals("Wrong number of warnings parsed.", 3, annotations.size());
}

/**
* Verifies that we get the Java Eclipse parser if we use the key of the 3.x
* version.
*/
@Test
public void testOldEclipseSerialization() {
verifyEclipseParser(ParserRegistry.getParser(OLD_ID_ECLIPSE_JAVA_COMPILER));
}

private void verifyEclipseParser(final AbstractWarningsParser parser) {
assertEquals("Wrong name",
Messages._Warnings_EclipseParser_ParserName().toString(), parser.getParserName().toString());
assertEquals("Wrong link",
Messages._Warnings_EclipseParser_LinkName().toString(), parser.getLinkName().toString());
assertEquals("Wrong trend",
Messages._Warnings_EclipseParser_TrendName().toString(), parser.getTrendName().toString());
}

/**
* Verifies that we get the Java parser if we use the key of the 3.x
* version.
Expand All @@ -90,15 +109,30 @@ private void verifyJavaParser(final AbstractWarningsParser parser) {
* {@link ParserDescription}) if we use the key of the 3.x version.
*/
@Test
public void testUiMapping() {
boolean isFound = false;
public void testUiMappingJava() {
ParserDescription description = verifyThatParserExists(OLD_ID_JAVA_COMPILER);
verifyJavaParser(ParserRegistry.getParser(description.getGroup()));
}

/**
* Verifies that we get the Eclipse parser (using
* {@link ParserRegistry#getAvailableParsers()} and
* {@link ParserDescription}) if we use the key of the 3.x version.
*/
@Test
public void testUiMappingEclipse() {
ParserDescription description = verifyThatParserExists(OLD_ID_ECLIPSE_JAVA_COMPILER);
verifyEclipseParser(ParserRegistry.getParser(description.getGroup()));
}

private ParserDescription verifyThatParserExists(final String parserName) {
for (ParserDescription description : ParserRegistry.getAvailableParsers()) {
if (description.isInGroup(OLD_ID_JAVA_COMPILER)) {
verifyJavaParser(ParserRegistry.getParser(description.getGroup()));
isFound = true;
if (description.isInGroup(parserName)) {
return description;
}
}
assertTrue("No parser found", isFound);
fail("No parser found for ID: " + parserName);
return null;
}

/**
Expand Down

0 comments on commit 87eee95

Please sign in to comment.