forked from apache/rocketmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MASTER [ROCKETMQ-3] Clean up and perfect the unit test of rocketmq-br…
…oker closes apache#7
- Loading branch information
1 parent
07b3cd1
commit 774101d
Showing
6 changed files
with
199 additions
and
105 deletions.
There are no files selected for viewing
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
74 changes: 74 additions & 0 deletions
74
rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerTestHarness.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,74 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $ | ||
*/ | ||
package com.alibaba.rocketmq.broker; | ||
|
||
import com.alibaba.rocketmq.common.BrokerConfig; | ||
import com.alibaba.rocketmq.remoting.netty.NettyClientConfig; | ||
import com.alibaba.rocketmq.remoting.netty.NettyServerConfig; | ||
import com.alibaba.rocketmq.store.config.MessageStoreConfig; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.util.Random; | ||
|
||
/** | ||
* @author zander | ||
*/ | ||
public class BrokerTestHarness { | ||
|
||
protected BrokerController brokerController = null; | ||
|
||
protected Random random = new Random(); | ||
public final String BROKER_NAME = "TestBrokerName"; | ||
protected String brokerAddr = ""; | ||
protected Logger logger = LoggerFactory.getLogger(BrokerTestHarness.class); | ||
protected BrokerConfig brokerConfig = new BrokerConfig(); | ||
protected NettyServerConfig nettyServerConfig = new NettyServerConfig(); | ||
protected NettyClientConfig nettyClientConfig = new NettyClientConfig(); | ||
protected MessageStoreConfig storeConfig = new MessageStoreConfig(); | ||
|
||
@Before | ||
public void startup() throws Exception { | ||
brokerConfig.setBrokerName(BROKER_NAME); | ||
brokerConfig.setBrokerIP1("127.0.0.1"); | ||
storeConfig.setStorePathRootDir(System.getProperty("user.home") + File.separator + "unitteststore"); | ||
storeConfig.setStorePathCommitLog(System.getProperty("user.home") + File.separator + "unitteststore" + File.separator + "commitlog"); | ||
nettyServerConfig.setListenPort(10000 + random.nextInt(1000)); | ||
brokerAddr = brokerConfig.getBrokerIP1() + ":" + nettyServerConfig.getListenPort(); | ||
brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig); | ||
boolean initResult = brokerController.initialize(); | ||
Assert.assertTrue(initResult); | ||
logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr()); | ||
brokerController.start(); | ||
} | ||
|
||
@After | ||
public void shutdown() throws Exception { | ||
if (brokerController != null) { | ||
brokerController.shutdown(); | ||
} | ||
//maybe need to clean the file store. But we do not suggest deleting anything. | ||
} | ||
} |
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
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
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
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<configuration> | ||
|
||
<appender name="DefaultAppender" class="ch.qos.logback.core.ConsoleAppender"> | ||
<append>true</append> | ||
<encoder> | ||
<pattern>%d{yyy-MM-dd HH\:mm\:ss,GMT+8} %p %t - %m%n</pattern> | ||
<charset class="java.nio.charset.Charset">UTF-8</charset> | ||
</encoder> | ||
</appender> | ||
|
||
<root> | ||
<level value="OFF"/> | ||
<appender-ref ref="DefaultAppender"/> | ||
</root> | ||
</configuration> |