use of cucumber.runtime.xstream.LocalizedXStreams in project cucumber-jvm by cucumber.
the class FromDataTableTest method runStepDef.
private StepDefs runStepDef(Method method, List<DataTableRow> rows) throws Throwable {
StepDefs stepDefs = new StepDefs();
StepDefinition stepDefinition = new StubStepDefinition(stepDefs, method, "some pattern");
Step stepWithRows = new Step(NO_COMMENTS, "Given ", "something", 10, rows, null);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(NO_ARGS, stepDefinition, "some.feature", stepWithRows, new LocalizedXStreams(classLoader));
stepDefinitionMatch.runStep(new I18n("en"));
return stepDefs;
}
use of cucumber.runtime.xstream.LocalizedXStreams in project cucumber-jvm by cucumber.
the class TableParser method parse.
public static DataTable parse(String source, ParameterInfo parameterInfo) {
final List<DataTableRow> rows = new ArrayList<DataTableRow>();
Lexer l = new En(new Listener() {
@Override
public void comment(String comment, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void tag(String tag, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void feature(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void background(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void scenario(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void scenarioOutline(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void examples(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void step(String keyword, String name, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void row(List<String> cells, Integer line) {
rows.add(new DataTableRow(NO_COMMENTS, cells, line));
}
@Override
public void docString(String contentType, String string, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void eof() {
}
});
l.scan(source);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return new DataTable(rows, new TableConverter(new LocalizedXStreams(classLoader).get(Locale.US), parameterInfo));
}
use of cucumber.runtime.xstream.LocalizedXStreams in project cucumber-jvm by cucumber.
the class ToDataTableTest method createTableConverterWithDateFormat.
@Before
public void createTableConverterWithDateFormat() {
LocalizedXStreams.LocalizedXStream xStream = new LocalizedXStreams(Thread.currentThread().getContextClassLoader()).get(Locale.US);
tc = new TableConverter(xStream, new ParameterInfo(null, DD_MM_YYYY, null, null));
}
use of cucumber.runtime.xstream.LocalizedXStreams in project cucumber-jvm by cucumber.
the class DataTableTest method createTable.
private DataTable createTable(List<String>... rows) {
List<DataTableRow> simpleRows = new ArrayList<DataTableRow>();
for (int i = 0; i < rows.length; i++) {
simpleRows.add(new DataTableRow(new ArrayList<Comment>(), rows[i], i + 1));
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
LocalizedXStreams.LocalizedXStream xStream = new LocalizedXStreams(classLoader).get(Locale.US);
return new DataTable(simpleRows, new TableConverter(xStream, null));
}
use of cucumber.runtime.xstream.LocalizedXStreams in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method gives_nice_error_message_when_conversion_fails.
@Test
public void gives_nice_error_message_when_conversion_fails() throws Throwable {
StepDefinition stepDefinition = mock(StepDefinition.class);
when(stepDefinition.getParameterCount()).thenReturn(1);
when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(Thang.class, null, null, null));
Step stepWithoutDocStringOrTable = mock(Step.class);
when(stepWithoutDocStringOrTable.getDocString()).thenReturn(null);
when(stepWithoutDocStringOrTable.getRows()).thenReturn(null);
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(Arrays.asList(new Argument(0, "blah")), stepDefinition, "some.feature", stepWithoutDocStringOrTable, new LocalizedXStreams(classLoader));
try {
stepDefinitionMatch.runStep(ENGLISH);
fail();
} catch (CucumberException expected) {
assertEquals("Don't know how to convert \"blah\" into cucumber.runtime.StepDefinitionMatchTest$Thang.\n" + "Try writing your own converter:\n" + "\n" + "@cucumber.deps.com.thoughtworks.xstream.annotations.XStreamConverter(ThangConverter.class)\n" + "public class Thang {}\n", expected.getMessage());
}
}
Aggregations