use of org.apache.rocketmq.logappender.common.ProducerInstance in project rocketmq-externals by apache.
the class AbstractTestCase method mockLoggerAppender.
@Before
public void mockLoggerAppender() throws Exception {
DefaultMQProducer defaultMQProducer = spy(new DefaultMQProducer("loggerAppender"));
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
Message message = (Message) invocationOnMock.getArgument(0);
messages.add(message);
return null;
}
}).when(defaultMQProducer).sendOneway(any(Message.class));
ProducerInstance spy = mock(ProducerInstance.class);
Field instance = ProducerInstance.class.getDeclaredField("instance");
instance.setAccessible(true);
instance.set(ProducerInstance.class, spy);
doReturn(defaultMQProducer).when(spy).getInstance(anyString(), anyString());
}
use of org.apache.rocketmq.logappender.common.ProducerInstance in project rocketmq by apache.
the class AbstractTestCase method mockLoggerAppender.
@Before
public void mockLoggerAppender() throws Exception {
DefaultMQProducer defaultMQProducer = spy(new DefaultMQProducer("loggerAppender"));
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
Message message = (Message) invocationOnMock.getArgument(0);
messages.add(message);
return null;
}
}).when(defaultMQProducer).sendOneway(any(Message.class));
ProducerInstance spy = mock(ProducerInstance.class);
Field instance = ProducerInstance.class.getDeclaredField("instance");
instance.setAccessible(true);
instance.set(ProducerInstance.class, spy);
doReturn(defaultMQProducer).when(spy).getInstance(anyString(), anyString());
}
Aggregations