From 0fa306da07d0b600f98830672e5ad3730735c2c5 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 3 Apr 2015 14:29:04 +0200 Subject: SONAR-6277 Fix id of component when publishing source code in report --- .../src/main/java/org/sonar/batch/report/SourcePublisher.java | 2 +- .../src/test/java/org/sonar/batch/report/SourcePublisherTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sonar-batch') diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/SourcePublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/SourcePublisher.java index ccb91681e2b..8f6b7f3ffb5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/SourcePublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/SourcePublisher.java @@ -46,7 +46,7 @@ public class SourcePublisher implements ReportPublisherStep { } DefaultInputFile inputFile = (DefaultInputFile) resource.inputPath(); - File iofile = writer.getSourceFile(1); + File iofile = writer.getSourceFile(resource.batchId()); int line = 0; try (FileOutputStream output = new FileOutputStream(iofile); BOMInputStream bomIn = new BOMInputStream(new FileInputStream(inputFile.file()), ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/SourcePublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/SourcePublisherTest.java index 824a6da2db9..e9b379a58e2 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/SourcePublisherTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/SourcePublisherTest.java @@ -68,7 +68,7 @@ public class SourcePublisherTest { publisher.publish(writer); - File out = writer.getSourceFile(1); + File out = writer.getSourceFile(2); assertThat(FileUtils.readFileToString(out, Charsets.UTF_8)).isEqualTo(""); } @@ -78,7 +78,7 @@ public class SourcePublisherTest { publisher.publish(writer); - File out = writer.getSourceFile(1); + File out = writer.getSourceFile(2); assertThat(FileUtils.readFileToString(out, Charsets.UTF_8)).isEqualTo("1\n2\n3\n4\n"); } @@ -88,7 +88,7 @@ public class SourcePublisherTest { publisher.publish(writer); - File out = writer.getSourceFile(1); + File out = writer.getSourceFile(2); assertThat(FileUtils.readFileToString(out, Charsets.UTF_8)).isEqualTo("1\n2\n3\n4\n5"); } @@ -98,7 +98,7 @@ public class SourcePublisherTest { publisher.publish(writer); - File out = writer.getSourceFile(1); + File out = writer.getSourceFile(2); assertThat(FileUtils.readFileToString(out, Charsets.UTF_8)).isEqualTo("\n2\n3\n4\n5"); } } -- cgit v1.2.3