Search in sources :

Example 1 with MyFacesContainer

use of org.apache.myfaces.mc.test.core.runner.MyFacesContainer in project deltaspike by apache.

the class MyFacesContainerAdapter method boot.

public void boot() {
    final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    this.mockedMyFacesTestContainer = new MyFacesContainer(new TestClass(this.testClass)) {

        @Override
        protected String getWebappResourcePath() {
            TestConfig testConfig = testClass.getJavaClass().getAnnotation(TestConfig.class);
            if (testConfig == null || DEFAULT_TEST_CONFIG_LITERAL.webappResourcePath().equals(testConfig.webappResourcePath())) {
                return MyFacesTestBaseConfig.WEBAPP_RESOURCE_PATH;
            }
            return testConfig.webappResourcePath();
        }

        @Override
        protected void setUpServletObjects() {
            //just needed for MyFaces-Test util v1.0.7
            //(to bypass issues with the outdated URLClassLoader used by AbstractJsfTestContainer)
            setCurrentClassLoader(originalClassLoader);
            super.setUpServletObjects();
        }

        @Override
        protected void setUpWebConfigParams() {
            servletContext.addInitParameter("org.apache.myfaces.config.annotation.LifecycleProvider", "org.apache.myfaces.config.annotation.NoInjectionAnnotationLifecycleProvider");
            servletContext.addInitParameter("org.apache.myfaces.CHECKED_VIEWID_CACHE_ENABLED", "false");
            servletContext.addInitParameter(ExpressionFactory.class.getName(), "org.apache.el.ExpressionFactoryImpl");
            super.setUpWebConfigParams();
            initContainerConfig();
            //add custom values (might replace the default values)
            for (Map.Entry<String, String> entry : containerConfig.entrySet()) {
                servletContext.addInitParameter(entry.getKey(), entry.getValue());
            }
        }
    };
    this.mockedMyFacesTestContainer.setUp(new Object());
}
Also used : TestConfig(org.apache.myfaces.mc.test.core.annotation.TestConfig) MyFacesContainer(org.apache.myfaces.mc.test.core.runner.MyFacesContainer) TestClass(org.junit.runners.model.TestClass)

Aggregations

TestConfig (org.apache.myfaces.mc.test.core.annotation.TestConfig)1 MyFacesContainer (org.apache.myfaces.mc.test.core.runner.MyFacesContainer)1 TestClass (org.junit.runners.model.TestClass)1