本文整理汇总了Java中org.jmock.integration.junit4.JUnit4Mockery.mock方法的典型用法代码示例。如果您正苦于以下问题:Java JUnit4Mockery.mock方法的具体用法?Java JUnit4Mockery.mock怎么用?Java JUnit4Mockery.mock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jmock.integration.junit4.JUnit4Mockery
的用法示例。
在下文中一共展示了JUnit4Mockery.mock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
authorParser = context.mock(AuthorParser.class);
contentParser = context.mock(ContentParser.class);
dataParser = context.mock(DataParser.class);
fieldParser = context.mock(FieldParser.class);
summaryParser = context.mock(SummaryParser.class);
titleParser = context.mock(TitleParser.class);
updatedParser = context.mock(UpdatedParser.class);
entryParser = new EntryParserImpl(authorParser, contentParser, dataParser,
fieldParser, summaryParser, titleParser,
updatedParser);
try {
document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
fail("Failure to create test document");
}
}
示例2: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() {
context = new JUnit4Mockery();
ancestorLinksRenderer = context.mock(AncestorLinksRenderer.class);
announcementsRenderer = context.mock(AnnouncementsRenderer.class);
attachmentsRenderer = context.mock(AttachmentsRenderer.class);
commentsRenderer = context.mock(CommentsRenderer.class);
contentRenderer = context.mock(ContentRenderer.class);
fileCabinetRenderer = context.mock(FileCabinetRenderer.class);
listRenderer = context.mock(ListRenderer.class);
subpageLinksRenderer = context.mock(SubpageLinksRenderer.class);
titleRenderer = context.mock(TitleRenderer.class);
exporter = new PageExporterImpl(
ancestorLinksRenderer,
announcementsRenderer,
attachmentsRenderer,
commentsRenderer,
contentRenderer,
fileCabinetRenderer,
listRenderer,
subpageLinksRenderer,
titleRenderer);
out = new StringBuilder();
entryStore = new InMemoryEntryStoreFactory().newEntryStore();
}
示例3: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() throws MalformedURLException {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
linkConverter = context.mock(AbsoluteLinkConverter.class);
appendableFactory = context.mock(AppendableFactory.class);
attachmentDownloader = new FakeDownloader();
entryStore = context.mock(EntryStore.class);
entryStoreFactory = context.mock(EntryStoreFactory.class);
feedProvider = context.mock(FeedProvider.class);
pageExporter = context.mock(PageExporter.class);
progressListener = context.mock(ProgressListener.class);
revisionsExporter = context.mock(RevisionsExporter.class);
siteExporter = new SiteExporterImpl(linkConverter, appendableFactory,
attachmentDownloader, entryStoreFactory, feedProvider, pageExporter,
revisionsExporter);
sitesService = new SitesService("");
entries = Sets.newHashSet();
feedUrl = new URL("https://host/feeds/content/domain/webspace");
}
示例4: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() throws Exception {
_mock = new JUnit4Mockery() {
{
setThreadingPolicy(new Synchroniser());
setImposteriser(ClassImposteriser.INSTANCE);
}
};
_searchService = _mock.mock(SearchService.class);
_repository = _mock.mock(Repository.class);
_nodeService = _mock.mock(NodeService.class);
_clusterProbeUtils = new ClusterProbeUtils();
_clusterProbeUtils.setSearchService(_searchService);
_clusterProbeUtils.setRepository(_repository);
_clusterProbeUtils.setNodeService(_nodeService);
}
示例5: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
myMockery = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
myDocument = myMockery.mock(DocumentImpl.class);
myMockery.checking(new Expectations() {{
allowing(myDocument).getTextLength(); will(new CustomAction("getTextLength") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
return myArray.length();
}
});
}});
init(10);
if (myConfig != null) {
myArray.insert(myConfig.text(), 0);
myArray.setDeferredChangeMode(myConfig.deferred());
}
}
示例6: testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseLength
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseLength() {
JUnit4Mockery context = new JUnit4Mockery();
Configuration configurationMock = context.mock(Configuration.class);
context.checking(new Expectations() {{
oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH));
will(returnValue(1.0));
oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH));
will(returnValue(3.0));
oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND));
will(returnValue(0.25));
}});
SafetyZoneService sut = new SafetyZoneService(configurationMock);
Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f);
assertEquals(-15.0, safetyEllipse.getX(), 1e-6);
assertEquals(-2.0, safetyEllipse.getY(), 1e-6);
assertEquals(22.5, safetyEllipse.getBeta(), 1e-6);
assertEquals(75.0, safetyEllipse.getAlpha(), 1e-6);
assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6);
}
示例7: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
myMockery = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
myDocument = myMockery.mock(Document.class);
}
示例8: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
myCollector = new DocumentChangesCollector();
buffer = new StringBuilder(TEXT);
myCollector.setCollectChanges(true);
myMockery = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
myDocument = myMockery.mock(Document.class);
myMockery.checking(new Expectations() {{
allowing(myDocument).getTextLength(); will(returnValue(TEXT.length()));
}});
}
示例9: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
myBuilder = new RichTextControlBuilder();
myMockery = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
myProcessor = myMockery.mock(RichTextControlBuilder.RichTextProcessor.class);
myMockery.checking(new Expectations() {{
allowing(myProcessor).getKey(); will(returnValue(META_KEY));
}});
myBuilder.registerProcessor(myProcessor);
}
示例10: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() throws MalformedURLException {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
sitesService = context.mock(SitesService.class);
entryInserter = context.mock(EntryInserter.class);
entryProvider = context.mock(EntryProvider.class);
entryUpdater = context.mock(EntryUpdater.class);
feedUrl = new URL("http://sites.google.com/feeds/content/site/test");
entryUploader = new EntryUploaderImpl(entryInserter, entryProvider,
entryUpdater);
}
示例11: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() {
context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
progressBar = context.mock(JProgressBar.class);
textComponent = context.mock(JTextComponent.class);
progressListener = new GuiProgressListener(progressBar, textComponent);
}
示例12: before
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void before() {
context = new JUnit4Mockery();
listRenderer = context.mock(ListRenderer.class);
revisionRenderer = context.mock(RevisionRenderer.class);
titleRenderer = context.mock(TitleRenderer.class);
revisionExporter = new RevisionExporterImpl(
listRenderer,
revisionRenderer,
titleRenderer);
out = new StringBuilder();
}
示例13: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
myStrategy = new DefaultLineWrapPositionStrategy();
myMockery = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
myProject = myMockery.mock(Project.class);
}
示例14: setupApplication
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public final void setupApplication() throws Exception {
context = new JUnit4Mockery();
context.setImposteriser(ClassImposteriser.INSTANCE);
myApplication = context.mock(ApplicationEx.class, "application");
context.checking(new Expectations() {
{
allowing(myApplication).isUnitTestMode(); will(returnValue(false));
allowing(myApplication).getName(); will(returnValue("IDEA"));
// some tests leave invokeLater()'s after them
allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class)));
allowing(myApplication).runReadAction(with(any(Runnable.class)));
will(new Action() {
@Override
public void describeTo(final Description description) {
description.appendText("runs runnable");
}
@Override
@Nullable
public Object invoke(final Invocation invocation) throws Throwable {
((Runnable)invocation.getParameter(0)).run();
return null;
}
});
}
});
}
示例15: setUp
import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
controller = new ExportHandler();
context = new JUnit4Mockery() {
{
// only here to mock types that are not interfaces
setImposteriser(ClassImposteriser.INSTANCE);
}
};
doc = context.mock(Document.class);
container = context.mock(XulDomContainer.class);
outputService = context.mock(OutputService.class);
executor = context.mock(SqlExecutor.class);
aggList = new AggListImpl();
controller.setOutputService(outputService);
controller.setAggList(aggList);
controller.setDdlDmlExecutor(executor);
// need some expectations here as setXulDomContainer calls getDocumentRoot on the container
context.checking(new Expectations() {
{
one(container).getDocumentRoot();
will(returnValue(doc));
}
});
controller.setXulDomContainer(container);
}