Search in sources :

Example 11 with Mock

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]);
}
Also used : PropertyValue(groovy.lang.PropertyValue) Mock(org.jmock.Mock)

Example 12 with Mock

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.
    }
}
Also used : Mock(org.jmock.Mock)

Example 13 with Mock

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);
}
Also used : Mock(org.jmock.Mock)

Example 14 with Mock

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);
}
Also used : Mock(org.jmock.Mock)

Example 15 with Mock

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);
}
Also used : Project(com.intellij.openapi.project.Project) User(jetbrains.communicator.core.users.User) ConsoleView(com.intellij.execution.ui.ConsoleView) MockIDEFacade(jetbrains.communicator.mock.MockIDEFacade) LocalMessageDispatcherImpl(jetbrains.communicator.core.impl.dispatcher.LocalMessageDispatcherImpl) Mock(org.jmock.Mock)

Aggregations

Mock (org.jmock.Mock)19 MockIDEFacade (jetbrains.communicator.mock.MockIDEFacade)4 HandlerExecutionChain (org.springframework.web.servlet.HandlerExecutionChain)4 IDEFacade (jetbrains.communicator.ide.IDEFacade)3 PropertyValue (groovy.lang.PropertyValue)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UserModelImpl (jetbrains.communicator.core.impl.users.UserModelImpl)2 JabberUI (jetbrains.communicator.jabber.JabberUI)2 HandlerInterceptor (org.springframework.web.servlet.HandlerInterceptor)2 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Project (com.intellij.openapi.project.Project)1 AsyncMessageDispatcher (jetbrains.communicator.core.dispatcher.AsyncMessageDispatcher)1 LocalMessageDispatcherImpl (jetbrains.communicator.core.impl.dispatcher.LocalMessageDispatcherImpl)1 User (jetbrains.communicator.core.users.User)1 MockJabberFacade (jetbrains.communicator.jabber.register.MockJabberFacade)1 Invocation (org.jmock.core.Invocation)1 IsGreaterThan (org.jmock.core.constraint.IsGreaterThan)1 ReturnStub (org.jmock.core.stub.ReturnStub)1 SimpleUrlHandlerMapping (org.springframework.web.servlet.handler.SimpleUrlHandlerMapping)1