Title: [1090] trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios: Added scenario that shows that reports can be written to file.
Revision
1090
Author
mauro
Date
2009-02-17 16:16:20 -0600 (Tue, 17 Feb 2009)

Log Message

Added scenario that shows that reports can be written to file.

Added Paths


Diff

Added: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/ReportCanBeWrittenToFile.java (0 => 1090)

--- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/ReportCanBeWrittenToFile.java	                        (rev 0)
+++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/ReportCanBeWrittenToFile.java	2009-02-17 22:16:20 UTC (rev 1090)
@@ -0,0 +1,56 @@
+package org.jbehave.examples.trader.scenarios;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.jbehave.scenario.JUnitScenario;
+import org.jbehave.scenario.MostUsefulConfiguration;
+import org.jbehave.scenario.PropertyBasedConfiguration;
+import org.jbehave.scenario.parser.ClasspathScenarioDefiner;
+import org.jbehave.scenario.parser.PatternScenarioParser;
+import org.jbehave.scenario.parser.ScenarioDefiner;
+import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver;
+import org.jbehave.scenario.reporters.PrintStreamScenarioReporter;
+import org.jbehave.scenario.reporters.ScenarioReporter;
+
+public class ReportCanBeWrittenToFile extends JUnitScenario {
+
+	public ReportCanBeWrittenToFile() {
+		this(Thread.currentThread().getContextClassLoader());
+	}
+
+	public ReportCanBeWrittenToFile(final ClassLoader classLoader) {
+		super(new MyConfiguration(classLoader), new TraderSteps(classLoader));
+	}
+
+	private static class MyConfiguration extends MostUsefulConfiguration {
+		private final ClassLoader classLoader;
+		private final OutputStream outputStream;
+
+		public MyConfiguration(ClassLoader classLoader) {
+			this.classLoader = classLoader;
+			try {
+				File file = File.createTempFile("ScenarioReport", ".txt");
+				this.outputStream = new FileOutputStream(file);
+				System.out.println("Writing output to "+file.getAbsolutePath());
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+
+		public ScenarioDefiner forDefiningScenarios() {
+			return new ClasspathScenarioDefiner(
+					new UnderscoredCamelCaseResolver(".scenario"),
+					new PatternScenarioParser(new PropertyBasedConfiguration()),
+					classLoader);
+		}
+
+		public ScenarioReporter forReportingScenarios() {
+			return new PrintStreamScenarioReporter(
+					new PrintStream(outputStream));
+		}
+	}
+
+}

Added: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario (0 => 1090)

--- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario	                        (rev 0)
+++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario	2009-02-17 22:16:20 UTC (rev 1090)
@@ -0,0 +1,15 @@
+Scenario: Status alert can be activated
+
+Given a stock of prices 0.5,1.0 and a threshold of 10.0
+When the stock is traded at 5.0
+Then the alert status should be OFF
+When the stock is sold at 11.0
+Then the alert status should be ON
+
+Scenario: Trader sells alls stocks
+
+Given a trader of name Mauro
+Given a stock of prices 0.5,1.0 and a threshold of 1.5
+When the stock is traded at 2.0
+Then the trader sells all stocks
+


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to