FileDocCategorySizeDatePackage
ClasspathConfigurationProviderTest.javaAPI DocExample4535Mon Jul 23 13:26:24 BST 2007org.apache.struts2.config

ClasspathConfigurationProviderTest

public class ClasspathConfigurationProviderTest extends TestCase

Fields Summary
ClasspathConfigurationProvider
provider
com.opensymphony.xwork2.config.Configuration
config
Constructors Summary
Methods Summary
public voidsetUp()

        provider = new ClasspathConfigurationProvider(new String[]{"org.apache.struts2.config"});
        config = new DefaultConfiguration();
        PackageConfig strutsDefault = new PackageConfig("struts-default");
        strutsDefault.addResultTypeConfig(new ResultTypeConfig("dispatcher", ServletDispatcherResult.class.getName(), "location"));
        strutsDefault.setDefaultResultType("dispatcher");
        config.addPackageConfig("struts-default", strutsDefault);
        PackageConfig customPackage = new PackageConfig("custom-package");
        customPackage.setNamespace("/custom");
        config.addPackageConfig("custom-package", customPackage);
        provider.init(config);
        provider.loadPackages();
    
public voidtestActionImplementation()

        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
        assertEquals("/cltest", pkg.getNamespace());
        ActionConfig acfg = pkg.getActionConfigs().get("actionImpl");
        assertNotNull(acfg);
    
public voidtestCustomNamespace()

        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.CustomNamespaceAction");
        Map configs = pkg.getAllActionConfigs();
        // assertEquals(2, configs.size());
        ActionConfig config = (ActionConfig) configs.get("customNamespace");
        assertEquals(config.getPackageName(), pkg.getName());
        assertEquals(1, pkg.getParents().size());
        assertNotNull(config);
        assertEquals("/mynamespace", pkg.getNamespace());
        ActionConfig ac = (ActionConfig) configs.get("customParentPackage");
        assertNotNull(ac);
    
public voidtestFoundRootPackages()

        assertEquals(5, config.getPackageConfigs().size());
        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config");
        assertNotNull(pkg);
        Map configs = pkg.getActionConfigs();
        assertNotNull(configs);
        // assertEquals(1, configs.size());
        ActionConfig actionConfig = (ActionConfig) configs.get("customParentPackage");
        assertNotNull(actionConfig);
    
public voidtestParentPackage()

        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config");
        // assertEquals(2, pkg.getParents().size());
        Map configs = pkg.getActionConfigs();
        ActionConfig config = (ActionConfig) configs.get("customParentPackage");
        assertNotNull(config);
        assertEquals("/custom", pkg.getNamespace());
    
public voidtestResultAnnotations()

        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
        assertEquals("/cltest", pkg.getNamespace());
        ActionConfig acfg = pkg.getActionConfigs().get("twoResult");
        assertNotNull(acfg);
        assertEquals(3, acfg.getResults().size());