Package com.opensymphony.xwork2.config.entities

Examples of com.opensymphony.xwork2.config.entities.PackageConfig


        if (pkgConfig == null) {
            pkgConfig = new PackageConfig.Builder(actionPackage);

            pkgConfig.namespace(actionNamespace);
            if (parent == null) {
                PackageConfig cfg = configuration.getPackageConfig(defaultParentPackage);
                if (cfg != null) {
                    pkgConfig.addParent(cfg);
                } else {
                    throw new ConfigurationException("ClasspathPackageProvider: Unable to locate default parent package: " +
                        defaultParentPackage);
View Full Code Here


            Map<String, PackageConfig> configs = new HashMap<String, PackageConfig>();

            Set<PackageConfig.Builder> builders;
            while ((builders = findPackagesWithNoParents()).size() > 0) {
                for (PackageConfig.Builder parent : builders) {
                    PackageConfig config = parent.build();
                    configs.put(config.getName(), config);
                    packageConfigBuilders.remove(config.getName());

                    for (Iterator<Map.Entry<PackageConfig.Builder,PackageConfig.Builder>> i = childToParent.entrySet().iterator(); i.hasNext(); ) {
                        Map.Entry<PackageConfig.Builder,PackageConfig.Builder> entry = i.next();
                        if (entry.getValue() == parent) {
                            entry.getKey().addParent(config);
View Full Code Here

        provider.loadPackages();
    }

    private Configuration createNewConfiguration() {
        Configuration config = new DefaultConfiguration();
        PackageConfig strutsDefault = new PackageConfig.Builder("struts-default")
                .addResultTypeConfig(new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName())
                        .defaultResultParam("location")
                        .build())
                .defaultResultType("dispatcher")
                .build();
        config.addPackageConfig("struts-default", strutsDefault);
        PackageConfig customPackage = new PackageConfig.Builder("custom-package")
            .namespace("/custom")
            .build();
        config.addPackageConfig("custom-package", customPackage);
        return config;
    }
View Full Code Here

        config = null;
    }

    public void testFoundRootPackages() {
        assertEquals(7, 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);
    }
View Full Code Here

       
        assertEquals(0, config.getPackageConfigs().size());
    }

    public void testParentPackage() {
        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());
    }
View Full Code Here

        provider.setActionPackages("org.apache.struts2.config.parenttest");
        provider.init(createNewConfiguration());
        provider.loadPackages();


        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.parenttest");
        // assertEquals(2, pkg.getParents().size());
        assertNotNull(pkg);

        assertEquals("custom-package", pkg.getParents().get(0).getName());
        Map configs = pkg.getActionConfigs();
        ActionConfig config = (ActionConfig) configs.get("some");
        assertNotNull(config);
    }
View Full Code Here

        ActionConfig config = (ActionConfig) configs.get("some");
        assertNotNull(config);
    }

    public void testCustomNamespace() {
        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);
    }
View Full Code Here

        ActionConfig ac = (ActionConfig) configs.get("customParentPackage");
        assertNotNull(ac);
    }
   
    public void testCustomActionAnnotation() {
        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.AnnotatedAction");
        Map configs = pkg.getAllActionConfigs();
        // assertEquals(2, configs.size());
        ActionConfig config = (ActionConfig) configs.get("myaction");
        assertNotNull(config);
    }
View Full Code Here

        ActionConfig config = (ActionConfig) configs.get("myaction");
        assertNotNull(config);
    }
   
    public void testCustomActionAnnotationOfAnyName() {
        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config");
        Map configs = pkg.getAllActionConfigs();
        // assertEquals(2, configs.size());
        ActionConfig config = (ActionConfig) configs.get("myaction2");
        assertNotNull(config);
    }
View Full Code Here

        ActionConfig config = (ActionConfig) configs.get("myaction2");
        assertNotNull(config);
    }
   
    public void testResultAnnotations() {
        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
        assertEquals("/cltest", pkg.getNamespace());
        ActionConfig acfg = pkg.getActionConfigs().get("twoResult");
        assertNotNull(acfg);
        assertEquals(2, acfg.getResults().size());
        assertEquals("input.jsp", acfg.getResults().get("input").getParams().get("location"));
        assertEquals("bob", acfg.getResults().get("chain").getParams().get("location"));

        acfg = pkg.getActionConfigs().get("oneResult");
        assertNotNull(acfg);
        assertEquals(1, acfg.getResults().size());
        assertEquals("input-parent.jsp", acfg.getResults().get("input").getParams().get("location"));
    }
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.entities.PackageConfig

Copyright © 2018 www.massapicom. 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.