Package org.virtualbox_4_0

Examples of org.virtualbox_4_0.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


      }

      String simplifiedMacAddressOfClonedVM = macAddress;

      final String hostId = System.getProperty(VirtualBoxConstants.VIRTUALBOX_HOST_ID);
      IMachine hostMachine = manager.getVBox().findMachine(hostId);
      if (isOSX(hostMachine)) {
         if (simplifiedMacAddressOfClonedVM.contains("00"))
            simplifiedMacAddressOfClonedVM = new StringBuilder(simplifiedMacAddressOfClonedVM).delete(
                  simplifiedMacAddressOfClonedVM.indexOf("00"), simplifiedMacAddressOfClonedVM.indexOf("00") + 1)
                  .toString();
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

   }

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

      IMachine vm = createNiceMock(IMachine.class);
      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();
      String group = "my-cluster-group";
      String name = "a-name-with-a-code-338";

      expect(vm.getName()).andReturn(
               VIRTUALBOX_NODE_PREFIX + MASTER_NAME + VIRTUALBOX_NODE_NAME_SEPARATOR + group
                        + VIRTUALBOX_NODE_NAME_SEPARATOR + name).anyTimes();
      expect(vm.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      INetworkAdapter nat = createNiceMock(INetworkAdapter.class);
      INATEngine natEng = createNiceMock(INATEngine.class);
     
      INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class);



      expect(vm.getNetworkAdapter(eq(0l))).andReturn(nat).once();
      expect(vm.getNetworkAdapter(eq(1l))).andReturn(hostOnly).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,3000,,22"));
      NetworkUtils networkUtils = createNiceMock(NetworkUtils.class);
View Full Code Here

      String flags = "";
      List<String> groups = Lists.newArrayList();
      String group = "";
      String settingsFile = manager.get().getVBox().composeMachineFilename(vmSpec.getVmName(), group , flags , workingDir);

      IMachine newMachine = vBox.createMachine(settingsFile, vmSpec.getVmName(), groups, vmSpec.getOsTypeId(), flags);
     
      manager.get().getVBox().registerMachine(newMachine);
      ensureConfiguration(masterSpec);
      return newMachine;
   }
View Full Code Here

         throw new RuntimeException("error reading default-keystroke-sequence file");
      }
   }

   protected void undoVm(String vmNameOrId) {
      IMachine vm = null;
      try {
         vm = manager.get().getVBox().findMachine(vmNameOrId);
         VmSpec vmSpec = new IMachineToVmSpec().apply(vm);
         int attempts = 0;
         while (attempts < 10 && !vm.getSessionState().equals(SessionState.Unlocked)) {
            attempts++;
            Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
         }
         machineUtils.applyForMachine(vmNameOrId, new UnregisterMachineIfExistsAndDeleteItsMedia(vmSpec));
View Full Code Here

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IGuestOSType osType = createNiceMock(IGuestOSType.class);

      List<IMachine> machines = Lists.newArrayList();
      IMachine imageMachine = createNiceMock(IMachine.class);
      IMachine clonedMachine = createNiceMock(IMachine.class);
      machines.add(imageMachine);
      machines.add(clonedMachine);

      expect(clonedMachine.getName()).andReturn("My Linux Node");
      expect(clonedMachine.getDescription()).andReturn("My Linux Node");
      expect(imageMachine.getName()).andReturn(VIRTUALBOX_IMAGE_PREFIX + "ubuntu-10.04");
      expect(imageMachine.getDescription()).andReturn(VIRTUALBOX_IMAGE_PREFIX + "ubuntu-10.04");

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.getMachines()).andReturn(machines).anyTimes();
View Full Code Here

   }
  
   @Test
   public void testCloneMachineFromAnotherMachine() {
      IMachine source = getVmWithGuestAdditionsInstalled();
      CloneSpec cloneSpec = CloneSpec.builder().vm(machineSpec.getVmSpec()).network(machineSpec.getNetworkSpec())
               .master(source).linked(true).build();
      IMachine clone = new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
               .apply(cloneSpec);
      assertTrue(isLinkedClone().apply(clone));
   }
View Full Code Here

public class ApplyBootOrderToMachineTest {

   @Test
   public void testSetBootOrderSuccessful() throws Exception {
      Map<Long, DeviceType> positionAndDeviceType = ImmutableMap.of(1l, DeviceType.HardDisk);
      IMachine machine = createMock(IMachine.class);
      for (long position : positionAndDeviceType.keySet()) {
         machine.setBootOrder(position, positionAndDeviceType.get(position));
      }
      machine.saveSettings();
      replay(machine);
      new ApplyBootOrderToMachine(positionAndDeviceType).apply(machine);
      verify(machine);
   }
View Full Code Here

      SessionState state = cloneMachineSession.getState();
      assertEquals(SessionState.Unlocked, state);
   }

   private IMachine cloneFromMaster() {
      IMachine source = getVmWithGuestAdditionsInstalled();
      CloneSpec cloneSpec = CloneSpec.builder().vm(masterSpec.getVmSpec()).network(masterSpec.getNetworkSpec())
            .master(source).linked(true).build();
      return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
            .apply(cloneSpec);
   }
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.