From 8aaf5ba3a0efa9c6c55113b2cac6a610ce3c47c8 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Wed, 19 Dec 2012 16:01:58 -0800 Subject: [PATCH] fix unit test --- .../image/motion/ImageMotionServiceImpl.java | 16 +++------------- .../cloudstack/storage/image/TemplateInfo.java | 2 -- .../apache/cloudstack/storage/to/TemplateTO.java | 4 ++-- .../apache/cloudstack/storage/to/VolumeTO.java | 6 +++++- .../storage/volume/VolumeEntityImpl.java | 5 +++++ .../framework/async/AsyncCallbackDispatcher.java | 2 +- .../driver/SolidfirePrimaryDataStoreDriver.java | 15 ++++++++------- .../cloudstack/storage/test/VolumeTest.java | 2 +- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java index 45929e44f0c..feb98803dbc 100644 --- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java +++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java @@ -22,8 +22,6 @@ import java.util.List; import javax.inject.Inject; -import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; -import org.apache.cloudstack.framework.async.AsyncCallbackHandler; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.EndPoint; import org.apache.cloudstack.storage.command.CommandResult; @@ -91,16 +89,8 @@ public class ImageMotionServiceImpl implements ImageMotionService { TemplateInfo template = templateStore.getTemplate(); imageService.grantTemplateAccess(template, ep); - AsyncCallbackDispatcher caller = new AsyncCallbackDispatcher(this) - .setParentCallback(callback) - .setOperationName("imagemotionService.copytemplate.callback"); - - ims.copyTemplateAsync(templateStore, ep, caller); - } - - @AsyncCallbackHandler(operationName="imagemotionService.copytemplate.callback") - public void copyTemplateAsyncCallback( AsyncCallbackDispatcher callback) { - AsyncCallbackDispatcher parentCaller = callback.getParentCallback(); - parentCaller.complete(callback.getResult()); + ims.copyTemplateAsync(templateStore, ep, callback); } + + } diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java index 71e6e3acc3a..0e11f3eb358 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java @@ -31,6 +31,4 @@ public interface TemplateInfo { String getPath(); String getUuid(); - - long getVirtualSize(); } diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java index 704f36ea169..8d73fcc10b3 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java +++ b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java @@ -8,13 +8,13 @@ public class TemplateTO { private final String uuid; private final VolumeDiskType diskType; private final ImageDataStoreTO imageDataStore; - private final long size; + private final long size = 0; public TemplateTO(TemplateInfo template) { this.path = template.getPath(); this.uuid = template.getUuid(); this.diskType = template.getDiskType(); this.imageDataStore = new ImageDataStoreTO(template.getImageDataStore()); - this.size = template.getVirtualSize(); + // this.size = template.getVirtualSize(); } public String getPath() { diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java index d507eb47a91..ed7f2be7b9a 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java +++ b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java @@ -15,7 +15,11 @@ public class VolumeTO { this.path = volume.getPath(); this.volumeType = volume.getType(); this.diskType = volume.getDiskType(); - this.dataStore = new PrimaryDataStoreTO(volume.getDataStore()); + if (volume.getDataStore() != null) { + this.dataStore = new PrimaryDataStoreTO(volume.getDataStore()); + } else { + this.dataStore = null; + } } public String getUuid() { diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java index 546c339b82b..8883e8e61bb 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java @@ -41,6 +41,11 @@ import com.cloud.utils.exception.CloudRuntimeException; public class VolumeEntityImpl implements VolumeEntity { private VolumeInfo volumeInfo; private final VolumeService vs; + + protected VolumeEntityImpl() { + this.vs = null; + } + public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) { this.volumeInfo = volumeObject; this.vs = vs; diff --git a/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallbackDispatcher.java b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallbackDispatcher.java index 125d9466739..f3cb60c95ee 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallbackDispatcher.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallbackDispatcher.java @@ -106,7 +106,7 @@ public class AsyncCallbackDispatcher implements AsyncCompletionCallback { } catch (IllegalAccessException e) { throw new RuntimeException("IllegalAccessException when invoking RPC callback for command: " + callback.getCallbackMethod().getName()); } catch (InvocationTargetException e) { - throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName()); + throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName(), e); } return true; diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java index 915e671e53c..d2d229b4870 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java @@ -2,7 +2,9 @@ package org.apache.cloudstack.storage.datastore.driver; import java.util.Map; +import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.EndPoint; +import org.apache.cloudstack.storage.command.CommandResult; import org.apache.cloudstack.storage.datastore.PrimaryDataStore; import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo; import org.apache.cloudstack.storage.volume.VolumeObject; @@ -15,13 +17,6 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { return false; } - @Override - public boolean createVolumeFromBaseImage(VolumeObject volume, - TemplateOnPrimaryDataStoreInfo template) { - // TODO Auto-generated method stub - return false; - } - @Override public boolean deleteVolume(VolumeObject vo) { // TODO Auto-generated method stub @@ -76,4 +71,10 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { } + @Override + public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template, AsyncCompletionCallback callback) { + // TODO Auto-generated method stub + + } + } diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java index eb0550a4faf..50a43141f15 100644 --- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java +++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java @@ -100,7 +100,7 @@ public class VolumeTest { results.add(host); Mockito.when(hostDao.listAll()).thenReturn(results); Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results); - CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(UUID.randomUUID().toString()); + CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(null,UUID.randomUUID().toString()); try { Mockito.when(agentMgr.send(Mockito.anyLong(), Mockito.any(CreateVolumeFromBaseImageCommand.class))).thenReturn(createVolumeFromImageAnswer);