use of org.jmock.Mock in project groovy-core by groovy.
the class InspectorTest method testInspectUninspectableProperty.
// TODO: if our code can never access inspect in this way, it would be better
// to move this to a boundary class and then we wouldn't need this test
public void testInspectUninspectableProperty() {
Object dummyInstance = new Object();
Inspector inspector = getTestableInspector(dummyInstance);
Class[] paramTypes = { Object.class, MetaProperty.class };
Object[] params = { null, null };
Mock mock = mock(PropertyValue.class, paramTypes, params);
mock.expects(once()).method("getType");
mock.expects(once()).method("getName");
mock.expects(once()).method("getValue").will(throwException(new RuntimeException()));
PropertyValue propertyValue = (PropertyValue) mock.proxy();
String[] result = inspector.fieldInfo(propertyValue);
assertEquals(Inspector.NOT_APPLICABLE, result[Inspector.MEMBER_VALUE_IDX]);
}
use of org.jmock.Mock in project gocd by gocd.
the class CompositeExtractorTest method testShouldThrowExceptionToStopParsingWhenAllHandlersCanStop.
public void testShouldThrowExceptionToStopParsingWhenAllHandlersCanStop() throws Exception {
Mock handler1 = mock(SAXBasedExtractor.class);
Mock handler2 = mock(SAXBasedExtractor.class);
handler1.expects(once()).method("characters").with(eq(null), eq(0), eq(2));
handler2.expects(once()).method("characters").with(eq(null), eq(0), eq(2));
handler1.expects(once()).method("canStop").will(returnValue(true));
handler2.expects(once()).method("canStop").will(returnValue(true));
com.thoughtworks.go.legacywrapper.CompositeExtractor handler = new com.thoughtworks.go.legacywrapper.CompositeExtractor(extractors(handler1, handler2));
try {
handler.characters(null, 0, 2);
fail();
} catch (ShouldStopParsingException e) {
// ok.
}
}
use of org.jmock.Mock in project gocd by gocd.
the class CompositeExtractorTest method testShouldCallAllHandlers.
public void testShouldCallAllHandlers() throws Exception {
Mock handler1 = mock(SAXBasedExtractor.class);
Mock handler2 = mock(SAXBasedExtractor.class);
handler1.expects(once()).method("characters").with(eq(null), eq(0), eq(2));
handler2.expects(once()).method("characters").with(eq(null), eq(0), eq(2));
handler1.expects(once()).method("canStop").will(returnValue(false));
com.thoughtworks.go.legacywrapper.CompositeExtractor handler = new com.thoughtworks.go.legacywrapper.CompositeExtractor(extractors(handler1, handler2));
handler.characters(null, 0, 2);
}
use of org.jmock.Mock in project gocd by gocd.
the class CompositeExtractorTest method testShouldCallAllExtractors.
public void testShouldCallAllExtractors() throws Exception {
Mock extractor1 = mock(SAXBasedExtractor.class);
Mock extractor2 = mock(SAXBasedExtractor.class);
extractor1.expects(once()).method("report").with(ANYTHING);
extractor2.expects(once()).method("report").with(ANYTHING);
com.thoughtworks.go.legacywrapper.CompositeExtractor handler = new com.thoughtworks.go.legacywrapper.CompositeExtractor(extractors(extractor1, extractor2));
handler.report(null);
}
use of org.jmock.Mock in project intellij-plugins by JetBrains.
the class MessagesTabTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myUserMock = mock(User.class);
myUser = (User) myUserMock.proxy();
final Mock consoleStub = mock(ConsoleView.class);
consoleStub.stubs().method(ANYTHING);
consoleStub.stubs().method("getComponent").will(returnValue(new JLabel()));
LocalMessageDispatcherImpl localMessageDispatcher = new LocalMessageDispatcherImpl(getBroadcaster(), new MockIDEFacade(getClass()), null);
disposeOnTearDown(localMessageDispatcher);
myMessagesTab = new MessagesTab(null, myUser, localMessageDispatcher, true) {
@Override
protected ConsoleView createConsoleView(Project project) {
return (ConsoleView) consoleStub.proxy();
}
};
disposeOnTearDown(myMessagesTab);
}
Aggregations