Package org.broadleafcommerce.common.extensibility.context

Examples of org.broadleafcommerce.common.extensibility.context.MergeClassPathXMLApplicationContext


    public void test() {
        try {
            /*
             * First we load the merged application context
             */
            MergeClassPathXMLApplicationContext test = new MergeClassPathXMLApplicationContext(new String[]{"org/broadleafcommerce/extensibility/base/applicationContext-src.xml","org/broadleafcommerce/extensibility/base/applicationContext-src2.xml"}, new String[]{"org/broadleafcommerce/extensibility/override/applicationContext-patch1.xml","org/broadleafcommerce/extensibility/override/applicationContext-patch2.xml"}, null);

            ExtensibilityTestBean srcBean = (ExtensibilityTestBean) test.getBean("test3");
            if (!srcBean.getTestProperty().equals("test1")) {
                assert false;
            }
            /*
             * Test to make sure the first patch was applied. This patch involves merging in
             * new properties (and overriding a property and attribute) for a bean
             * with a given id.
             */
            ExtensibilityTestBean bean1 = (ExtensibilityTestBean) test.getBean("test");
            if (!bean1.getTestProperty().equals("test") || !bean1.getTestProperty2().equals("test2")) {
                assert false;
            }
            /*
             * Test to make sure the second patch was applied. This patch involves adding
             * an entirely new bean to the source.
             */
            ExtensibilityTestBean3 bean2 = (ExtensibilityTestBean3) test.getBean("test2");
            if (!bean2.getTestProperty().equals("new") || !bean2.getTestProperty2().equals("none2") || !bean2.getTestProperty3().equals("none3")) {
                assert false;
            }
        } catch (Exception e) {
            logger.error(e);
View Full Code Here


@SuppressWarnings("deprecation")
public class MergeDependencyInjectionTestExecutionListener extends DependencyInjectionTestExecutionListener {

    @Override
    protected void injectDependencies(TestContext testContext) throws Exception {
        MergeClassPathXMLApplicationContext context = BaseTest.getContext();
        Object bean = testContext.getTestInstance();
        AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
        beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
        beanFactory.initializeBean(bean, testContext.getTestClass().getName());
        testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE);
    }
View Full Code Here

                if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Dlegacy=true")) {
                    additionalContexts.add("bl-applicationContext-test-legacy.xml");
                }
               
                String[] strArray = new String[additionalContexts.size()];
                mergeContext = new MergeClassPathXMLApplicationContext(contexts, additionalContexts.toArray(strArray));
               
                //allow for request-scoped beans that can occur in web application contexts
                RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
                mergeContext.getBeanFactory().registerScope("request", new RequestScope());
            }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.common.extensibility.context.MergeClassPathXMLApplicationContext

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.