Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#33: Fixed HtmlSourceAttacher - forced to use text\plain mime type #35

Merged
merged 1 commit into from
Jul 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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