Package org.virtualbox_4_0

Examples of org.virtualbox_4_0.IMachine


   @Test
   public void testConvert() throws Exception {

      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IMachine vm = createNiceMock(IMachine.class);
      IGuestOSType guestOsType = createNiceMock(IGuestOSType.class);
      String linuxDescription = "Ubuntu 10.04";
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();

      expect(vm.getOSTypeId()).andReturn("os-type").anyTimes();
      expect(vm.getName()).andReturn(VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX + "my-vm-id").anyTimes();
      expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType);
      expect(vm.getDescription()).andReturn("my-ubuntu-machine").anyTimes();
      expect(guestOsType.getDescription()).andReturn(linuxDescription).anyTimes();
      expect(guestOsType.getIs64Bit()).andReturn(true);
      expect(vm.getState()).andReturn(MachineState.PoweredOff);

      replay(vbm, vBox, vm, guestOsType);

      IMachineToImage fn = new IMachineToImage(VirtualBoxComputeServiceContextModule.toPortableImageStatus, Suppliers
               .ofInstance(vbm), map);
View Full Code Here


   @Test
   public void testConvert1() throws Exception {

      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IMachine vm = createNiceMock(IMachine.class);
      IGuestOSType guestOsType = createNiceMock(IGuestOSType.class);
      String guestOsDescription = "ubuntu 11.04 server (i386)";
      String vmDescription = "ubuntu-11.04-server-i386";
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();

      expect(vm.getName()).andReturn(VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX + "my-vm-id").anyTimes();
      expect(vm.getOSTypeId()).andReturn("os-type").anyTimes();
      expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType);
      expect(vm.getDescription()).andReturn(vmDescription).anyTimes();
      expect(guestOsType.getDescription()).andReturn(guestOsDescription).anyTimes();
      expect(guestOsType.getIs64Bit()).andReturn(true);
      expect(vm.getState()).andReturn(MachineState.Running);

      replay(vbm, vBox, vm, guestOsType);

      IMachineToImage fn = new IMachineToImage(VirtualBoxComputeServiceContextModule.toPortableImageStatus, Suppliers
               .ofInstance(vbm), map);
View Full Code Here

   @Test
   public void testUnparseableOsString() throws Exception {

      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IMachine vm = createNiceMock(IMachine.class);
      IGuestOSType guestOsType = createNiceMock(IGuestOSType.class);

      expect(vbm.getVBox()).andReturn(vBox).anyTimes();

      expect(vm.getName()).andReturn(VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX + "my-vm-id").anyTimes();
      String unknownOsDescription = "SomeOtherOs 2.04";
      expect(vm.getOSTypeId()).andReturn("os-type").anyTimes();
      expect(vm.getDescription()).andReturn("my-unknown-machine").anyTimes();
      expect(guestOsType.getDescription()).andReturn(unknownOsDescription).anyTimes();
      expect(guestOsType.getIs64Bit()).andReturn(true);
      expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType);
      expect(vm.getState()).andReturn(MachineState.PoweredOff);

      replay(vbm, vBox, vm, guestOsType);

      IMachineToImage fn = new IMachineToImage(VirtualBoxComputeServiceContextModule.toPortableImageStatus, Suppliers
               .ofInstance(vbm), map);
View Full Code Here

   }

   @Test
   public void testGuestAdditionsAreInstalled() throws Exception {
      try {
         IMachine machine = cloneFromMaster();
         machineController.ensureMachineIsLaunched(machine.getName());

         sshClientForIMachine = injector.getInstance(IMachineToSshClient.class);
         SshClient client = sshClientForIMachine.apply(machine);

         sshResponds = injector.getInstance(SshResponds.class);
         checkState(sshResponds.apply(client), "timed out waiting for guest %s to be accessible via ssh",
                  machine.getName());

         String version = machine.getGuestPropertyValue("/VirtualBox/GuestAdd/Version");
        
         assertTrue(version != null && !version.isEmpty());
      } finally {
         for (VmSpec spec : ImmutableSet.of(machineSpec.getVmSpec())) {
            machineController.ensureMachineIsShutdown(spec.getVmName());
View Full Code Here

         }
      }
   }

   private IMachine cloneFromMaster() {
      IMachine source = getVmWithGuestAdditionsInstalled();
      CloneSpec cloneSpec = CloneSpec.builder().vm(machineSpec.getVmSpec()).network(machineSpec.getNetworkSpec())
               .master(source).linked(true).build();
      return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
               .apply(cloneSpec);
   }
View Full Code Here

   @Test
   public void testConvert() throws Exception {
      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IMachine vm = createNiceMock(IMachine.class);
      IGuestOSType guestOsType = createNiceMock(IGuestOSType.class);

      String linuxDescription = "Ubuntu Linux 10.04";
      String machineName = "hw-machineId";

      expect(vm.getOSTypeId()).andReturn("os-type").anyTimes();
      expect(vm.getName()).andReturn(machineName).anyTimes();

      expect(vm.getDescription()).andReturn(linuxDescription).anyTimes();

      expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType);
      expect(vbm.getVBox()).andReturn(vBox);
      expect(guestOsType.getIs64Bit()).andReturn(true);
View Full Code Here

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

  }

  @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

  }

  @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

            .getInstance(Json.class));

   @Test(enabled = false)
   public void testCreateFromMaster() throws Exception {

      IMachine vm = createNiceMock(IMachine.class);
      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IGuestOSType iGuestOSType = createNiceMock(IGuestOSType.class);
      INetworkAdapter nat = createNiceMock(INetworkAdapter.class);
      INATEngine natEng = createNiceMock(INATEngine.class);

      expect(vm.getName()).andReturn(VIRTUALBOX_IMAGE_PREFIX + MASTER_NAME).anyTimes();
      expect(vm.getState()).andReturn(MachineState.PoweredOff).anyTimes();
      expect(vm.getNetworkAdapter(eq(0l))).andReturn(nat).once();
      expect(vm.getNetworkAdapter(eq(1l))).andReturn(null).once();
      expect(nat.getAttachmentType()).andReturn(NetworkAttachmentType.NAT).once();
      expect(nat.getNATEngine()).andReturn(natEng).anyTimes();
      expect(natEng.getHostIP()).andReturn("127.0.0.1").once();
      expect(natEng.getRedirects()).andReturn(ImmutableList.of("0,1,127.0.0.1,2222,,22"));
     
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();
      expect(vm.getOSTypeId()).andReturn("RedHat_64").anyTimes();
      expect(vBox.getGuestOSType(vm.getOSTypeId())).andReturn(iGuestOSType);
     
      INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class);
      NetworkUtils networkUtils = createNiceMock(NetworkUtils.class);

      replay(vm, vBox, iGuestOSType, nat, natEng, hostOnly, networkUtils);
View Full Code Here

TOP

Related Classes of org.virtualbox_4_0.IMachine

Copyright © 2018 www.massapicom. 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.