Examples of IMachine


Examples of org.virtualbox_4_2.IMachine

public class AttachNATAdapterToMachineIfNotAlreadyExistsTest {

  @Test
  public void testApplyNetworkingToNonExistingAdapter() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);
    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    iNetworkAdapter.setEnabled(true);
    machine.saveSettings();

    replay(machine, iNetworkAdapter, natEngine);
    NetworkAdapter networkAdapter = NetworkAdapter.builder()
        .networkAttachmentType(NetworkAttachmentType.NAT)
        .tcpRedirectRule("127.0.0.1", 2222, "", 22).build();
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

  }

  @Test
  public void testApplySkipsWhenAlreadyExists() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);

    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    expectLastCall()
        .andThrow(
            new VBoxException(null,
                "VirtualBox error: A NAT rule of this name already exists (0x80070057)"));

    iNetworkAdapter.setEnabled(true);
    machine.saveSettings();

    replay(machine, iNetworkAdapter, natEngine);
    NetworkAdapter networkAdapter = NetworkAdapter.builder()
        .networkAttachmentType(NetworkAttachmentType.NAT)
        .tcpRedirectRule("127.0.0.1", 2222, "", 22).build();
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

  }

  @Test(enabled=false, expectedExceptions = VBoxException.class)
  public void testRethrowInvalidAdapterSlotException() throws Exception {
    Long slotId = 30l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    String error = "VirtualBox error: Argument slot is invalid "
        + "(must be slot < RT_ELEMENTS(mNetworkAdapters)) (0x80070057)";

    VBoxException invalidSlotException = new VBoxException(
        createNiceMock(Throwable.class), error);
    expect(machine.getNetworkAdapter(slotId))
        .andThrow(invalidSlotException);

    replay(machine, iNetworkAdapter, natEngine);
    NetworkAdapter networkAdapter = NetworkAdapter.builder()
        .networkAttachmentType(NetworkAttachmentType.NAT)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.