Java 类com.vmware.vim25.mo.PropertyCollector 实例源码

项目:jcloud-vsphere    文件:VSphereLocationSupplierTest.java   
@Test
public void vSphereLocationSupplierTest() throws IOException {
   ServerConnection serverConnection = PowerMock.createMock(ServerConnection.class);
   WSClient wsClient = PowerMock.createMock(WSClient.class);
   ManagedObjectReference managedObjectReference = PowerMock.createMock(ManagedObjectReference.class);
   ServiceInstance serviceInstance = PowerMock.createMock(ServiceInstance.class);
   CreateAndConnectVSphereClient supplier = PowerMock.createMock(CreateAndConnectVSphereClient.class);
   VSphereServiceInstance vSphereServiceInstance = PowerMock.createMock(VSphereServiceInstance.class);
   Folder rootFolder = PowerMock.createMock(Folder.class);

   expect(supplier.get()).andReturn(vSphereServiceInstance);

   expect(vSphereServiceInstance.getInstance()).andReturn(serviceInstance);

   expect(serviceInstance.getRootFolder()).andReturn(rootFolder);

   expect(rootFolder.getServerConnection()).andReturn(serverConnection).anyTimes();
   expect(rootFolder.getMOR()).andReturn(managedObjectReference);
   expect(serverConnection.getServiceInstance()).andReturn(serviceInstance).anyTimes();
   expect(serverConnection.getVimService()).andReturn(new VimPortType(wsClient)).anyTimes();
   AboutInfo aboutInfo = new AboutInfo();
   aboutInfo.setApiVersion("5.1");
   expect(serviceInstance.getPropertyCollector()).andReturn(new PropertyCollector(serverConnection, managedObjectReference));
   expect(serviceInstance.getAboutInfo()).andReturn(aboutInfo);
   vSphereServiceInstance.close();
   replay(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);


   VSphereLocationSupplier vSphereLocationSupplier = new VSphereLocationSupplier(supplier);
   Set<? extends Location> location = vSphereLocationSupplier.get();

   Assert.assertEquals(1, location.size());
   for (Location l : location) {
      Assert.assertEquals("default", l.getId());
   }


   verify(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);
}
项目:vijava    文件:ManagedObjectWatcher.java   
public ManagedObjectWatcher(PropertyCollector pc)
{
    this.pc = pc;
}