本文整理汇总了Java中org.jbehave.core.io.CodeLocations.codeLocationFromClass方法的典型用法代码示例。如果您正苦于以下问题:Java CodeLocations.codeLocationFromClass方法的具体用法?Java CodeLocations.codeLocationFromClass怎么用?Java CodeLocations.codeLocationFromClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbehave.core.io.CodeLocations
的用法示例。
在下文中一共展示了CodeLocations.codeLocationFromClass方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PlayersCanHazTurns
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
public PlayersCanHazTurns() {
ClassLoader classLoader = this.getClass().getClassLoader();
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
Keywords keywords = new LocalizedKeywords(new Locale("lc"),
"i18n/keywords", classLoader);
Configuration configuration = new MostUsefulConfiguration()
.useKeywords(keywords)
.useStoryParser(new RegexStoryParser(keywords))
.useStoryPathResolver(new UnderscoredCamelCaseResolver(""))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(codeLocation)
.withDefaultFormats()
.withFormats(CONSOLE, TXT)
.withFailureTrace(true)
.withKeywords(keywords));
useConfiguration(configuration);
WindowControl windowControl = new WindowControl();
addSteps(new InstanceStepsFactory(configuration, new LolCatzSteps(windowControl), new BeforeAndAfterSteps(windowControl)).createCandidateSteps());
}
示例2: shouldCreateAndWriteToFilePrintStreamForStoryLocation
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldCreateAndWriteToFilePrintStreamForStoryLocation() throws IOException {
// Given
String storyPath = storyPath(MyStory.class);
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(CodeLocations.codeLocationFromClass(this.getClass()), storyPath));
File file = factory.outputFile();
file.delete();
assertThat(file.exists(), is(false));
// When
PrintStream printStream = factory.createPrintStream();
file = factory.getOutputFile();
printStream.print("Hello World");
// Then
assertThat(file.exists(), is(true));
assertThat(IOUtils.toString(new FileReader(file), true), equalTo("Hello World"));
}
示例3: shouldAllowOverrideOfDefaultConfiguration
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldAllowOverrideOfDefaultConfiguration(){
// Given
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
String storyPath = "org/jbehave/examples/trader/stories/my_given.story";
FileConfiguration configuration = new FileConfiguration("ext");
// When
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
assertThat(factory.configuration(), equalTo(configuration));
FileConfiguration newConfiguration = new FileConfiguration();
factory.useConfiguration(newConfiguration);
// Then
assertThat(factory.configuration(), not(equalTo(configuration)));
assertThat(factory.configuration().toString(), containsString(FileConfiguration.EXTENSION));
assertThat(factory.configuration().toString(), containsString(FileConfiguration.RELATIVE_DIRECTORY));
}
示例4: shouldFailIfPrintStreamCannotBeCreated
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test(expected=PrintStreamCreationFailed.class)
public void shouldFailIfPrintStreamCannotBeCreated(){
// Given
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
String storyPath = "org/jbehave/examples/trader/stories/my_given.story";
FileConfiguration configuration = new FileConfiguration("ext");
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration){
protected File outputDirectory() {
return new File((String)null);
}
};
// When
factory.createPrintStream();
// Then fail as expected
}
示例5: shouldBuildWithCustomReportersAsProvidedFormat
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldBuildWithCustomReportersAsProvidedFormat() throws IOException {
// Given
String storyPath = storyPath(MyStory.class);
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(
CodeLocations.codeLocationFromClass(MyStory.class), storyPath));
StoryReporter txtReporter = new TxtOutput(factory.createPrintStream(), new Properties(),
new LocalizedKeywords(), true);
StoryReporter htmlReporter = new TxtOutput(factory.createPrintStream(), new Properties(),
new LocalizedKeywords(), true);
StoryReporterBuilder builder = new StoryReporterBuilder();
// When
StoryReporter reporter = builder.withReporters(txtReporter, htmlReporter).build(storyPath);
// Then
assertThat(reporter, instanceOf(ConcurrentStoryReporter.class));
StoryReporter delegate = ((ConcurrentStoryReporter) reporter).getDelegate();
assertThat(delegate, instanceOf(DelegatingStoryReporter.class));
Collection<StoryReporter> delegates = ((DelegatingStoryReporter) delegate).getDelegates();
assertThat(delegates.size(), equalTo(2));
assertThat(delegates.contains(txtReporter), is(true));
assertThat(delegates.contains(htmlReporter), is(true));
}
示例6: shouldAllowUseOfGettersAndSetters
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldAllowUseOfGettersAndSetters(){
SpringStoryReporterBuilder builder = new SpringStoryReporterBuilder();
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
builder.setCodeLocation(codeLocation);
assertThat(builder.getCodeLocation(), equalTo(codeLocation));
List<Format> formats = asList(Format.CONSOLE, Format.HTML);
builder.setFormats(formats);
assertThat(builder.getFormats(), equalTo(formats));
Keywords keywords = new LocalizedKeywords();
builder.setKeywords(keywords);
assertThat(builder.getKeywords(), equalTo(keywords));
String relativeDirectory = "reports";
builder.setRelativeDirectory(relativeDirectory);
assertThat(builder.getRelativeDirectory(), equalTo(relativeDirectory));
assertThat(builder.getOutputDirectory(), endsWith(relativeDirectory));
Properties viewResources = new Properties();
builder.setViewResources(viewResources);
assertThat(builder.getViewResources(), equalTo(viewResources));
boolean reportFailureTrace = true;
builder.setReportFailureTrace(reportFailureTrace);
assertThat(builder.isReportFailureTrace(), equalTo(reportFailureTrace));
FilePathResolver pathResolver = new FileConfiguration().getPathResolver();
builder.setPathResolver(pathResolver);
assertThat(builder.getPathResolver(), equalTo(pathResolver));
}
示例7: assertThatOutputNameIs
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
private void assertThatOutputNameIs(String storyPath, String outputName, FilePathResolver pathResolver) {
// Given
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
String extension = "ext";
FileConfiguration configuration = (pathResolver != null ? new FileConfiguration("", extension, pathResolver) : new FileConfiguration(extension));
// When
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
// Then
assertThat(factory.outputName(), equalTo(outputName));
}
示例8: shouldHandleStoryPathInClasspath
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldHandleStoryPathInClasspath() {
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
String storyPath = "org/jbehave/examples/trader/stories/my_given.story";
ensureOutputFileIsSame(codeLocation, storyPath);
}
示例9: shouldHandleStoryPathAsURL
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldHandleStoryPathAsURL() {
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
String storyPath = codeLocation + "org/jbehave/examples/trader/stories/my_given.story";
ensureOutputFileIsSame(codeLocation, storyPath);
}
示例10: shouldHandleStoryPathAsURLWithSpecifiedCodeSourceClass
import org.jbehave.core.io.CodeLocations; //导入方法依赖的package包/类
@Test
public void shouldHandleStoryPathAsURLWithSpecifiedCodeSourceClass() {
URL codeLocation = CodeLocations.codeLocationFromClass(FilePrintStreamFactory.class);
String storyPath = codeLocation + "org/jbehave/examples/trader/stories/my_given.story";
ensureOutputFileIsSame(codeLocation, storyPath);
}