FileDocCategorySizeDatePackage
CompositeActionMapperTest.javaAPI DocExample5360Mon Jul 23 13:26:10 BST 2007org.apache.struts2.dispatcher.mapper

CompositeActionMapperTest

public class CompositeActionMapperTest extends TestCase
version
$Date: 2006-11-23 12:31:52 -0500 (Thu, 23 Nov 2006) $ $Id: CompositeActionMapperTest.java 478625 2006-11-23 17:31:52Z wsmoak $

Fields Summary
CompositeActionMapper
compositeActionMapper
com.mockobjects.dynamic.Mock
mockContainer
Constructors Summary
Methods Summary
public voidsetUp()

        compositeActionMapper = new CompositeActionMapper();
        mockContainer = new Mock(Container.class);
        compositeActionMapper.setContainer((Container)mockContainer.proxy());
    
public voidtestGetActionMappingAndUri1()

        ActionMapper mapper1 = new InnerActionMapper1();
        ActionMapper mapper2 = new InnerActionMapper2();
        ActionMapper mapper3 = new InnerActionMapper3();
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper1")), mapper1);
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper2")), mapper3);
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper3")), mapper2);
        compositeActionMapper.setActionMappers("mapper1,mapper2,mapper3");
        
        ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
        String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
        mockContainer.verify();
        
        assertNotNull(actionMapping);
        assertNotNull(uri);
        assertTrue(actionMapping == InnerActionMapper3.actionMapping);
        assertTrue(uri == InnerActionMapper3.uri);
        
    
public voidtestGetActionMappingAndUri2()

        ActionMapper mapper1 = new InnerActionMapper1();
        ActionMapper mapper2 = new InnerActionMapper2();
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper1")), mapper1);
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper2")), mapper2);
        compositeActionMapper.setActionMappers("mapper1,mapper2");

        ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
        String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
        mockContainer.verify();

        assertNull(actionMapping);
        assertNull(uri);