Package org.jmock

Examples of org.jmock.Mock.expects()


    public void testAddedFoldersShouldCauseFolderAddedEvent() {
        Mock folderMock = mock(FileObject.class);
        DifferenceAnalysingFolderContentHandler handler = new DifferenceAnalysingFolderContentHandler((FileObject) folderMock.proxy(), null);

        Mock addedFolderMock = mock(FileObject.class);
        addedFolderMock.expects(once())
                       .method("getType")
                       .withNoArguments()
                       .will(returnValue(FileType.FOLDER));
        FileObject addedFolder = (FileObject) addedFolderMock.proxy();
View Full Code Here


                       .withNoArguments()
                       .will(returnValue(FileType.FOLDER));
        FileObject addedFolder = (FileObject) addedFolderMock.proxy();

        Mock folderListenerMock = mock(FolderListener.class);
        folderListenerMock.expects(once())
                          .method("folderAdded")
                          .with(same(addedFolder));
        handler.addFolderListener((FolderListener) folderListenerMock.proxy());

        handler.setCurrentChildren(new FileObject[]{addedFolder});
View Full Code Here

    public void testRemovedFoldersShouldCauseFolderRemovedEvent() {
        Mock folderMock = mock(FileObject.class);
        DifferenceAnalysingFolderContentHandler handler = new DifferenceAnalysingFolderContentHandler((FileObject) folderMock.proxy(), null);

        Mock initialFolderOneMock = mock(FileObject.class);
        initialFolderOneMock.expects(once())
                            .method("getType")
                            .withNoArguments()
                            .will(returnValue(FileType.FOLDER));
        FileObject initialFolderOne = (FileObject) initialFolderOneMock.proxy();
        Mock initialFolderTwoMock = mock(FileObject.class);
View Full Code Here

                            .method("getType")
                            .withNoArguments()
                            .will(returnValue(FileType.FOLDER));
        FileObject initialFolderOne = (FileObject) initialFolderOneMock.proxy();
        Mock initialFolderTwoMock = mock(FileObject.class);
        initialFolderTwoMock.expects(once())
                            .method("getType")
                            .withNoArguments()
                            .will(returnValue(FileType.FOLDER));
        initialFolderTwoMock.expects(once())
                            .method("getType")
View Full Code Here

        Mock initialFolderTwoMock = mock(FileObject.class);
        initialFolderTwoMock.expects(once())
                            .method("getType")
                            .withNoArguments()
                            .will(returnValue(FileType.FOLDER));
        initialFolderTwoMock.expects(once())
                            .method("getType")
                            .withNoArguments()
                            .will(returnValue(FileType.FOLDER));
        FileObject initialFolderTwo = (FileObject) initialFolderTwoMock.proxy();
        FileObject[] initialFolders = new FileObject[] {initialFolderOne, initialFolderTwo};
View Full Code Here

        handler.setCurrentChildren(initialFolders);

        FileObject[] foldersAfterRemoval = new FileObject[] {initialFolderOne};
        Mock folderListenerMock = mock(FolderListener.class);
        folderListenerMock.expects(once())
                          .method("folderRemoved")
                          .with(same(initialFolderTwo));
        handler.addFolderListener((FolderListener) folderListenerMock.proxy());

        handler.setCurrentChildren(foldersAfterRemoval);
View Full Code Here

                "    component(A)\n" +
                "}");

        A a = new A();
        Mock cafMock = mock(ComponentAdapterFactory.class);
        cafMock.expects(once()).method("createComponentAdapter").with(same(A.class), same(A.class), eq(null)).will(returnValue(new InstanceComponentAdapter(A.class, a)));
        ComponentAdapterFactory componentAdapterFactory = (ComponentAdapterFactory) cafMock.proxy();
        PicoContainer pico = buildContainer(script, null, componentAdapterFactory);
        assertSame(a, pico.getComponentInstanceOfType(A.class));
    }
View Full Code Here

        Mock newChildFolderMock = mock(FileObject.class, "childFolder");
        FileObject[] newChildren = new FileObject[] {(FileObject) newChildFolderMock.proxy()};

        Mock folderContentHandlerMock = mock(FolderContentHandler.class, "folderContentHandlerMock");

        folderContentHandlerMock.expects(once())
                                .method("getFolder")
                                .withNoArguments()
                                .will(returnValue(rootFolderMock.proxy()));

        rootFolderMock.expects(once())
View Full Code Here

                      .withNoArguments();
        rootFolderMock.expects(once())
                      .method("getChildren")
                      .withNoArguments()
                      .will(returnValue(noChildren));
        folderContentHandlerMock.expects(once())
                                .method("setCurrentChildren")
                                .with(same(noChildren));
        FolderContentPoller fileMonitor = new FolderContentPoller((FolderContentHandler) folderContentHandlerMock.proxy());

        fileMonitor.start();
View Full Code Here

                      .withNoArguments();
        rootFolderMock.expects(once())
                      .method("getChildren")
                      .withNoArguments()
                      .will(returnValue(newChildren));
        folderContentHandlerMock.expects(once())
                                .method("setCurrentChildren")
                                .with(same(newChildren));


        synchronized(fileMonitor) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.