use of com.cloud.common.virtualnetwork.VirtualRoutingResource in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testRebootRouterCommandConnect.
@Test
public void testRebootRouterCommandConnect() {
final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class);
final Connect conn = Mockito.mock(Connect.class);
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
final String vmName = "Test";
final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1");
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource);
when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
when(routingResource.connect(command.getPrivateIpAddress())).thenReturn(true);
try {
when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
try {
verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
}
Aggregations