-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
W-16789548: New chains for validation: all are not disposed generatin…
…g a memory leak (#14011) (#14036) * New chains for validation: all are not disposed generating a memory leak * add TC
- Loading branch information
1 parent
093645d
commit 0a175fe
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...g/mule/runtime/core/privileged/processor/chain/AbstractMessageProcessorChainTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2023 Salesforce, Inc. All rights reserved. | ||
* The software in this package is published under the terms of the CPAL v1.0 | ||
* license, a copy of which has been included with this distribution in the | ||
* LICENSE.txt file. | ||
*/ | ||
package org.mule.runtime.core.privileged.processor.chain; | ||
|
||
import static org.mule.runtime.core.api.lifecycle.LifecycleUtils.startIfNeeded; | ||
import static org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded; | ||
import static org.mule.runtime.core.privileged.processor.MessageProcessors.newChain; | ||
|
||
import static java.util.Optional.empty; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.sameInstance; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.MockitoAnnotations.openMocks; | ||
|
||
import org.mule.runtime.core.api.context.notification.MuleContextListener; | ||
import org.mule.runtime.core.internal.context.DefaultMuleContext; | ||
import org.mule.tck.junit4.AbstractMuleTestCase; | ||
import org.mule.tck.testmodels.mule.TestMessageProcessor; | ||
|
||
import org.junit.Test; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
|
||
|
||
public class AbstractMessageProcessorChainTestCase extends AbstractMuleTestCase { | ||
|
||
@InjectMocks | ||
MessageProcessorChain messageChain = newChain(empty(), new TestMessageProcessor("test")); | ||
|
||
@Mock | ||
DefaultMuleContext muleContext; | ||
|
||
public AbstractMessageProcessorChainTestCase() { | ||
openMocks(this); | ||
} | ||
|
||
@Test | ||
public void testRemoveChain() throws Exception { | ||
startIfNeeded(messageChain); | ||
stopIfNeeded(messageChain); | ||
|
||
ArgumentCaptor<MuleContextListener> addListenerCaptor = ArgumentCaptor.forClass(MuleContextListener.class); | ||
ArgumentCaptor<MuleContextListener> removeListenerCaptor = ArgumentCaptor.forClass(MuleContextListener.class); | ||
|
||
verify(muleContext, times(1)).addListener(addListenerCaptor.capture()); | ||
verify(muleContext, times(1)).removeListener(removeListenerCaptor.capture()); | ||
|
||
assertThat(addListenerCaptor.getValue(), is(sameInstance(removeListenerCaptor.getValue()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters