Search in sources :

Example 1 with ClusteringCommand

use of org.apache.axis2.clustering.ClusteringCommand in project carbon-apimgt by wso2.

the class TenantLoadMessageSenderTest method testSendTenantRegistryLoadMessage.

@Test
public void testSendTenantRegistryLoadMessage() throws ClusteringFault {
    ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
    ClusteringMessage request = new TenantLoadMessage(1, "a.com");
    ClusteringCommand command = PowerMockito.mock(ClusteringCommand.class);
    List<ClusteringCommand> commandList = new ArrayList<ClusteringCommand>();
    commandList.add(command);
    PowerMockito.when(clusteringAgent.sendMessage(request, true)).thenReturn(commandList);
    tenantLoadMessageSender.sendTenantLoadMessage(clusteringAgent, 1, "a.com", 1);
}
Also used : ClusteringCommand(org.apache.axis2.clustering.ClusteringCommand) ClusteringMessage(org.apache.axis2.clustering.ClusteringMessage) ArrayList(java.util.ArrayList) ClusteringAgent(org.apache.axis2.clustering.ClusteringAgent) TenantLoadMessage(org.wso2.carbon.apimgt.impl.message.clustering.TenantLoadMessage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ClusteringCommand

use of org.apache.axis2.clustering.ClusteringCommand in project carbon-apimgt by wso2.

the class TenantLoadMessageSenderTest method testSendTenantRegistryLoadMessageFail.

@Test(expected = ClusteringFault.class)
public void testSendTenantRegistryLoadMessageFail() throws ClusteringFault {
    ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
    ClusteringCommand command = PowerMockito.mock(ClusteringCommand.class);
    List<ClusteringCommand> commandList = new ArrayList<ClusteringCommand>();
    commandList.add(command);
    ClusteringFault clusteringFault = PowerMockito.mock(ClusteringFault.class);
    PowerMockito.when(clusteringAgent.sendMessage(Matchers.any(TenantLoadMessage.class), Matchers.anyBoolean())).thenThrow(clusteringFault);
    tenantLoadMessageSender.sendTenantLoadMessage(clusteringAgent, 1, "a.com", 2);
}
Also used : ClusteringCommand(org.apache.axis2.clustering.ClusteringCommand) ArrayList(java.util.ArrayList) ClusteringAgent(org.apache.axis2.clustering.ClusteringAgent) TenantLoadMessage(org.wso2.carbon.apimgt.impl.message.clustering.TenantLoadMessage) ClusteringFault(org.apache.axis2.clustering.ClusteringFault) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ArrayList (java.util.ArrayList)2 ClusteringAgent (org.apache.axis2.clustering.ClusteringAgent)2 ClusteringCommand (org.apache.axis2.clustering.ClusteringCommand)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 TenantLoadMessage (org.wso2.carbon.apimgt.impl.message.clustering.TenantLoadMessage)2 ClusteringFault (org.apache.axis2.clustering.ClusteringFault)1 ClusteringMessage (org.apache.axis2.clustering.ClusteringMessage)1