Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-22744] Fixed encoding problems with messages using cyr…
…illic alphabet.
  • Loading branch information
uhafner committed Aug 16, 2014
1 parent b383d76 commit 80788b29be3b250e6d75788f03568ed2291c1183
Showing with 45 additions and 9 deletions.
  1. +1 −1 pom.xml
  2. +35 −6 src/test/java/hudson/plugins/tasks/parser/TaskScannerTest.java
  3. +6 −0 src/test/resources/hudson/plugins/tasks/parser/issue22744.java
  4. +3 −2 tasks.iml
@@ -39,7 +39,7 @@
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-core</artifactId>
<version>1.55</version>
<version>1.58-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
@@ -1,11 +1,5 @@
package hudson.plugins.tasks.parser;

import static org.junit.Assert.*;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.util.model.AnnotationContainer;
import hudson.plugins.analysis.util.model.JavaProject;
import hudson.plugins.analysis.util.model.Priority;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -15,6 +9,13 @@

import org.junit.Test;

import static org.junit.Assert.*;

import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.util.model.AnnotationContainer;
import hudson.plugins.analysis.util.model.JavaProject;
import hudson.plugins.analysis.util.model.Priority;

/**
* Tests the class {@link TaskScanner}.
*/
@@ -34,6 +35,34 @@ public class TaskScannerTest {
/** Error message. */
private static final String WRONG_NUMBER_OF_TASKS_ERROR = "Wrong number of tasks found.";

/**
* Parses a warning log with characters in different locale.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-22744">Issue 22744</a>
*/
@Test
public void issue22744() throws IOException {
InputStream file = TaskScannerTest.class.getResourceAsStream("issue22744.java");

Collection<Task> result = new TaskScanner("FIXME", "TODO", "", false).scan(new InputStreamReader(file, "windows-1251"));
assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 2, result.size());

Iterator<Task> warnings = result.iterator();
Task task = warnings.next();
verifyTask(task, Priority.HIGH, "FIXME", 4, "\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Jenkins");
task = warnings.next();
verifyTask(task, Priority.NORMAL, "TODO", 5, "\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c");
}

private void verifyTask(final Task task, final Priority priority, final String tag, final int line, final String message) {
assertEquals("Wrong priority detected: ", priority, task.getPriority());
assertEquals("Wrong tag detected: ", tag, task.getType());
assertEquals("Wrong line detected: ", line, task.getPrimaryLineNumber());
assertEquals("Wrong message detected: ", message, task.getDetailMessage());
}

/**
* Parses a warning log with !!! and !!!! warnings.
*
@@ -0,0 +1,6 @@
package hudson.plugins.tasks.parser;

public class TestTaskScanner {
//FIXME тестирование Jenkins
//TODO пример комментария на русском
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
@@ -18,8 +18,9 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.jvnet.hudson.plugins:analysis-core:1.55" level="project" />
<orderEntry type="module" module-name="analysis-core" />
<orderEntry type="library" name="Maven: de.java2html:java2html:5.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-digester3:3.2" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib:2.2.2" level="project" />
<orderEntry type="library" name="Maven: asm:asm:3.3.1" level="project" />

0 comments on commit 80788b2

Please sign in to comment.