| 1 | |
package org.jbehave.core.reporters; |
| 2 | |
|
| 3 | |
|
| 4 | |
import java.io.PrintStream; |
| 5 | |
|
| 6 | |
public abstract class Format { |
| 7 | |
|
| 8 | 1 | public static final Format CONSOLE = new Format("CONSOLE") { |
| 9 | |
@Override |
| 10 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 11 | |
StoryReporterBuilder storyReporterBuilder) { |
| 12 | 2 | return new ConsoleOutput(storyReporterBuilder.keywords()).doReportFailureTrace( |
| 13 | |
storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( |
| 14 | |
storyReporterBuilder.compressFailureTrace()); |
| 15 | |
} |
| 16 | |
}; |
| 17 | |
|
| 18 | 1 | public static final Format ANSI_CONSOLE = new Format("ANSI_CONSOLE") { |
| 19 | |
@Override |
| 20 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 21 | |
StoryReporterBuilder storyReporterBuilder) { |
| 22 | 0 | return new ANSIConsoleOutput(storyReporterBuilder.keywords()) |
| 23 | |
.doReportFailureTrace(storyReporterBuilder.reportFailureTrace()) |
| 24 | |
.doCompressFailureTrace(storyReporterBuilder.compressFailureTrace()); |
| 25 | |
} |
| 26 | |
}; |
| 27 | |
|
| 28 | 1 | public static final Format IDE_CONSOLE = new Format("IDE_CONSOLE") { |
| 29 | |
@Override |
| 30 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 31 | |
StoryReporterBuilder storyReporterBuilder) { |
| 32 | 2 | return new IdeOnlyConsoleOutput(storyReporterBuilder.keywords()).doReportFailureTrace( |
| 33 | |
storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( |
| 34 | |
storyReporterBuilder.compressFailureTrace()); |
| 35 | |
} |
| 36 | |
}; |
| 37 | |
|
| 38 | 1 | public static final Format TXT = new Format("TXT") { |
| 39 | |
@Override |
| 40 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 41 | |
StoryReporterBuilder storyReporterBuilder) { |
| 42 | 8 | factory.useConfiguration(storyReporterBuilder.fileConfiguration("txt")); |
| 43 | 8 | return new TxtOutput(factory.createPrintStream(), storyReporterBuilder.keywords()).doReportFailureTrace( |
| 44 | |
storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( |
| 45 | |
storyReporterBuilder.compressFailureTrace()); |
| 46 | |
} |
| 47 | |
}; |
| 48 | |
|
| 49 | 1 | public static final Format HTML = new Format("HTML") { |
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 53 | |
StoryReporterBuilder storyReporterBuilder) { |
| 54 | 4 | factory.useConfiguration(storyReporterBuilder.fileConfiguration("html")); |
| 55 | 4 | return new HtmlOutput(factory.createPrintStream(), storyReporterBuilder.keywords()).doReportFailureTrace( |
| 56 | |
storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( |
| 57 | |
storyReporterBuilder.compressFailureTrace()); |
| 58 | |
} |
| 59 | |
}; |
| 60 | |
|
| 61 | 1 | public static final Format HTML_TEMPLATE = new Format("HTML") { |
| 62 | |
@Override |
| 63 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 64 | |
StoryReporterBuilder storyReporterBuilder) { |
| 65 | 0 | factory.useConfiguration(storyReporterBuilder.fileConfiguration("html")); |
| 66 | 0 | return new HtmlTemplateOuput(factory.getOutputFile(), storyReporterBuilder.keywords()); |
| 67 | |
} |
| 68 | |
}; |
| 69 | |
|
| 70 | 1 | public static final Format XML = new Format("XML") { |
| 71 | |
@Override |
| 72 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 73 | |
StoryReporterBuilder storyReporterBuilder) { |
| 74 | 2 | factory.useConfiguration(storyReporterBuilder.fileConfiguration("xml")); |
| 75 | 2 | return new XmlOutput(factory.createPrintStream(), storyReporterBuilder.keywords()).doReportFailureTrace( |
| 76 | |
storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( |
| 77 | |
storyReporterBuilder.compressFailureTrace()); |
| 78 | |
} |
| 79 | |
}; |
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | 1 | public static final Format STATS = new Format("STATS") { |
| 86 | |
@Override |
| 87 | |
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 88 | |
StoryReporterBuilder storyReporterBuilder) { |
| 89 | 8 | factory.useConfiguration(storyReporterBuilder.fileConfiguration("stats")); |
| 90 | 8 | return new PostStoryStatisticsCollector(factory.createPrintStream()); |
| 91 | |
} |
| 92 | |
}; |
| 93 | |
|
| 94 | |
private final String name; |
| 95 | |
|
| 96 | 13 | public Format(String name) { |
| 97 | 13 | this.name = name; |
| 98 | 13 | } |
| 99 | |
|
| 100 | |
public abstract StoryReporter createStoryReporter(FilePrintStreamFactory factory, |
| 101 | |
StoryReporterBuilder storyReporterBuilder); |
| 102 | |
|
| 103 | |
public String name() { |
| 104 | 36 | return name; |
| 105 | |
} |
| 106 | |
|
| 107 | |
public static void println(PrintStream writer, Object what) { |
| 108 | 218 | writer.println(what); |
| 109 | 218 | } |
| 110 | |
|
| 111 | |
@Override |
| 112 | |
public String toString() { |
| 113 | 0 | return name; |
| 114 | |
} |
| 115 | |
|
| 116 | |
} |