Package org.apache.struts.config

Examples of org.apache.struts.config.ExceptionConfig


     */
    public void testProcessExceptionConfigClassNoExtends()
        throws Exception {
        moduleConfig.addExceptionConfig(baseException);

        ExceptionConfig result = null;

        try {
            result =
                actionServlet.processExceptionConfigClass(baseException,
                    moduleConfig, null);
View Full Code Here


     */
    public void testProcessExceptionConfigClassSubConfigCustomClass()
        throws Exception {
        moduleConfig.addExceptionConfig(baseException);

        ExceptionConfig customSub = new ExceptionConfig();

        customSub.setType("java.lang.IllegalStateException");
        customSub.setExtends("java.lang.NullPointerException");
        moduleConfig.addExceptionConfig(customSub);

        ExceptionConfig result =
            actionServlet.processExceptionConfigClass(customSub, moduleConfig,
                null);

        assertSame("The instance returned should be the param given it.",
            customSub, result);
View Full Code Here

     * Make sure the code throws the correct exception when it can't create an
     * instance of the base config's custom class.
     */
    public void notestProcessExceptionConfigClassError()
        throws Exception {
        ExceptionConfig customBase =
            new CustomExceptionConfigArg("java.lang.NullPointerException");

        moduleConfig.addExceptionConfig(customBase);

        ExceptionConfig customSub = new ExceptionConfig();

        customSub.setType("java.lang.IllegalStateException");
        customSub.setExtends("java.lang.NullPointerException");
        moduleConfig.addExceptionConfig(customSub);

        try {
            actionServlet.processExceptionConfigClass(customSub, moduleConfig,
                null);
View Full Code Here

            return (true);
        }

        // Look up the local or global exception handler configuration
        ExceptionConfig exceptionConfig = null;
        ActionConfig actionConfig = actionCtx.getActionConfig();
        ModuleConfig moduleConfig = actionCtx.getModuleConfig();

        if (actionConfig != null) {
            if (LOG.isDebugEnabled()) {
View Full Code Here

        // Process exception config extensions.
        ExceptionConfig[] exceptions = config.findExceptionConfigs();

        for (int i = 0; i < exceptions.length; i++) {
            ExceptionConfig exception = exceptions[i];

            processExceptionExtension(exception, config, null);
        }

        for (int i = 0; i < exceptions.length; i++) {
            ExceptionConfig exception = exceptions[i];

            // Verify that required fields are all present for the config
            if (exception.getKey() == null) {
                handleValueRequiredException("key", exception.getType(),
                    "global exception config");
            }
        }
    }
View Full Code Here

            // Nothing to do, then
            return exceptionConfig;
        }

        // Make sure that this config is of the right class
        ExceptionConfig baseConfig = null;
        if (actionConfig != null) {
            baseConfig = actionConfig.findExceptionConfig(ancestor);
        }

        if (baseConfig == null) {
            // This means either there's no actionConfig anyway, or the
            // ancestor is not defined within the action.
            baseConfig = moduleConfig.findExceptionConfig(ancestor);
        }

        if (baseConfig == null) {
            throw new UnavailableException("Unable to find "
                + "exception config '" + ancestor + "' to extend.");
        }

        // Was our config's class overridden already?
        if (exceptionConfig.getClass().equals(ExceptionConfig.class)) {
            // Ensure that our config is using the correct class
            if (!baseConfig.getClass().equals(exceptionConfig.getClass())) {
                // Replace the config with an instance of the correct class
                ExceptionConfig newExceptionConfig = null;
                String baseConfigClassName = baseConfig.getClass().getName();

                try {
                    newExceptionConfig =
                        (ExceptionConfig) RequestUtils.applicationInstance(
View Full Code Here

            // ... and the exception configs
            ExceptionConfig[] exceptions = actionConfig.findExceptionConfigs();

            for (int j = 0; j < exceptions.length; j++) {
                ExceptionConfig exception = exceptions[j];

                if (exception.getKey() == null) {
                    handleValueRequiredException("key", exception.getType(),
                        "action exception config");
                }
            }
        }
    }
View Full Code Here

            }

            // Process exception extensions.
            ExceptionConfig[] exceptions = actionConfig.findExceptionConfigs();
            for (int i = 0; i < exceptions.length; i++) {
                ExceptionConfig exception = exceptions[i];
                processExceptionExtension(exception, moduleConfig,
                    actionConfig);
            }
        } catch (ServletException e) {
            throw e;
View Full Code Here

     */
    public void testProcessExceptionConfigClassOverriddenSubFormClass()
        throws Exception {
        moduleConfig.addExceptionConfig(baseException);

        ExceptionConfig customSub =
            new CustomExceptionConfigArg("java.lang.IllegalStateException");

        customSub.setExtends("java.lang.NullPointerException");
        moduleConfig.addExceptionConfig(customSub);

        try {
            actionServlet.processExceptionConfigClass(customSub, moduleConfig,
                null);
View Full Code Here

     * Test that an ActionConfig's ExceptionConfig can inherit from a
     * global ExceptionConfig.
     */
    public void testProcessActionExtensionWithExceptionConfig()
        throws ServletException {
        ExceptionConfig exceptionConfig = new ExceptionConfig();
        exceptionConfig.setType("SomeException");
        exceptionConfig.setExtends("java.lang.NullPointerException");
        baseAction.addExceptionConfig(exceptionConfig);

        moduleConfig.addActionConfig(baseAction);
        moduleConfig.addExceptionConfig(baseException);
        actionServlet.processActionConfigExtension(baseAction, moduleConfig);

        exceptionConfig = baseAction.findExceptionConfig("SomeException");

        assertEquals("SomeException's inheritance was not processed.",
            baseException.getKey(), exceptionConfig.getKey());
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.config.ExceptionConfig

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.