提交 4d760164 编写于 作者: V vongosling

Polish parts slow UT

上级 788c757a
......@@ -17,6 +17,7 @@
package org.apache.rocketmq.broker;
import java.io.File;
import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.remoting.netty.NettyClientConfig;
......@@ -25,16 +26,10 @@ import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.After;
import org.junit.Test;
import java.io.File;
import static org.assertj.core.api.Assertions.assertThat;
public class BrokerControllerTest {
/**
* Tests if the controller can be properly stopped and started.
*
* @throws Exception If fails.
*/
@Test
public void testBrokerRestart() throws Exception {
BrokerController brokerController = new BrokerController(
......@@ -48,7 +43,7 @@ public class BrokerControllerTest {
}
@After
public void destory() {
public void destroy() {
UtilAll.deleteFile(new File(new MessageStoreConfig().getStorePathRootDir()));
}
}
......@@ -17,7 +17,6 @@
package org.apache.rocketmq.logappender;
import org.apache.log4j.Logger;
import org.apache.rocketmq.client.exception.MQClientException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
......@@ -30,7 +29,7 @@ public abstract class Log4jTest extends AbstractTestCase {
public abstract String getType();
@Test
public void testLog4j() throws InterruptedException, MQClientException {
public void testLog4j() {
clear();
Logger logger = Logger.getLogger("testLogger");
for (int i = 0; i < 10; i++) {
......
......@@ -20,15 +20,13 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;
import org.apache.rocketmq.client.exception.MQClientException;
import java.io.File;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class LogbackTest extends AbstractTestCase {
@Before
......@@ -42,7 +40,7 @@ public class LogbackTest extends AbstractTestCase {
}
@Test
public void testLogback() throws InterruptedException, MQClientException {
public void testLogback() {
clear();
Logger logger = LoggerFactory.getLogger("testLogger");
for (int i = 0; i < 10; i++) {
......
......@@ -35,7 +35,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class DefaultMessageStoreShuwDownTest {
public class DefaultMessageStoreShutdownTest {
private DefaultMessageStore messageStore;
@Before
......@@ -48,7 +48,7 @@ public class DefaultMessageStoreShuwDownTest {
}
@Test
public void testDispatchBehindWhenShutDown() {
public void testDispatchBehindWhenShutdown() {
messageStore.shutdown();
assertTrue(!messageStore.shutDownNormal);
File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
......@@ -56,7 +56,7 @@ public class DefaultMessageStoreShuwDownTest {
}
@After
public void destory() {
public void destroy() {
messageStore.destroy();
File file = new File(messageStore.getMessageStoreConfig().getStorePathRootDir());
UtilAll.deleteFile(file);
......
......@@ -59,7 +59,6 @@ public class DefaultMessageStoreTest {
@Test(expected = OverlappingFileLockException.class)
public void test_repate_restart() throws Exception {
long totalMsgs = 100;
QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes();
......@@ -92,7 +91,7 @@ public class DefaultMessageStoreTest {
UtilAll.deleteFile(file);
}
public MessageStore buildMessageStore() throws Exception {
private MessageStore buildMessageStore() throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
......@@ -103,8 +102,8 @@ public class DefaultMessageStoreTest {
}
@Test
public void testWriteAndRead() throws Exception {
long totalMsgs = 100;
public void testWriteAndRead() {
long totalMsgs = 10;
QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes();
for (long i = 0; i < totalMsgs; i++) {
......@@ -119,7 +118,7 @@ public class DefaultMessageStoreTest {
verifyThatMasterIsFunctional(totalMsgs, messageStore);
}
public MessageExtBrokerInner buildMessage() {
private MessageExtBrokerInner buildMessage() {
MessageExtBrokerInner msg = new MessageExtBrokerInner();
msg.setTopic("FooBar");
msg.setTags("TAG1");
......@@ -134,23 +133,6 @@ public class DefaultMessageStoreTest {
return msg;
}
@Test
public void testGroupCommit() throws Exception {
long totalMsgs = 10;
QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes();
for (long i = 0; i < totalMsgs; i++) {
messageStore.putMessage(buildMessage());
}
for (long i = 0; i < totalMsgs; i++) {
GetMessageResult result = messageStore.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null);
assertThat(result).isNotNull();
result.release();
}
verifyThatMasterIsFunctional(totalMsgs, messageStore);
}
private void verifyThatMasterIsFunctional(long totalMsgs, MessageStore master) {
for (long i = 0; i < totalMsgs; i++) {
master.putMessage(buildMessage());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册