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

Commit

Permalink
[JENKINS-12280] Added testcase for dynamic parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 16, 2012
1 parent 5e313b8 commit 3dae5bc
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 66 deletions.
Expand Up @@ -18,9 +18,6 @@
* Tests the class {@link AntJavacParser}.
*/
public class AntJavacParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two deprecation warnings.
*
Expand Down
Expand Up @@ -14,7 +14,6 @@
* Tests the class {@link ArmccCompilerParser}.
*/
public class ArmccCompilerParserTest extends ParserTester {
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
private static final String WARNING_CATEGORY = ArmccCompilerParser.WARNING_CATEGORY;
private static final String WARNING_TYPE = ArmccCompilerParser.WARNING_TYPE;

Expand Down
Expand Up @@ -14,9 +14,6 @@
* Tests the class {@link CoolfluxChessccParserTest}.
*/
public class CoolfluxChessccParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two warnings.
*
Expand Down
Expand Up @@ -17,11 +17,7 @@
* Tests the class {@link DoxygenParser}.
*/
public class DoxygenParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
/** The category. */
private static final String WARNING_CATEGORY = DoxygenParser.WARNING_CATEGORY;
/** The type. **/
private static final String WARNING_TYPE = DoxygenParser.WARNING_TYPE;

/**
Expand Down
@@ -1,5 +1,12 @@
package hudson.plugins.warnings.parser;

import static junit.framework.Assert.*;
import hudson.plugins.analysis.util.model.FileAnnotation;

import java.io.IOException;
import java.util.Collection;

import org.junit.Test;

/**
* Test the class {@link DynamicParser}.
Expand All @@ -25,6 +32,28 @@ protected WarningsParser createParser() {
+ " return new Warning(fileName, Integer.parseInt(start), \"PHP Runtime Warning\", category, message, priority);\n");
}


/**
* Parses a file with one warning that are started by ant.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-9926">Issue 9926</a>
*/
@Test
public void issue12280() throws IOException {
Collection<FileAnnotation> warnings = new DynamicParser("issue12280",
"^.*: XmlDoc warning (\\w+): (.* type ([^\\s]+)\\..*)$",
"import hudson.plugins.warnings.parser.Warning\n"
+ " String fileName = matcher.group(3)\n"
+ " String category = matcher.group(1)\n"
+ " String message = matcher.group(2)\n"
+ " return new Warning(fileName, 0, \"Xml Doc\", category, message);")
.parse(openFile("issue12280.txt"));

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 9, warnings.size());
}

/** {@inheritDoc} */
@Override
protected String getWarningsFile() {
Expand Down
Expand Up @@ -18,9 +18,6 @@
* Tests the class {@link EclipseParser}.
*/
public class EclipseParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a warning log with console annotations which are removed.
*
Expand Down
Expand Up @@ -19,9 +19,6 @@
* Tests the class {@link FlexSDKParser}.
*/
public class FlexSDKParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two deprecation warnings.
*
Expand Down
Expand Up @@ -14,13 +14,8 @@
* Tests the class {@link Gcc4CompilerParser}.
*/
public class Gcc4CompilerParserTest extends ParserTester {
/** Error message. */
private static final String THERE_ARE_WARNINGS_FOUND = "There are warnings found";
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
/** The category. */
private static final String WARNING_CATEGORY = Gcc4CompilerParser.WARNING_CATEGORY;
/** The type. **/
private static final String WARNING_TYPE = Gcc4CompilerParser.WARNING_TYPE;

/**
Expand Down
Expand Up @@ -14,14 +14,9 @@
* Tests the class {@link Gcc4LinkerParser}.
*/
public class Gcc4LinkerParserTest extends ParserTester {
/** The category. */
private static final String WARNING_CATEGORY = Gcc4LinkerParser.WARNING_CATEGORY;
/** The type. **/
private static final String WARNING_TYPE = Gcc4LinkerParser.WARNING_TYPE;
/** Error message. */
private static final String THERE_ARE_WARNINGS_FOUND = "There are warnings found";
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with GCC linker errors.
Expand Down
Expand Up @@ -14,11 +14,7 @@
* Tests the class {@link GccParser}.
*/
public class GccParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
/** An error. */
private static final String GCC_ERROR = GccParser.GCC_ERROR;
/** A warning. */
private static final String GCC_WARNING = "GCC warning";

/**
Expand Down
Expand Up @@ -14,9 +14,6 @@
* Tests the class {@link GhsMultiParser}.
*/
public class GhsMultiParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two deprecation warnings.
*
Expand Down
Expand Up @@ -14,9 +14,6 @@
* Tests the class {@link IntelCParserTest}.
*/
public class IntelCParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two Intel warnings.
*
Expand Down
Expand Up @@ -15,9 +15,6 @@
* Tests the class {@link JavaDocParser}.
*/
public class JavaDocParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two deprecation warnings.
*
Expand Down
Expand Up @@ -14,9 +14,6 @@
* Tests the class {@link JavacParser}.
*/
public class JavacParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with two deprecation warnings.
*
Expand Down
Expand Up @@ -16,9 +16,6 @@
* Tests the class {@link MsBuildParser}.
*/
public class MsBuildParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with warnings of the MS Build tools.
*
Expand Down
Expand Up @@ -28,9 +28,7 @@
*/
public class ParserRegistryTest {
private static final File DUMMY_FILE = new File("");
/** Filename with all warnings. */
private static final String FILE_NAME = "all.txt";
/** Error message. */
private static final String WRONG_NUMBER_OF_ANNOTATIONS_PARSED = "Wrong number of annotations parsed";

/**
Expand Down
23 changes: 16 additions & 7 deletions src/test/java/hudson/plugins/warnings/parser/ParserTester.java
Expand Up @@ -12,16 +12,25 @@
* Base class for parser tests. Provides an assertion test for warnings.
*/
public abstract class ParserTester {
protected static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Checks the properties of the specified warning.
*
* @param annotation the warning to check
* @param lineNumber the expected line number
* @param message the expected message
* @param fileName the expected filename
* @param type the expected type
* @param category the expected category
* @param priority the expected priority
* @param annotation
* the warning to check
* @param lineNumber
* the expected line number
* @param message
* the expected message
* @param fileName
* the expected filename
* @param type
* the expected type
* @param category
* the expected category
* @param priority
* the expected priority
*/
protected void checkWarning(final FileAnnotation annotation, final int lineNumber, final String message, final String fileName, final String type, final String category, final Priority priority) {
assertTrue("Annotation is of wrong type.", annotation instanceof Warning);
Expand Down
Expand Up @@ -14,9 +14,6 @@
* Tests the class {@link TiCcsParser}.
*/
public class TiCcsParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with warnings of the TI CodeComposer tools.
*
Expand Down
Expand Up @@ -14,10 +14,6 @@
* Tests the class {@link TnsdlParser}.
*/
public class TnsdlParserTest extends ParserTester {

/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
/** An error. */
private static final String WARNING_CATEGORY = TnsdlParser.WARNING_CATEGORY;

/**
Expand Down
Expand Up @@ -12,12 +12,9 @@

/**
* Tests the class {@link YuiCompressorParser}.
* @author EmidioStani
* @author Emidio Stani
*/
public class YuiCompressorParserTest extends ParserTester {
/** Error message. */
private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";

/**
* Parses a file with 3 warnings.
*
Expand Down
11 changes: 11 additions & 0 deletions src/test/resources/hudson/plugins/warnings/parser/issue12280.txt
@@ -0,0 +1,11 @@
StatusSource.cs(47,97): warning CS0618: 'System.Net.Dns.GetHostByName(string)' is obsolete: 'GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202'
SystemNotifier.cs(23,20): warning CS0618: 'Ours.Util.ThreadUtils.MainThread' is obsolete: 'Use InvokeOnMainThread for Invoke calls or MainForm if you need the form'
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Log.LogSettings. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.SubscribeException. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.UnsubscribeException. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.NameServer.NameServerA. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Status.NotifierCollection. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Status.NotifierCollectionEnumerator. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Management.Notifier. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Management.StatusNotifier. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.
Common.targets : XmlDoc warning OUR0100: Missing or insufficient documentation for type Ours.Management.Worker. Types MUST be documented regardless of visibility, preferably describing the purpose/responsibility of, context of, correct use of, and special notions for the type.

0 comments on commit 3dae5bc

Please sign in to comment.