BuildLoopControllerTest.java :  » Build » cruisecontrol » net » sourceforge » cruisecontrol » dashboard » web » Java Open Source

Java Open Source » Build » cruisecontrol 
cruisecontrol » net » sourceforge » cruisecontrol » dashboard » web » BuildLoopControllerTest.java
package net.sourceforge.cruisecontrol.dashboard.web;

import net.sourceforge.cruisecontrol.BuildLoopInformation;
import net.sourceforge.cruisecontrol.dashboard.repository.BuildInformationRepository;
import net.sourceforge.cruisecontrol.util.BuildInformationHelper;

import org.jmock.Mock;
import org.jmock.cglib.MockObjectTestCase;
import org.springframework.mock.web.MockHttpServletRequest;

public class BuildLoopControllerTest extends MockObjectTestCase {
    public void testBuildLoopShouldPassBuildInfomationProviderRepositoryImpl() throws Exception {
        MockHttpServletRequest req = new MockHttpServletRequest();
        req.setContent("<xml/>".getBytes());
        req.setMethod("POST");
        Mock repositoryMock = mock(BuildInformationRepository.class);
        Mock helperMock = mock(BuildInformationHelper.class);
        BuildLoopController buildLoopController =
                new BuildLoopController((BuildInformationHelper) helperMock.proxy(),
                        (BuildInformationRepository) repositoryMock.proxy());
        BuildLoopInformation buildLoopInformation = new BuildLoopInformation(null, null, null, null);
        helperMock.expects(once()).method("toObject").with(eq("<xml/>")).will(
                returnValue(buildLoopInformation));
        repositoryMock.expects(once()).method("saveOrUpdate").with(eq(buildLoopInformation));
        buildLoopController.handleRequest(req, null);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.