protected MuleContext createMuleContext() throws Exception { if (isDisposeContextPerClass() && muleContext != null) { context = muleContext; } else { final ClassLoader executionClassLoader = getExecutionClassLoader(); final ClassLoader originalContextClassLoader = currentThread().getContextClassLoader(); try { builders.add(new SimpleConfigurationBuilder(getStartUpRegistryObjects())); addBuilders(builders); builders.add(new MockExtensionManagerConfigurationBuilder()); builders.add(getBuilder()); MuleContextBuilder contextBuilder = MuleContextBuilder.builder(APP); DefaultMuleConfiguration muleConfiguration = new DefaultMuleConfiguration(); contextBuilder.setMuleConfiguration(muleConfiguration); contextBuilder.setExecutionClassLoader(executionClassLoader); contextBuilder.setObjectSerializer(getObjectSerializer()); contextBuilder.setDeploymentProperties(getDeploymentProperties()); configureMuleContext(contextBuilder); context = muleContextFactory.createMuleContext(builders, contextBuilder); recordSchedulersOnInit(context); if (!isGracefulShutdown()) {
@Override protected void doSetUp() throws Exception { super.doSetUp(); scheduler = muleContext.getSchedulerService().cpuIntensiveScheduler(); }
@After public final void disposeContextPerTest() throws Exception { try { doTearDown(); } finally { if (!isDisposeContextPerClass()) { if (isStartContext() && muleContext != null && muleContext.isStarted()) { muleContext.stop(); } disposeContext(); if (testServicesConfigurationBuilder != null) { testServicesConfigurationBuilder.stopServices(); } doTearDownAfterMuleContextDispose(); } // When an Assumption fails then junit doesn't call @Before methods so we need to avoid // executing delete if there's no root folder. workingDirectory.delete(); } }
@Before public final void setUpMuleContext() throws Exception { if (!logConfigured) { configureLoggingForTest(getClass()); logConfigured = true; } workingDirectory.create(); String workingDirectoryOldValue = System.setProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY, workingDirectory.getRoot().getAbsolutePath()); try { doSetUpBeforeMuleContextCreation(); muleContext = createMuleContext(); if (doTestClassInjection()) { muleContext.getInjector().inject(this); } if (isStartContext() && muleContext != null && !muleContext.isStarted()) { startMuleContext(); } doSetUp(); } finally { if (workingDirectoryOldValue != null) { System.setProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY, workingDirectoryOldValue); } else { System.clearProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY); } } }
@Override protected void doTearDown() throws Exception { synchronized (runners) { tearingDown = true; for (FlowRunner runner : runners) { runner.dispose(); } } super.doTearDown(); }
@Override protected Map<String, Object> getStartUpRegistryObjects() { final Map<String, Object> objects = new HashMap<>(); objects.putAll(super.getStartUpRegistryObjects()); objects.put(COMPATIBILITY_PLUGIN_INSTALLED, new Object()); return objects; }
@Override protected void addBuilders(List<ConfigurationBuilder> builders) { super.addBuilders(builders); builders.add(0, new AbstractConfigurationBuilder() { @Override protected void doConfigure(MuleContext muleContext) throws Exception { registryHelper = (MuleRegistryHelper) ((MuleContextWithRegistry) muleContext).getRegistry(); registryHelper = spy(registryHelper); ((DefaultMuleContext) muleContext).setRegistry(registryHelper); } }); }
@Before public final void setUpMuleContext() throws Exception { if (!logConfigured) { configureLoggingForTest(getClass()); logConfigured = true; } workingDirectory.create(); String workingDirectoryOldValue = System.setProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY, workingDirectory.getRoot().getAbsolutePath()); try { doSetUpBeforeMuleContextCreation(); muleContext = createMuleContext(); if (doTestClassInjection()) { muleContext.getInjector().inject(this); } if (isStartContext() && muleContext != null && !muleContext.isStarted()) { startMuleContext(); } doSetUp(); } finally { if (workingDirectoryOldValue != null) { System.setProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY, workingDirectoryOldValue); } else { System.clearProperty(WORKING_DIRECTORY_SYSTEM_PROPERTY_KEY); } } }
@Override protected void doTearDown() throws Exception { scheduler.stop(); super.doTearDown(); }
@Override protected Map<String, Object> getStartUpRegistryObjects() { final Map<String, Object> objects = new HashMap<>(); objects.putAll(super.getStartUpRegistryObjects()); objects.put(COMPATIBILITY_PLUGIN_INSTALLED, new Object()); return objects; }
@Override protected void addBuilders(List<ConfigurationBuilder> builders) { builders.add(0, createBootstrapServiceDiscovererContextBuilder()); super.addBuilders(builders); }
protected MuleContext createMuleContext() throws Exception { if (isDisposeContextPerClass() && muleContext != null) { context = muleContext; } else { final ClassLoader executionClassLoader = getExecutionClassLoader(); final ClassLoader originalContextClassLoader = currentThread().getContextClassLoader(); try { builders.add(new SimpleConfigurationBuilder(getStartUpRegistryObjects())); addBuilders(builders); builders.add(getBuilder()); MuleContextBuilder contextBuilder = MuleContextBuilder.builder(APP); DefaultMuleConfiguration muleConfiguration = new DefaultMuleConfiguration(); contextBuilder.setMuleConfiguration(muleConfiguration); contextBuilder.setExecutionClassLoader(executionClassLoader); contextBuilder.setObjectSerializer(getObjectSerializer()); contextBuilder.setDeploymentProperties(getDeploymentProperties()); configureMuleContext(contextBuilder); context = muleContextFactory.createMuleContext(builders, contextBuilder); recordSchedulersOnInit(context); if (!isGracefulShutdown()) {
@Override protected void doSetUp() throws Exception { super.doSetUp(); el = muleContext.getExpressionManager(); }
@After public final void disposeContextPerTest() throws Exception { try { doTearDown(); } finally { if (!isDisposeContextPerClass()) { if (isStartContext() && muleContext != null && muleContext.isStarted()) { muleContext.stop(); } disposeContext(); if (testServicesConfigurationBuilder != null) { testServicesConfigurationBuilder.stopServices(); } doTearDownAfterMuleContextDispose(); } // When an Assumption fails then junit doesn't call @Before methods so we need to avoid // executing delete if there's no root folder. workingDirectory.delete(); } }
@Override protected void doTearDown() throws Exception { super.doTearDown(); managerStopped.set(true); managerStoppedEvents.set(0); }
@Override protected Map<String, Object> getStartUpRegistryObjects() { Map<String, Object> objects = new HashMap<>(); objects.putAll(super.getStartUpRegistryObjects()); objects.put(COMPATIBILITY_PLUGIN_INSTALLED, new Object()); return objects; }
@Override protected void addBuilders(List<ConfigurationBuilder> builders) { super.addBuilders(builders); builders.add(0, new AbstractConfigurationBuilder() { @Override protected void doConfigure(MuleContext muleContext) throws Exception { registryHelper = (MuleRegistryHelper) ((MuleContextWithRegistries) muleContext).getRegistry(); registryHelper = spy(registryHelper); ((DefaultMuleContext) muleContext).setMuleRegistry(registryHelper); } }); }
@Override protected void doSetUp() throws Exception { super.doSetUp(); directInboundMessageSource = new DirectInboundMessageSource(); }
@After public void doTeardown() throws Exception { untilSuccessful.dispose(); super.doTearDown(); }
@Override protected Map<String, Object> getStartUpRegistryObjects() { Map<String, Object> objects = new HashMap<>(); objects.putAll(super.getStartUpRegistryObjects()); objects.put(COMPATIBILITY_PLUGIN_INSTALLED, new Object()); return objects; }