TestVBox.java revision 2c76fd8cdec6f32663a03b16fb5871f7c54330a6
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync/* Small sample/testcase which demonstrates that the same source code can
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * be used to connect to the webservice and (XP)COM APIs. */
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * Copyright (C) 2010-2011 Oracle Corporation
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * available from http://www.virtualbox.org. This file is free software;
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * General Public License (GPL) as published by the Free Software
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync IMachineStateChangedEvent mcse = IMachineStateChangedEvent.queryInterface(ev);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync } catch (Throwable t) {
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync static void testEvents(VirtualBoxManager mgr, IEventSource es)
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync // active mode for Java doesn't fully work yet, and using passive
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync // is more portable (the only mode for MSCOM and WS) and thus generally
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync // recommended
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync es.registerListener(listener, Arrays.asList(VBoxEventType.Any), false);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync } catch (Exception e) {
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync static void testEnumeration(VirtualBoxManager mgr, IVirtualBox vbox)
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync boolean hwvirtEnabled = false, hwvirtNestedPaging = false;
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync boolean paeEnabled = false;
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync boolean inaccessible = false;
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync hwvirtEnabled = m.getHWVirtExProperty(HWVirtExPropertyType.Enabled);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync hwvirtNestedPaging = m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync paeEnabled = m.getCPUProperty(CPUPropertyType.PAE);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync static void testStart(VirtualBoxManager mgr, IVirtualBox vbox)
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync System.out.println("\nAttempting to start VM '" + m + "'");
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync VirtualBoxManager mgr1 = VirtualBoxManager.createInstance(null);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync VirtualBoxManager mgr2 = VirtualBoxManager.createInstance(null);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync String mach1 = mgr1.getVBox().getMachines().get(0).getName();
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync String mach2 = mgr2.getVBox().getMachines().get(0).getName();
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync } finally {
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync static void testReadLog(VirtualBoxManager mgr, IVirtualBox vbox)
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync while (true)
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync boolean ws = false;
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync System.out.println("Cannot connect, start webserver first!");
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync System.out.println("VirtualBox version: " + vbox.getVersion() + "\n");
c9579522f347fc3fda6b3f4add0b355981cd7758vboxsync System.out.println("VBox error: "+e.getMessage()+" original="+e.getWrapped());