Skip to content

Commit

Permalink
#33: Fixed HtmlSourceAttacher - forced to use text\plain mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
Invictum committed Jul 5, 2018
1 parent ba21112 commit 17d2ac2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import net.thucydides.core.screenshots.ScreenshotAndHtmlSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rp.com.google.common.io.ByteSource;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Date;
import java.util.Optional;

Expand All @@ -18,6 +20,7 @@
*/
public class HtmlSourceAttacher implements StepProcessor {

private final static String MIME = "test/plain";
private final static Logger LOG = LoggerFactory.getLogger(HtmlSourceAttacher.class);

@Override
Expand All @@ -30,7 +33,8 @@ public void proceed(final TestStep step) {
Date timestamp = sourceFile.get().lastModified() < stepStartTime
.getTime() ? stepStartTime : new Date(sourceFile.get().lastModified());
try {
ReportPortalMessage message = new ReportPortalMessage(sourceFile.get(), "HTML Source");
byte[] data = Files.readAllBytes(sourceFile.get().toPath());
ReportPortalMessage message = new ReportPortalMessage(ByteSource.wrap(data), MIME, "HTML Source");
ReportPortal.emitLog(message, Utils.logLevel(step.getResult()), timestamp);
} catch (IOException e) {
LOG.error("Failed to attach sources");
Expand Down

0 comments on commit 17d2ac2

Please sign in to comment.