Search in sources :

Example 21 with DefaultMQAdminExtImpl

use of org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class BrokerStatusSubCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    KVTable kvTable = new KVTable();
    kvTable.setTable(new HashMap<String, String>());
    when(mQClientAPIImpl.getBrokerRuntimeInfo(anyString(), anyLong())).thenReturn(kvTable);
}
Also used : Field(java.lang.reflect.Field) KVTable(org.apache.rocketmq.common.protocol.body.KVTable) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Example 22 with DefaultMQAdminExtImpl

use of org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class UpdateBrokerConfigSubCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
}
Also used : Field(java.lang.reflect.Field) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Example 23 with DefaultMQAdminExtImpl

use of org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class ConsumerProgressSubCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingException, MQClientException, MQBrokerException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    TopicRouteData topicRouteData = new TopicRouteData();
    List<BrokerData> brokerDatas = new ArrayList<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerName("default-broker");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerDatas.add(brokerData);
    topicRouteData.setBrokerDatas(brokerDatas);
    topicRouteData.setQueueDatas(new ArrayList<QueueData>());
    topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
    when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData);
    ConsumeStats consumeStats = new ConsumeStats();
    consumeStats.setConsumeTps(1234);
    MessageQueue messageQueue = new MessageQueue();
    OffsetWrapper offsetWrapper = new OffsetWrapper();
    HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>();
    stats.put(messageQueue, offsetWrapper);
    consumeStats.setOffsetTable(stats);
    when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats);
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) HashMap(java.util.HashMap) ConsumeStats(org.apache.rocketmq.common.admin.ConsumeStats) QueueData(org.apache.rocketmq.common.protocol.route.QueueData) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OffsetWrapper(org.apache.rocketmq.common.admin.OffsetWrapper) TopicRouteData(org.apache.rocketmq.common.protocol.route.TopicRouteData) Field(java.lang.reflect.Field) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArrayList(java.util.ArrayList) List(java.util.List) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Example 24 with DefaultMQAdminExtImpl

use of org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class GetNamesrvConfigCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    Map<String, Properties> propertiesMap = new HashMap<>();
    List<String> nameServers = new ArrayList<>();
    when(mQClientAPIImpl.getNameServerConfig(ArgumentMatchers.<String>anyList(), anyLong())).thenReturn(propertiesMap);
}
Also used : Field(java.lang.reflect.Field) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) Properties(java.util.Properties) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Example 25 with DefaultMQAdminExtImpl

use of org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class WipeWritePermSubCommandTest method init.

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException, RemotingCommandException {
    mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);
    field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
    field.setAccessible(true);
    field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
    List<String> result = new ArrayList<>();
    result.add("default-name-one");
    result.add("default-name-two");
    when(mqClientInstance.getMQClientAPIImpl().getNameServerAddressList()).thenReturn(result);
    when(mQClientAPIImpl.wipeWritePermOfBroker(anyString(), anyString(), anyLong())).thenReturn(6);
}
Also used : Field(java.lang.reflect.Field) MQClientAPIImpl(org.apache.rocketmq.client.impl.MQClientAPIImpl) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MQClientInstance(org.apache.rocketmq.client.impl.factory.MQClientInstance) DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) DefaultMQAdminExtImpl(org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

Field (java.lang.reflect.Field)36 MQClientAPIImpl (org.apache.rocketmq.client.impl.MQClientAPIImpl)36 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)36 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)36 DefaultMQAdminExtImpl (org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl)36 BeforeClass (org.junit.BeforeClass)32 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 HashMap (java.util.HashMap)16 ArrayList (java.util.ArrayList)14 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)12 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)12 HashSet (java.util.HashSet)10 TopicRouteData (org.apache.rocketmq.common.protocol.route.TopicRouteData)10 List (java.util.List)8 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)8 Connection (org.apache.rocketmq.common.protocol.body.Connection)8 QueueData (org.apache.rocketmq.common.protocol.route.QueueData)8 Properties (java.util.Properties)6 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)6 ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)6