cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [02/55] [abbrv] Removing ^M's from code.
Date Mon, 08 Apr 2013 13:13:12 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/async/TestSyncQueueManager.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/async/TestSyncQueueManager.java b/server/test/com/cloud/async/TestSyncQueueManager.java
index 2322aec..59afb11 100644
--- a/server/test/com/cloud/async/TestSyncQueueManager.java
+++ b/server/test/com/cloud/async/TestSyncQueueManager.java
@@ -33,163 +33,163 @@ public class TestSyncQueueManager extends TestCase {
     private volatile long expectingCurrent = 1;
     @Inject SyncQueueManager mgr;
 
-    public void leftOverItems() {
-
-        List<SyncQueueItemVO> l = mgr.getActiveQueueItems(1L, false);
-        if(l != null && l.size() > 0) {
-            for(SyncQueueItemVO item : l) {
-                s_logger.info("Left over item: " + item.toString());
-                mgr.purgeItem(item.getId());
-            }
-        }
-    }
-
-    public void dequeueFromOneQueue() {
-        final int totalRuns = 5000;
-        final SyncQueueVO queue = mgr.queue("vm_instance", 1L, "Async-job", 1, 1);
-        for(int i = 1; i < totalRuns; i++)
-            mgr.queue("vm_instance", 1L, "Async-job", i+1, 1);
-
-        count = 0;
-        expectingCurrent = 1;
-        Thread thread1 = new Thread(new Runnable() {
+    public void leftOverItems() {
+
+        List<SyncQueueItemVO> l = mgr.getActiveQueueItems(1L, false);
+        if(l != null && l.size() > 0) {
+            for(SyncQueueItemVO item : l) {
+                s_logger.info("Left over item: " + item.toString());
+                mgr.purgeItem(item.getId());
+            }
+        }
+    }
+
+    public void dequeueFromOneQueue() {
+        final int totalRuns = 5000;
+        final SyncQueueVO queue = mgr.queue("vm_instance", 1L, "Async-job", 1, 1);
+        for(int i = 1; i < totalRuns; i++)
+            mgr.queue("vm_instance", 1L, "Async-job", i+1, 1);
+
+        count = 0;
+        expectingCurrent = 1;
+        Thread thread1 = new Thread(new Runnable() {
             @Override
-            public void run() {
-                while(count < totalRuns) {
-                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 1L);
-                    if(item != null) {
-                        s_logger.info("Thread 1 process item: " + item.toString());
-
-                        Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
-                        expectingCurrent++;
-                        count++;
-
-                        mgr.purgeItem(item.getId());
-                    }
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-        }
-                );
-
-        Thread thread2 = new Thread(new Runnable() {
+            public void run() {
+                while(count < totalRuns) {
+                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 1L);
+                    if(item != null) {
+                        s_logger.info("Thread 1 process item: " + item.toString());
+
+                        Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
+                        expectingCurrent++;
+                        count++;
+
+                        mgr.purgeItem(item.getId());
+                    }
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        Thread thread2 = new Thread(new Runnable() {
             @Override
-            public void run() {
-                while(count < totalRuns) {
-                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 1L);
-                    if(item != null) {
-                        s_logger.info("Thread 2 process item: " + item.toString());
-
-                        Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
-                        expectingCurrent++;
-                        count++;
-                        mgr.purgeItem(item.getId());
-                    }
-
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-        }
-                ); 
-
-        thread1.start();
-        thread2.start();
-        try {
-            thread1.join();
-        } catch (InterruptedException e) {
-        }
-        try {
-            thread2.join();
-        } catch (InterruptedException e) {
-        }
-
-        Assert.assertEquals(totalRuns, count);
-    }
-
-    public void dequeueFromAnyQueue() {
-        // simulate 30 queues
-        final int queues = 30;
-        final int totalRuns = 100;
-        final int itemsPerRun = 20;
-        for(int q = 1; q <= queues; q++)
-            for(int i = 0; i < totalRuns; i++)
-                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
-
-        count = 0;
-        Thread thread1 = new Thread(new Runnable() {
+            public void run() {
+                while(count < totalRuns) {
+                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 1L);
+                    if(item != null) {
+                        s_logger.info("Thread 2 process item: " + item.toString());
+
+                        Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
+                        expectingCurrent++;
+                        count++;
+                        mgr.purgeItem(item.getId());
+                    }
+
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        thread1.start();
+        thread2.start();
+        try {
+            thread1.join();
+        } catch (InterruptedException e) {
+        }
+        try {
+            thread2.join();
+        } catch (InterruptedException e) {
+        }
+
+        Assert.assertEquals(totalRuns, count);
+    }
+
+    public void dequeueFromAnyQueue() {
+        // simulate 30 queues
+        final int queues = 30;
+        final int totalRuns = 100;
+        final int itemsPerRun = 20;
+        for(int q = 1; q <= queues; q++)
+            for(int i = 0; i < totalRuns; i++)
+                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
+
+        count = 0;
+        Thread thread1 = new Thread(new Runnable() {
             @Override
-            public void run() {
-                while(count < totalRuns*queues) {
-                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, itemsPerRun);
-                    if(l != null && l.size() > 0) {
-                        s_logger.info("Thread 1 get " + l.size() + " dequeued items");
-
-                        for(SyncQueueItemVO item : l) {
-                            s_logger.info("Thread 1 process item: " + item.toString());
-                            count++;
-
-                            mgr.purgeItem(item.getId());
-                        }
-                    }
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-        }
-                );
-
-        Thread thread2 = new Thread(new Runnable() {
+            public void run() {
+                while(count < totalRuns*queues) {
+                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, itemsPerRun);
+                    if(l != null && l.size() > 0) {
+                        s_logger.info("Thread 1 get " + l.size() + " dequeued items");
+
+                        for(SyncQueueItemVO item : l) {
+                            s_logger.info("Thread 1 process item: " + item.toString());
+                            count++;
+
+                            mgr.purgeItem(item.getId());
+                        }
+                    }
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        Thread thread2 = new Thread(new Runnable() {
             @Override
-            public void run() {
-                while(count < totalRuns*queues) {
-                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, itemsPerRun);
-                    if(l != null && l.size() > 0) {
-                        s_logger.info("Thread 2 get " + l.size() + " dequeued items");
-
-                        for(SyncQueueItemVO item : l) {
-                            s_logger.info("Thread 2 process item: " + item.toString());
-                            count++;
-                            mgr.purgeItem(item.getId());
-                        }
-                    }
-
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-        }
-                ); 
-
-        thread1.start();
-        thread2.start();
-        try {
-            thread1.join();
-        } catch (InterruptedException e) {
-        }
-        try {
-            thread2.join();
-        } catch (InterruptedException e) {
-        }
-        Assert.assertEquals(queues*totalRuns, count);
-    }
-
-    public void testPopulateQueueData() {
-        final int queues = 30000;
-        final int totalRuns = 100;
-
-        for(int q = 1; q <= queues; q++)
-            for(int i = 0; i < totalRuns; i++)
-                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
+            public void run() {
+                while(count < totalRuns*queues) {
+                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, itemsPerRun);
+                    if(l != null && l.size() > 0) {
+                        s_logger.info("Thread 2 get " + l.size() + " dequeued items");
+
+                        for(SyncQueueItemVO item : l) {
+                            s_logger.info("Thread 2 process item: " + item.toString());
+                            count++;
+                            mgr.purgeItem(item.getId());
+                        }
+                    }
+
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        thread1.start();
+        thread2.start();
+        try {
+            thread1.join();
+        } catch (InterruptedException e) {
+        }
+        try {
+            thread2.join();
+        } catch (InterruptedException e) {
+        }
+        Assert.assertEquals(queues*totalRuns, count);
+    }
+
+    public void testPopulateQueueData() {
+        final int queues = 30000;
+        final int totalRuns = 100;
+
+        for(int q = 1; q <= queues; q++)
+            for(int i = 0; i < totalRuns; i++)
+                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
     }
 
     public void testSyncQueue() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/network/security/SecurityGroupManagerTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/security/SecurityGroupManagerTestConfiguration.java b/server/test/com/cloud/network/security/SecurityGroupManagerTestConfiguration.java
index 5969948..b3a9ff1 100644
--- a/server/test/com/cloud/network/security/SecurityGroupManagerTestConfiguration.java
+++ b/server/test/com/cloud/network/security/SecurityGroupManagerTestConfiguration.java
@@ -1,158 +1,158 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.network.security;
-
-import java.io.IOException;
-
-import org.mockito.Mockito;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.ComponentScan.Filter;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.core.type.filter.TypeFilter;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
-import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
-import com.cloud.configuration.dao.ConfigurationDaoImpl;
-import com.cloud.dc.dao.ClusterDaoImpl;
-import com.cloud.dc.dao.DataCenterDaoImpl;
-import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
-import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
-import com.cloud.dc.dao.DataCenterVnetDaoImpl;
-import com.cloud.dc.dao.DcDetailsDaoImpl;
-import com.cloud.dc.dao.HostPodDaoImpl;
-import com.cloud.dc.dao.PodVlanDaoImpl;
-import com.cloud.domain.dao.DomainDaoImpl;
-import com.cloud.event.dao.UsageEventDaoImpl;
-import com.cloud.host.dao.HostDaoImpl;
-import com.cloud.host.dao.HostDetailsDaoImpl;
-import com.cloud.host.dao.HostTagsDaoImpl;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.security.SecurityGroupManagerTestConfiguration.Library;
-import com.cloud.network.security.dao.SecurityGroupDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupWorkDaoImpl;
-import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
-import com.cloud.projects.ProjectManager;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.user.AccountManager;
-import com.cloud.user.DomainManager;
-import com.cloud.user.dao.AccountDaoImpl;
-import com.cloud.utils.component.SpringComponentScanUtils;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.NicDaoImpl;
-import com.cloud.vm.dao.UserVmDaoImpl;
-import com.cloud.vm.dao.UserVmDetailsDaoImpl;
-import com.cloud.vm.dao.VMInstanceDaoImpl;
-
-@Configuration
-@ComponentScan(basePackageClasses={
-        SecurityGroupRulesDaoImpl.class,
-        UserVmDaoImpl.class,
-        AccountDaoImpl.class,
-        ConfigurationDaoImpl.class,
-        SecurityGroupWorkDaoImpl.class,
-        VmRulesetLogDaoImpl.class,
-        VMInstanceDaoImpl.class,
-        DomainDaoImpl.class,
-        UsageEventDaoImpl.class,
-        ResourceTagsDaoImpl.class,
-        HostDaoImpl.class,
-        HostDetailsDaoImpl.class,
-        HostTagsDaoImpl.class,
-        ClusterDaoImpl.class,
-        HostPodDaoImpl.class,
-        DataCenterDaoImpl.class,
-        DataCenterIpAddressDaoImpl.class,
-        HostTransferMapDaoImpl.class,
-        SecurityGroupManagerImpl2.class,
-        SecurityGroupDaoImpl.class,
-        SecurityGroupVMMapDaoImpl.class,
-        UserVmDetailsDaoImpl.class,
-        DataCenterIpAddressDaoImpl.class,
-        DataCenterLinkLocalIpAddressDaoImpl.class,
-        DataCenterVnetDaoImpl.class,
-        PodVlanDaoImpl.class,
-        DcDetailsDaoImpl.class,
-        SecurityGroupRuleDaoImpl.class,
-        NicDaoImpl.class,
-        SecurityGroupJoinDaoImpl.class},
-        includeFilters={@Filter(value=Library.class, type=FilterType.CUSTOM)},
-        useDefaultFilters=false
-        )
-public class SecurityGroupManagerTestConfiguration {
-
-    @Bean
-    public NetworkModel networkModel() {
-        return Mockito.mock(NetworkModel.class);
-    }
-
-    @Bean 
-    public AgentManager agentManager() {
-        return Mockito.mock(AgentManager.class);
-    }
-
-    @Bean
-    public VirtualMachineManager virtualMachineManager(){
-        return Mockito.mock(VirtualMachineManager.class);
-    }
-
-    @Bean
-    public UserVmManager userVmManager() {
-        return Mockito.mock(UserVmManager.class);
-    }
-
-    @Bean
-    public NetworkManager networkManager(){
-        return Mockito.mock(NetworkManager.class);
-    }
-
-    @Bean
-    public AccountManager accountManager() {
-        return Mockito.mock(AccountManager.class);
-    }
-
-    @Bean
-    public DomainManager domainManager() {
-        return Mockito.mock(DomainManager.class);
-    }
-
-    @Bean
-    public ProjectManager projectManager() {
-        return Mockito.mock(ProjectManager.class);
-    }
-
-    public static class Library implements TypeFilter {
-
-        @Override
-        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
-            mdr.getClassMetadata().getClassName();
-            ComponentScan cs = SecurityGroupManagerTestConfiguration.class.getAnnotation(ComponentScan.class);
-            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
-        }
-
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.network.security;
+
+import java.io.IOException;
+
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
+import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
+import com.cloud.configuration.dao.ConfigurationDaoImpl;
+import com.cloud.dc.dao.ClusterDaoImpl;
+import com.cloud.dc.dao.DataCenterDaoImpl;
+import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterVnetDaoImpl;
+import com.cloud.dc.dao.DcDetailsDaoImpl;
+import com.cloud.dc.dao.HostPodDaoImpl;
+import com.cloud.dc.dao.PodVlanDaoImpl;
+import com.cloud.domain.dao.DomainDaoImpl;
+import com.cloud.event.dao.UsageEventDaoImpl;
+import com.cloud.host.dao.HostDaoImpl;
+import com.cloud.host.dao.HostDetailsDaoImpl;
+import com.cloud.host.dao.HostTagsDaoImpl;
+import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.security.SecurityGroupManagerTestConfiguration.Library;
+import com.cloud.network.security.dao.SecurityGroupDaoImpl;
+import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
+import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
+import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
+import com.cloud.network.security.dao.SecurityGroupWorkDaoImpl;
+import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
+import com.cloud.projects.ProjectManager;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.user.AccountManager;
+import com.cloud.user.DomainManager;
+import com.cloud.user.dao.AccountDaoImpl;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.UserVmManager;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.UserVmDaoImpl;
+import com.cloud.vm.dao.UserVmDetailsDaoImpl;
+import com.cloud.vm.dao.VMInstanceDaoImpl;
+
+@Configuration
+@ComponentScan(basePackageClasses={
+        SecurityGroupRulesDaoImpl.class,
+        UserVmDaoImpl.class,
+        AccountDaoImpl.class,
+        ConfigurationDaoImpl.class,
+        SecurityGroupWorkDaoImpl.class,
+        VmRulesetLogDaoImpl.class,
+        VMInstanceDaoImpl.class,
+        DomainDaoImpl.class,
+        UsageEventDaoImpl.class,
+        ResourceTagsDaoImpl.class,
+        HostDaoImpl.class,
+        HostDetailsDaoImpl.class,
+        HostTagsDaoImpl.class,
+        ClusterDaoImpl.class,
+        HostPodDaoImpl.class,
+        DataCenterDaoImpl.class,
+        DataCenterIpAddressDaoImpl.class,
+        HostTransferMapDaoImpl.class,
+        SecurityGroupManagerImpl2.class,
+        SecurityGroupDaoImpl.class,
+        SecurityGroupVMMapDaoImpl.class,
+        UserVmDetailsDaoImpl.class,
+        DataCenterIpAddressDaoImpl.class,
+        DataCenterLinkLocalIpAddressDaoImpl.class,
+        DataCenterVnetDaoImpl.class,
+        PodVlanDaoImpl.class,
+        DcDetailsDaoImpl.class,
+        SecurityGroupRuleDaoImpl.class,
+        NicDaoImpl.class,
+        SecurityGroupJoinDaoImpl.class},
+        includeFilters={@Filter(value=Library.class, type=FilterType.CUSTOM)},
+        useDefaultFilters=false
+        )
+public class SecurityGroupManagerTestConfiguration {
+
+    @Bean
+    public NetworkModel networkModel() {
+        return Mockito.mock(NetworkModel.class);
+    }
+
+    @Bean
+    public AgentManager agentManager() {
+        return Mockito.mock(AgentManager.class);
+    }
+
+    @Bean
+    public VirtualMachineManager virtualMachineManager(){
+        return Mockito.mock(VirtualMachineManager.class);
+    }
+
+    @Bean
+    public UserVmManager userVmManager() {
+        return Mockito.mock(UserVmManager.class);
+    }
+
+    @Bean
+    public NetworkManager networkManager(){
+        return Mockito.mock(NetworkManager.class);
+    }
+
+    @Bean
+    public AccountManager accountManager() {
+        return Mockito.mock(AccountManager.class);
+    }
+
+    @Bean
+    public DomainManager domainManager() {
+        return Mockito.mock(DomainManager.class);
+    }
+
+    @Bean
+    public ProjectManager projectManager() {
+        return Mockito.mock(ProjectManager.class);
+    }
+
+    public static class Library implements TypeFilter {
+
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = SecurityGroupManagerTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/snapshot/SnapshotDaoTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/snapshot/SnapshotDaoTestConfiguration.java b/server/test/com/cloud/snapshot/SnapshotDaoTestConfiguration.java
index 128a62c..cc410db 100644
--- a/server/test/com/cloud/snapshot/SnapshotDaoTestConfiguration.java
+++ b/server/test/com/cloud/snapshot/SnapshotDaoTestConfiguration.java
@@ -1,72 +1,72 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.snapshot;
-
-import java.io.IOException;
-
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.ComponentScan.Filter;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.core.type.filter.TypeFilter;
-
-import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
-import com.cloud.dc.dao.ClusterDaoImpl;
-import com.cloud.dc.dao.HostPodDaoImpl;
-import com.cloud.host.dao.HostDaoImpl;
-import com.cloud.host.dao.HostDetailsDaoImpl;
-import com.cloud.host.dao.HostTagsDaoImpl;
-import com.cloud.storage.dao.SnapshotDaoImpl;
-import com.cloud.storage.dao.VolumeDaoImpl;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.component.SpringComponentScanUtils;
-import com.cloud.vm.dao.NicDaoImpl;
-import com.cloud.vm.dao.VMInstanceDaoImpl;
-
-@Configuration
-@ComponentScan(basePackageClasses={
-        SnapshotDaoImpl.class,
-        ResourceTagsDaoImpl.class,
-        VMInstanceDaoImpl.class,
-        VolumeDaoImpl.class,
-        NicDaoImpl.class,
-        HostDaoImpl.class,
-        HostDetailsDaoImpl.class,
-        HostTagsDaoImpl.class,
-        HostTransferMapDaoImpl.class,
-        ClusterDaoImpl.class,
-        HostPodDaoImpl.class},
-        includeFilters={@Filter(value=SnapshotDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
-        useDefaultFilters=false
-        )
-public class SnapshotDaoTestConfiguration {
-
-
-    public static class Library implements TypeFilter {
-
-        @Override
-        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
-            mdr.getClassMetadata().getClassName();
-            ComponentScan cs = SnapshotDaoTestConfiguration.class.getAnnotation(ComponentScan.class);
-            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
-        }
-
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.snapshot;
+
+import java.io.IOException;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
+import com.cloud.dc.dao.ClusterDaoImpl;
+import com.cloud.dc.dao.HostPodDaoImpl;
+import com.cloud.host.dao.HostDaoImpl;
+import com.cloud.host.dao.HostDetailsDaoImpl;
+import com.cloud.host.dao.HostTagsDaoImpl;
+import com.cloud.storage.dao.SnapshotDaoImpl;
+import com.cloud.storage.dao.VolumeDaoImpl;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.VMInstanceDaoImpl;
+
+@Configuration
+@ComponentScan(basePackageClasses={
+        SnapshotDaoImpl.class,
+        ResourceTagsDaoImpl.class,
+        VMInstanceDaoImpl.class,
+        VolumeDaoImpl.class,
+        NicDaoImpl.class,
+        HostDaoImpl.class,
+        HostDetailsDaoImpl.class,
+        HostTagsDaoImpl.class,
+        HostTransferMapDaoImpl.class,
+        ClusterDaoImpl.class,
+        HostPodDaoImpl.class},
+        includeFilters={@Filter(value=SnapshotDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
+        useDefaultFilters=false
+        )
+public class SnapshotDaoTestConfiguration {
+
+
+    public static class Library implements TypeFilter {
+
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = SnapshotDaoTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java b/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
index de0a4ed..58de4d2 100644
--- a/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
+++ b/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
@@ -1,53 +1,53 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.storage.dao;
-
-import java.io.IOException;
-
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.ComponentScan.Filter;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.core.type.filter.TypeFilter;
-
-import com.cloud.utils.component.SpringComponentScanUtils;
-
-@Configuration
-@ComponentScan(basePackageClasses={
-        PrimaryDataStoreDaoImpl.class,
-        StoragePoolDetailsDaoImpl.class},
-        includeFilters={@Filter(value=StoragePoolDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
-        useDefaultFilters=false
-        )
-public class StoragePoolDaoTestConfiguration {
-
-
-    public static class Library implements TypeFilter {
-
-        @Override
-        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
-            mdr.getClassMetadata().getClassName();
-            ComponentScan cs = StoragePoolDaoTestConfiguration.class.getAnnotation(ComponentScan.class);
-            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
-        }
-
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.storage.dao;
+
+import java.io.IOException;
+
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.utils.component.SpringComponentScanUtils;
+
+@Configuration
+@ComponentScan(basePackageClasses={
+        PrimaryDataStoreDaoImpl.class,
+        StoragePoolDetailsDaoImpl.class},
+        includeFilters={@Filter(value=StoragePoolDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
+        useDefaultFilters=false
+        )
+public class StoragePoolDaoTestConfiguration {
+
+
+    public static class Library implements TypeFilter {
+
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = StoragePoolDaoTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
index a238e52..576c95b 100644
--- a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
+++ b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
@@ -1,186 +1,186 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm.snapshot;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CreateVMSnapshotAnswer;
-import com.cloud.agent.api.CreateVMSnapshotCommand;
-import com.cloud.agent.api.to.VolumeTO;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.OperationTimedoutException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.HypervisorGuruManager;
-import com.cloud.storage.GuestOSVO;
-import com.cloud.storage.Snapshot;
-import com.cloud.storage.SnapshotVO;
-import com.cloud.storage.VolumeVO;
-import com.cloud.storage.dao.GuestOSDao;
-import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.VolumeDao;
-import com.cloud.user.Account;
-import com.cloud.user.AccountManager;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserDao;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.fsm.NoTransitionException;
-import com.cloud.vm.UserVmVO;
-import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
-import com.cloud.vm.snapshot.dao.VMSnapshotDao;
-
-
-
-public class VMSnapshotManagerTest {
-    @Spy VMSnapshotManagerImpl _vmSnapshotMgr = new VMSnapshotManagerImpl();
-    @Mock Account admin;
-    @Mock VMSnapshotDao _vmSnapshotDao;
-    @Mock VolumeDao _volumeDao;
-    @Mock AccountDao _accountDao;
-    @Mock VMInstanceDao _vmInstanceDao;
-    @Mock UserVmDao _userVMDao;
-    @Mock HostDao _hostDao;
-    @Mock UserDao _userDao;
-    @Mock AgentManager _agentMgr;
-    @Mock HypervisorGuruManager _hvGuruMgr;
-    @Mock AccountManager _accountMgr;
-    @Mock GuestOSDao _guestOSDao;
-    @Mock PrimaryDataStoreDao _storagePoolDao;
-    @Mock SnapshotDao _snapshotDao;
-    @Mock VirtualMachineManager _itMgr;
-    @Mock ConfigurationDao _configDao;
-    int _vmSnapshotMax = 10;
-    
-    private static long TEST_VM_ID = 3L;
-    @Mock UserVmVO vmMock;
-    @Mock VolumeVO volumeMock;
-    
-    @Before
-    public void setup(){
-        MockitoAnnotations.initMocks(this);
-        doReturn(admin).when(_vmSnapshotMgr).getCaller();
-        _vmSnapshotMgr._accountDao = _accountDao;
-        _vmSnapshotMgr._userVMDao = _userVMDao;
-        _vmSnapshotMgr._vmSnapshotDao = _vmSnapshotDao;
-        _vmSnapshotMgr._volumeDao = _volumeDao;
-        _vmSnapshotMgr._accountMgr = _accountMgr;
-        _vmSnapshotMgr._snapshotDao = _snapshotDao;
-        _vmSnapshotMgr._guestOSDao = _guestOSDao;
-        
-        doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), 
-                any(Boolean.class), any(ControlledEntity.class));
-        
-        _vmSnapshotMgr._vmSnapshotMax = _vmSnapshotMax;
-        
-        when(_userVMDao.findById(anyLong())).thenReturn(vmMock);
-        when(_vmSnapshotDao.findByName(anyLong(), anyString())).thenReturn(null);
-        when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(new ArrayList<VMSnapshotVO>());
-       
-        List<VolumeVO> mockVolumeList = new ArrayList<VolumeVO>();
-        mockVolumeList.add(volumeMock);
-        when(volumeMock.getInstanceId()).thenReturn(TEST_VM_ID);
-        when(_volumeDao.findByInstance(anyLong())).thenReturn(mockVolumeList);
-        
-        when(vmMock.getInstanceName()).thenReturn("i-3-VM-TEST");
-        when(vmMock.getState()).thenReturn(State.Running);
-        
-        when(_guestOSDao.findById(anyLong())).thenReturn(mock(GuestOSVO.class));
-    } 
-    
-    // vmId null case
-    @Test(expected=InvalidParameterValueException.class)
-    public void testAllocVMSnapshotF1() throws ResourceAllocationException{
-        when(_userVMDao.findById(TEST_VM_ID)).thenReturn(null);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-    }
-
-    // vm state not in [running, stopped] case
-    @Test(expected=InvalidParameterValueException.class)
-    public void testAllocVMSnapshotF2() throws ResourceAllocationException{
-        when(vmMock.getState()).thenReturn(State.Starting);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-    }
-    
-    // VM in stopped state & snapshotmemory case
-    @Test(expected=InvalidParameterValueException.class)
-    public void testCreateVMSnapshotF3() throws AgentUnavailableException, OperationTimedoutException, ResourceAllocationException{
-        when(vmMock.getState()).thenReturn(State.Stopped);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-    }
-    
-    // max snapshot limit case
-    @SuppressWarnings("unchecked")
-    @Test(expected=CloudRuntimeException.class)
-    public void testAllocVMSnapshotF4() throws ResourceAllocationException{
-        List<VMSnapshotVO> mockList = mock(List.class);
-        when(mockList.size()).thenReturn(10);
-        when(_vmSnapshotDao.findByVm(TEST_VM_ID)).thenReturn(mockList);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-    }
-    
-    // active volume snapshots case
-    @SuppressWarnings("unchecked")
-    @Test(expected=CloudRuntimeException.class)
-    public void testAllocVMSnapshotF5() throws ResourceAllocationException{
-        List<SnapshotVO> mockList = mock(List.class);
-        when(mockList.size()).thenReturn(1);
-        when(_snapshotDao.listByInstanceId(TEST_VM_ID,Snapshot.State.Creating,
-                Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp)).thenReturn(mockList);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-    }
-    
-    // successful creation case
-    @Test
-    public void testCreateVMSnapshot() throws AgentUnavailableException, OperationTimedoutException, ResourceAllocationException, NoTransitionException{
-        when(vmMock.getState()).thenReturn(State.Running);
-        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
-        
-        when(_vmSnapshotDao.findCurrentSnapshotByVmId(anyLong())).thenReturn(null);
-        doReturn(new ArrayList<VolumeTO>()).when(_vmSnapshotMgr).getVolumeTOList(anyLong());
-        doReturn(new CreateVMSnapshotAnswer(null,true,"")).when(_vmSnapshotMgr).sendToPool(anyLong(), any(CreateVMSnapshotCommand.class));
-        doNothing().when(_vmSnapshotMgr).processAnswer(any(VMSnapshotVO.class), 
-                any(UserVmVO.class), any(Answer.class), anyLong());
-        doReturn(true).when(_vmSnapshotMgr).vmSnapshotStateTransitTo(any(VMSnapshotVO.class),any(VMSnapshot.Event.class));
-        _vmSnapshotMgr.createVmSnapshotInternal(vmMock, mock(VMSnapshotVO.class), 5L);
-    }
-
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm.snapshot;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CreateVMSnapshotAnswer;
+import com.cloud.agent.api.CreateVMSnapshotCommand;
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.exception.AgentUnavailableException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.OperationTimedoutException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.HypervisorGuruManager;
+import com.cloud.storage.GuestOSVO;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.GuestOSDao;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.UserDao;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.vm.UserVmVO;
+import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.VMInstanceDao;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+
+
+
+public class VMSnapshotManagerTest {
+    @Spy VMSnapshotManagerImpl _vmSnapshotMgr = new VMSnapshotManagerImpl();
+    @Mock Account admin;
+    @Mock VMSnapshotDao _vmSnapshotDao;
+    @Mock VolumeDao _volumeDao;
+    @Mock AccountDao _accountDao;
+    @Mock VMInstanceDao _vmInstanceDao;
+    @Mock UserVmDao _userVMDao;
+    @Mock HostDao _hostDao;
+    @Mock UserDao _userDao;
+    @Mock AgentManager _agentMgr;
+    @Mock HypervisorGuruManager _hvGuruMgr;
+    @Mock AccountManager _accountMgr;
+    @Mock GuestOSDao _guestOSDao;
+    @Mock PrimaryDataStoreDao _storagePoolDao;
+    @Mock SnapshotDao _snapshotDao;
+    @Mock VirtualMachineManager _itMgr;
+    @Mock ConfigurationDao _configDao;
+    int _vmSnapshotMax = 10;
+
+    private static long TEST_VM_ID = 3L;
+    @Mock UserVmVO vmMock;
+    @Mock VolumeVO volumeMock;
+
+    @Before
+    public void setup(){
+        MockitoAnnotations.initMocks(this);
+        doReturn(admin).when(_vmSnapshotMgr).getCaller();
+        _vmSnapshotMgr._accountDao = _accountDao;
+        _vmSnapshotMgr._userVMDao = _userVMDao;
+        _vmSnapshotMgr._vmSnapshotDao = _vmSnapshotDao;
+        _vmSnapshotMgr._volumeDao = _volumeDao;
+        _vmSnapshotMgr._accountMgr = _accountMgr;
+        _vmSnapshotMgr._snapshotDao = _snapshotDao;
+        _vmSnapshotMgr._guestOSDao = _guestOSDao;
+
+        doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class),
+                any(Boolean.class), any(ControlledEntity.class));
+
+        _vmSnapshotMgr._vmSnapshotMax = _vmSnapshotMax;
+
+        when(_userVMDao.findById(anyLong())).thenReturn(vmMock);
+        when(_vmSnapshotDao.findByName(anyLong(), anyString())).thenReturn(null);
+        when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(new ArrayList<VMSnapshotVO>());
+
+        List<VolumeVO> mockVolumeList = new ArrayList<VolumeVO>();
+        mockVolumeList.add(volumeMock);
+        when(volumeMock.getInstanceId()).thenReturn(TEST_VM_ID);
+        when(_volumeDao.findByInstance(anyLong())).thenReturn(mockVolumeList);
+
+        when(vmMock.getInstanceName()).thenReturn("i-3-VM-TEST");
+        when(vmMock.getState()).thenReturn(State.Running);
+
+        when(_guestOSDao.findById(anyLong())).thenReturn(mock(GuestOSVO.class));
+    }
+
+    // vmId null case
+    @Test(expected=InvalidParameterValueException.class)
+    public void testAllocVMSnapshotF1() throws ResourceAllocationException{
+        when(_userVMDao.findById(TEST_VM_ID)).thenReturn(null);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+    }
+
+    // vm state not in [running, stopped] case
+    @Test(expected=InvalidParameterValueException.class)
+    public void testAllocVMSnapshotF2() throws ResourceAllocationException{
+        when(vmMock.getState()).thenReturn(State.Starting);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+    }
+
+    // VM in stopped state & snapshotmemory case
+    @Test(expected=InvalidParameterValueException.class)
+    public void testCreateVMSnapshotF3() throws AgentUnavailableException, OperationTimedoutException, ResourceAllocationException{
+        when(vmMock.getState()).thenReturn(State.Stopped);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+    }
+
+    // max snapshot limit case
+    @SuppressWarnings("unchecked")
+    @Test(expected=CloudRuntimeException.class)
+    public void testAllocVMSnapshotF4() throws ResourceAllocationException{
+        List<VMSnapshotVO> mockList = mock(List.class);
+        when(mockList.size()).thenReturn(10);
+        when(_vmSnapshotDao.findByVm(TEST_VM_ID)).thenReturn(mockList);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+    }
+
+    // active volume snapshots case
+    @SuppressWarnings("unchecked")
+    @Test(expected=CloudRuntimeException.class)
+    public void testAllocVMSnapshotF5() throws ResourceAllocationException{
+        List<SnapshotVO> mockList = mock(List.class);
+        when(mockList.size()).thenReturn(1);
+        when(_snapshotDao.listByInstanceId(TEST_VM_ID,Snapshot.State.Creating,
+                Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp)).thenReturn(mockList);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+    }
+
+    // successful creation case
+    @Test
+    public void testCreateVMSnapshot() throws AgentUnavailableException, OperationTimedoutException, ResourceAllocationException, NoTransitionException{
+        when(vmMock.getState()).thenReturn(State.Running);
+        _vmSnapshotMgr.allocVMSnapshot(TEST_VM_ID,"","",true);
+
+        when(_vmSnapshotDao.findCurrentSnapshotByVmId(anyLong())).thenReturn(null);
+        doReturn(new ArrayList<VolumeTO>()).when(_vmSnapshotMgr).getVolumeTOList(anyLong());
+        doReturn(new CreateVMSnapshotAnswer(null,true,"")).when(_vmSnapshotMgr).sendToPool(anyLong(), any(CreateVMSnapshotCommand.class));
+        doNothing().when(_vmSnapshotMgr).processAnswer(any(VMSnapshotVO.class),
+                any(UserVmVO.class), any(Answer.class), anyLong());
+        doReturn(true).when(_vmSnapshotMgr).vmSnapshotStateTransitTo(any(VMSnapshotVO.class),any(VMSnapshot.Event.class));
+        _vmSnapshotMgr.createVmSnapshotInternal(vmMock, mock(VMSnapshotVO.class), 5L);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/server/test/com/cloud/vpc/VpcTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/VpcTestConfiguration.java b/server/test/com/cloud/vpc/VpcTestConfiguration.java
index e250cd1..df73a6c 100644
--- a/server/test/com/cloud/vpc/VpcTestConfiguration.java
+++ b/server/test/com/cloud/vpc/VpcTestConfiguration.java
@@ -1,231 +1,231 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.vpc;
-
-import java.io.IOException;
-
-import org.mockito.Mockito;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.ComponentScan.Filter;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.core.type.filter.TypeFilter;
-
-import com.cloud.alert.AlertManager;
-import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
-import com.cloud.configuration.dao.ConfigurationDaoImpl;
-import com.cloud.configuration.dao.ResourceLimitDaoImpl;
-import com.cloud.dao.EntityManagerImpl;
-import com.cloud.dc.dao.AccountVlanMapDaoImpl;
-import com.cloud.dc.dao.ClusterDaoImpl;
-import com.cloud.dc.dao.DataCenterDaoImpl;
-import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
-import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
-import com.cloud.dc.dao.DataCenterVnetDaoImpl;
-import com.cloud.dc.dao.DcDetailsDaoImpl;
-import com.cloud.dc.dao.HostPodDaoImpl;
-import com.cloud.dc.dao.PodVlanDaoImpl;
-import com.cloud.dc.dao.PodVlanMapDaoImpl;
-import com.cloud.domain.dao.DomainDaoImpl;
-import com.cloud.event.dao.UsageEventDao;
-import com.cloud.host.dao.HostDaoImpl;
-import com.cloud.host.dao.HostDetailsDaoImpl;
-import com.cloud.host.dao.HostTagsDaoImpl;
-import com.cloud.vpc.MockNetworkModelImpl;
-import com.cloud.network.StorageNetworkManager;
-import com.cloud.network.dao.IPAddressDaoImpl;
-import com.cloud.network.lb.LoadBalancingRulesManager;
-import com.cloud.network.rules.RulesManager;
-import com.cloud.network.vpc.VpcManagerImpl;
-import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
-import com.cloud.network.vpc.dao.StaticRouteDaoImpl;
-import com.cloud.network.vpc.dao.VpcDao;
-import com.cloud.network.vpc.dao.VpcGatewayDaoImpl;
-import com.cloud.network.vpc.dao.VpcOfferingDao;
-import com.cloud.utils.component.SpringComponentScanUtils;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.dao.DomainRouterDaoImpl;
-import com.cloud.vm.dao.NicDaoImpl;
-import com.cloud.vm.dao.UserVmDaoImpl;
-import com.cloud.vm.dao.UserVmDetailsDaoImpl;
-import com.cloud.vm.dao.VMInstanceDaoImpl;
-import com.cloud.vpc.dao.MockNetworkOfferingDaoImpl;
-import com.cloud.vpc.dao.MockNetworkOfferingServiceMapDaoImpl;
-import com.cloud.vpc.dao.MockNetworkServiceMapDaoImpl;
-import com.cloud.vpc.dao.MockVpcOfferingDaoImpl;
-import com.cloud.vpc.dao.MockVpcOfferingServiceMapDaoImpl;
-
-
-import com.cloud.configuration.dao.ResourceCountDaoImpl;
-import com.cloud.dc.dao.VlanDaoImpl;
-import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
-import com.cloud.network.dao.FirewallRulesDaoImpl;
-import com.cloud.network.dao.LoadBalancerDaoImpl;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.PhysicalNetworkDaoImpl;
-import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
-import com.cloud.network.dao.RouterNetworkDaoImpl;
-import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
-import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
-import com.cloud.network.element.NetworkElement;
-import com.cloud.network.element.Site2SiteVpnServiceProvider;
-import com.cloud.network.vpn.RemoteAccessVpnService;
-import com.cloud.network.vpn.Site2SiteVpnManager;
-import com.cloud.projects.dao.ProjectAccountDaoImpl;
-import com.cloud.projects.dao.ProjectDaoImpl;
-import com.cloud.resourcelimit.ResourceLimitManagerImpl;
-import com.cloud.storage.dao.SnapshotDaoImpl;
-import com.cloud.storage.dao.VMTemplateDaoImpl;
-import com.cloud.storage.dao.VMTemplateDetailsDaoImpl;
-import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
-import com.cloud.storage.dao.VolumeDaoImpl;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.user.AccountManager;
-import com.cloud.user.dao.AccountDaoImpl;
-import com.cloud.user.dao.UserStatisticsDaoImpl;
-
-
-@Configuration
-@ComponentScan(basePackageClasses={VpcManagerImpl.class, NetworkElement.class,
-        VpcOfferingDao.class,
-        ConfigurationDaoImpl.class,
-        IPAddressDaoImpl.class,
-        DomainRouterDaoImpl.class,
-        VpcGatewayDaoImpl.class,
-        PrivateIpDaoImpl.class,
-        StaticRouteDaoImpl.class,
-        PhysicalNetworkDaoImpl.class,
-        ResourceTagsDaoImpl.class,
-        FirewallRulesDaoImpl.class,
-        VlanDaoImpl.class,
-        AccountDaoImpl.class,
-        ResourceCountDaoImpl.class,
-        Site2SiteVpnGatewayDaoImpl.class,
-        PodVlanMapDaoImpl.class,
-        AccountVlanMapDaoImpl.class,
-        HostDaoImpl.class,
-        HostDetailsDaoImpl.class,
-        HostTagsDaoImpl.class,
-        HostTransferMapDaoImpl.class,
-        ClusterDaoImpl.class,
-        HostPodDaoImpl.class,
-        RouterNetworkDaoImpl.class,
-        UserStatisticsDaoImpl.class,
-        PhysicalNetworkTrafficTypeDaoImpl.class,
-        FirewallRulesCidrsDaoImpl.class,
-        ResourceLimitManagerImpl.class,
-        ResourceLimitDaoImpl.class,
-        ResourceCountDaoImpl.class,
-        DomainDaoImpl.class,
-        UserVmDaoImpl.class,
-        UserVmDetailsDaoImpl.class,
-        NicDaoImpl.class,
-        SnapshotDaoImpl.class,
-        VMInstanceDaoImpl.class,
-        VolumeDaoImpl.class,
-        VMTemplateDaoImpl.class,VMTemplateZoneDaoImpl.class,VMTemplateDetailsDaoImpl.class,DataCenterDaoImpl.class,DataCenterIpAddressDaoImpl.class,DataCenterLinkLocalIpAddressDaoImpl.class,DataCenterVnetDaoImpl.class,PodVlanDaoImpl.class,
-        DcDetailsDaoImpl.class,MockNetworkManagerImpl.class,MockVpcVirtualNetworkApplianceManager.class,
-        EntityManagerImpl.class,LoadBalancerDaoImpl.class,FirewallRulesCidrsDaoImpl.class,VirtualRouterProviderDaoImpl.class,
-        ProjectDaoImpl.class,ProjectAccountDaoImpl.class,MockVpcOfferingDaoImpl.class,
-        MockConfigurationManagerImpl.class, MockNetworkOfferingServiceMapDaoImpl.class,
-        MockNetworkServiceMapDaoImpl.class,MockVpcOfferingServiceMapDaoImpl.class,MockNetworkOfferingDaoImpl.class, MockNetworkModelImpl.class},
-        includeFilters={@Filter(value=VpcTestConfiguration.VpcLibrary.class, type=FilterType.CUSTOM)},
-        useDefaultFilters=false
-        )
-public class VpcTestConfiguration {
-    
-    
-
-    @Bean
-    public RulesManager rulesManager() {
-        return Mockito.mock(RulesManager.class);
-    }
-
-    
-    @Bean
-    public StorageNetworkManager storageNetworkManager() {
-        return Mockito.mock(StorageNetworkManager.class);
-    }
-    
-    @Bean
-    public LoadBalancingRulesManager loadBalancingRulesManager() {
-        return Mockito.mock(LoadBalancingRulesManager.class);
-    }
-
-    
-    @Bean
-    public AlertManager alertManager() {
-        return Mockito.mock(AlertManager.class);
-    }
-    
-
-
-    @Bean
-    public UserVmManager userVmManager() {
-        return Mockito.mock(UserVmManager.class);
-    }
-
-
-    @Bean
-    public AccountManager accountManager() {
-        return Mockito.mock(AccountManager.class);
-    }
-
-    @Bean
-    public Site2SiteVpnServiceProvider site2SiteVpnServiceProvider() {
-        return Mockito.mock(Site2SiteVpnServiceProvider.class);
-    }
-
-    @Bean
-    public Site2SiteVpnManager site2SiteVpnManager() {
-        return Mockito.mock(Site2SiteVpnManager.class);
-    }
-
-    
-    @Bean
-    public UsageEventDao usageEventDao() {
-        return Mockito.mock(UsageEventDao.class);
-    }
-    
-    @Bean
-    public RemoteAccessVpnService remoteAccessVpnService() {
-        return Mockito.mock(RemoteAccessVpnService.class);
-    }
-    
-    @Bean
-    public VpcDao vpcDao() {
-        return Mockito.mock(VpcDao.class);
-    }
-
-    @Bean
-    public NetworkDao networkDao() {
-        return Mockito.mock(NetworkDao.class);
-    }
-    
-    public static class VpcLibrary implements TypeFilter {
-        @Override
-        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
-            mdr.getClassMetadata().getClassName();
-            ComponentScan cs = VpcTestConfiguration.class.getAnnotation(ComponentScan.class);
-            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
-        }
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.vpc;
+
+import java.io.IOException;
+
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.alert.AlertManager;
+import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
+import com.cloud.configuration.dao.ConfigurationDaoImpl;
+import com.cloud.configuration.dao.ResourceLimitDaoImpl;
+import com.cloud.dao.EntityManagerImpl;
+import com.cloud.dc.dao.AccountVlanMapDaoImpl;
+import com.cloud.dc.dao.ClusterDaoImpl;
+import com.cloud.dc.dao.DataCenterDaoImpl;
+import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterVnetDaoImpl;
+import com.cloud.dc.dao.DcDetailsDaoImpl;
+import com.cloud.dc.dao.HostPodDaoImpl;
+import com.cloud.dc.dao.PodVlanDaoImpl;
+import com.cloud.dc.dao.PodVlanMapDaoImpl;
+import com.cloud.domain.dao.DomainDaoImpl;
+import com.cloud.event.dao.UsageEventDao;
+import com.cloud.host.dao.HostDaoImpl;
+import com.cloud.host.dao.HostDetailsDaoImpl;
+import com.cloud.host.dao.HostTagsDaoImpl;
+import com.cloud.vpc.MockNetworkModelImpl;
+import com.cloud.network.StorageNetworkManager;
+import com.cloud.network.dao.IPAddressDaoImpl;
+import com.cloud.network.lb.LoadBalancingRulesManager;
+import com.cloud.network.rules.RulesManager;
+import com.cloud.network.vpc.VpcManagerImpl;
+import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
+import com.cloud.network.vpc.dao.StaticRouteDaoImpl;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcGatewayDaoImpl;
+import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.UserVmManager;
+import com.cloud.vm.dao.DomainRouterDaoImpl;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.UserVmDaoImpl;
+import com.cloud.vm.dao.UserVmDetailsDaoImpl;
+import com.cloud.vm.dao.VMInstanceDaoImpl;
+import com.cloud.vpc.dao.MockNetworkOfferingDaoImpl;
+import com.cloud.vpc.dao.MockNetworkOfferingServiceMapDaoImpl;
+import com.cloud.vpc.dao.MockNetworkServiceMapDaoImpl;
+import com.cloud.vpc.dao.MockVpcOfferingDaoImpl;
+import com.cloud.vpc.dao.MockVpcOfferingServiceMapDaoImpl;
+
+
+import com.cloud.configuration.dao.ResourceCountDaoImpl;
+import com.cloud.dc.dao.VlanDaoImpl;
+import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
+import com.cloud.network.dao.FirewallRulesDaoImpl;
+import com.cloud.network.dao.LoadBalancerDaoImpl;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.PhysicalNetworkDaoImpl;
+import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
+import com.cloud.network.dao.RouterNetworkDaoImpl;
+import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
+import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
+import com.cloud.network.element.NetworkElement;
+import com.cloud.network.element.Site2SiteVpnServiceProvider;
+import com.cloud.network.vpn.RemoteAccessVpnService;
+import com.cloud.network.vpn.Site2SiteVpnManager;
+import com.cloud.projects.dao.ProjectAccountDaoImpl;
+import com.cloud.projects.dao.ProjectDaoImpl;
+import com.cloud.resourcelimit.ResourceLimitManagerImpl;
+import com.cloud.storage.dao.SnapshotDaoImpl;
+import com.cloud.storage.dao.VMTemplateDaoImpl;
+import com.cloud.storage.dao.VMTemplateDetailsDaoImpl;
+import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
+import com.cloud.storage.dao.VolumeDaoImpl;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.user.AccountManager;
+import com.cloud.user.dao.AccountDaoImpl;
+import com.cloud.user.dao.UserStatisticsDaoImpl;
+
+
+@Configuration
+@ComponentScan(basePackageClasses={VpcManagerImpl.class, NetworkElement.class,
+        VpcOfferingDao.class,
+        ConfigurationDaoImpl.class,
+        IPAddressDaoImpl.class,
+        DomainRouterDaoImpl.class,
+        VpcGatewayDaoImpl.class,
+        PrivateIpDaoImpl.class,
+        StaticRouteDaoImpl.class,
+        PhysicalNetworkDaoImpl.class,
+        ResourceTagsDaoImpl.class,
+        FirewallRulesDaoImpl.class,
+        VlanDaoImpl.class,
+        AccountDaoImpl.class,
+        ResourceCountDaoImpl.class,
+        Site2SiteVpnGatewayDaoImpl.class,
+        PodVlanMapDaoImpl.class,
+        AccountVlanMapDaoImpl.class,
+        HostDaoImpl.class,
+        HostDetailsDaoImpl.class,
+        HostTagsDaoImpl.class,
+        HostTransferMapDaoImpl.class,
+        ClusterDaoImpl.class,
+        HostPodDaoImpl.class,
+        RouterNetworkDaoImpl.class,
+        UserStatisticsDaoImpl.class,
+        PhysicalNetworkTrafficTypeDaoImpl.class,
+        FirewallRulesCidrsDaoImpl.class,
+        ResourceLimitManagerImpl.class,
+        ResourceLimitDaoImpl.class,
+        ResourceCountDaoImpl.class,
+        DomainDaoImpl.class,
+        UserVmDaoImpl.class,
+        UserVmDetailsDaoImpl.class,
+        NicDaoImpl.class,
+        SnapshotDaoImpl.class,
+        VMInstanceDaoImpl.class,
+        VolumeDaoImpl.class,
+        VMTemplateDaoImpl.class,VMTemplateZoneDaoImpl.class,VMTemplateDetailsDaoImpl.class,DataCenterDaoImpl.class,DataCenterIpAddressDaoImpl.class,DataCenterLinkLocalIpAddressDaoImpl.class,DataCenterVnetDaoImpl.class,PodVlanDaoImpl.class,
+        DcDetailsDaoImpl.class,MockNetworkManagerImpl.class,MockVpcVirtualNetworkApplianceManager.class,
+        EntityManagerImpl.class,LoadBalancerDaoImpl.class,FirewallRulesCidrsDaoImpl.class,VirtualRouterProviderDaoImpl.class,
+        ProjectDaoImpl.class,ProjectAccountDaoImpl.class,MockVpcOfferingDaoImpl.class,
+        MockConfigurationManagerImpl.class, MockNetworkOfferingServiceMapDaoImpl.class,
+        MockNetworkServiceMapDaoImpl.class,MockVpcOfferingServiceMapDaoImpl.class,MockNetworkOfferingDaoImpl.class, MockNetworkModelImpl.class},
+        includeFilters={@Filter(value=VpcTestConfiguration.VpcLibrary.class, type=FilterType.CUSTOM)},
+        useDefaultFilters=false
+        )
+public class VpcTestConfiguration {
+
+
+
+    @Bean
+    public RulesManager rulesManager() {
+        return Mockito.mock(RulesManager.class);
+    }
+
+
+    @Bean
+    public StorageNetworkManager storageNetworkManager() {
+        return Mockito.mock(StorageNetworkManager.class);
+    }
+
+    @Bean
+    public LoadBalancingRulesManager loadBalancingRulesManager() {
+        return Mockito.mock(LoadBalancingRulesManager.class);
+    }
+
+
+    @Bean
+    public AlertManager alertManager() {
+        return Mockito.mock(AlertManager.class);
+    }
+
+
+
+    @Bean
+    public UserVmManager userVmManager() {
+        return Mockito.mock(UserVmManager.class);
+    }
+
+
+    @Bean
+    public AccountManager accountManager() {
+        return Mockito.mock(AccountManager.class);
+    }
+
+    @Bean
+    public Site2SiteVpnServiceProvider site2SiteVpnServiceProvider() {
+        return Mockito.mock(Site2SiteVpnServiceProvider.class);
+    }
+
+    @Bean
+    public Site2SiteVpnManager site2SiteVpnManager() {
+        return Mockito.mock(Site2SiteVpnManager.class);
+    }
+
+
+    @Bean
+    public UsageEventDao usageEventDao() {
+        return Mockito.mock(UsageEventDao.class);
+    }
+
+    @Bean
+    public RemoteAccessVpnService remoteAccessVpnService() {
+        return Mockito.mock(RemoteAccessVpnService.class);
+    }
+
+    @Bean
+    public VpcDao vpcDao() {
+        return Mockito.mock(VpcDao.class);
+    }
+
+    @Bean
+    public NetworkDao networkDao() {
+        return Mockito.mock(NetworkDao.class);
+    }
+
+    public static class VpcLibrary implements TypeFilter {
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = VpcTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/utils/src/com/cloud/utils/component/SpringComponentScanUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/SpringComponentScanUtils.java b/utils/src/com/cloud/utils/component/SpringComponentScanUtils.java
index 9a85c79..28b84e6 100644
--- a/utils/src/com/cloud/utils/component/SpringComponentScanUtils.java
+++ b/utils/src/com/cloud/utils/component/SpringComponentScanUtils.java
@@ -1,41 +1,41 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.utils.component;
-
-import org.springframework.context.annotation.ComponentScan;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class SpringComponentScanUtils {
-
-    public static boolean includedInBasePackageClasses(String clazzName, ComponentScan cs) {
-        Class<?> clazzToCheck;
-        try {
-            clazzToCheck = Class.forName(clazzName);
-        } catch (ClassNotFoundException e) {
-            throw new CloudRuntimeException("Unable to find " + clazzName);
-        }
-        Class<?>[] clazzes = cs.basePackageClasses();
-        for (Class<?> clazz : clazzes) {
-            if (clazzToCheck.isAssignableFrom(clazz)) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.utils.component;
+
+import org.springframework.context.annotation.ComponentScan;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class SpringComponentScanUtils {
+
+    public static boolean includedInBasePackageClasses(String clazzName, ComponentScan cs) {
+        Class<?> clazzToCheck;
+        try {
+            clazzToCheck = Class.forName(clazzName);
+        } catch (ClassNotFoundException e) {
+            throw new CloudRuntimeException("Unable to find " + clazzName);
+        }
+        Class<?>[] clazzes = cs.basePackageClasses();
+        for (Class<?> clazz : clazzes) {
+            if (clazzToCheck.isAssignableFrom(clazz)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/utils/src/com/cloud/utils/xmlobject/XmlObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObject.java b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
index 80ac13d..67bb8ed 100644
--- a/utils/src/com/cloud/utils/xmlobject/XmlObject.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
@@ -14,183 +14,183 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package com.cloud.utils.xmlobject;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-import edu.emory.mathcs.backport.java.util.Collections;
-
-public class XmlObject {
-    private Map<String, Object> elements = new HashMap<String, Object>();
-    private String text;
-    private String tag;
-    
-    XmlObject() {
-    }
-    
-    public XmlObject(String tag) {
-        this.tag = tag;
-    }
-    
+package com.cloud.utils.xmlobject;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+import edu.emory.mathcs.backport.java.util.Collections;
+
+public class XmlObject {
+    private Map<String, Object> elements = new HashMap<String, Object>();
+    private String text;
+    private String tag;
+
+    XmlObject() {
+    }
+
+    public XmlObject(String tag) {
+        this.tag = tag;
+    }
+
     public XmlObject putElement(String key, Object e) {
         if (e == null) {
             throw new IllegalArgumentException(String.format("element[%s] can not be null", key));
-        }
-        Object old = elements.get(key);
-        if (old == null) {
-            System.out.println(String.format("no %s, add new", key));
-            elements.put(key, e);
-        } else {
-            if (old instanceof List) {
-                System.out.println(String.format("already list %s, add", key));
-                ((List)old).add(e);
-            } else {
-                System.out.println(String.format("not list list %s, add list", key));
-                List lst = new ArrayList();
-                lst.add(old);
-                lst.add(e);
-                elements.put(key, lst);
-            }
-        }
-        
-        return this;
-    }
-    
-    private Object recurGet(XmlObject obj, Iterator<String> it) {
-        String key = it.next();
-        Object e = obj.elements.get(key);
-        if (e == null) {
-            return null;
-        }
-        
-        if (!it.hasNext()) {
-            return e;
-        } else {
-            if (!(e instanceof XmlObject)) {
-                throw new CloudRuntimeException(String.format("%s doesn't reference to a XmlObject", it.next()));
-            }
-            return recurGet((XmlObject) e, it);
-        }
-    }
-    
-    public <T> T get(String elementStr) {
-        String[] strs = elementStr.split("\\.");
-        List<String> lst = new ArrayList<String>(strs.length);
-        Collections.addAll(lst, strs);
-        return (T)recurGet(this, lst.iterator());
-    }
-    
-    public <T> List<T> getAsList(String elementStr) {
-        Object e = get(elementStr);
-        if (e instanceof List) {
-            return (List<T>)e;
-        }
-        List lst = new ArrayList(1);
-        lst.add(e);
-        return lst;
-    }
-    
-    public String getText() {
-        return text;
-    }
-
-    public XmlObject setText(String text) {
-        this.text = text;
-        return this;
-    }
-
-    public String getTag() {
-        return tag;
-    }
-
-    public XmlObject setTag(String tag) {
-        this.tag = tag;
-        return this;
-    }
-    
-    public String dump() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("<").append(tag);
-        List<XmlObject> children = new ArrayList<XmlObject>();
-        for (Map.Entry<String, Object> e : elements.entrySet()) {
-            String key = e.getKey();
-            Object val = e.getValue();
-            if (val instanceof String)  {
-                sb.append(String.format(" %s=\"%s\"", key, val.toString()));
-            } else if (val instanceof XmlObject) {
-                children.add((XmlObject) val);
-            } else if (val instanceof List) {
-                children.addAll((Collection<? extends XmlObject>) val);
-            } else {
-                throw new CloudRuntimeException(String.format("unsupported element type[tag:%s, class: %s], only allowed type of [String, List<XmlObject>, Object]", key, val.getClass().getName()));
-            }
-        }
-        
-        if (!children.isEmpty() && text != null) {
-            throw new CloudRuntimeException(String.format("element %s cannot have both text[%s] and child elements", tag, text));
-        }
-        
-        if (!children.isEmpty()) {
-            sb.append(">");
-            for (XmlObject x : children) {
-                sb.append(x.dump());
-            }
-            sb.append(String.format("</%s>", tag));
-        } else {
-            if (text != null) {
-                sb.append(">");
-                sb.append(text);
-                sb.append(String.format("</%s>", tag));
-            } else {
-                sb.append(" />");
-            }
-        }
-        return sb.toString();
-    }
-    
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder("<" + tag);
-        for (Map.Entry<String, Object> e : elements.entrySet()) {
-            String key = e.getKey();
-            Object value = e.getValue();
-            if (!(value instanceof String)) {
-                continue;
-            }
-            sb.append(String.format(" %s=\"%s\"", key, value.toString()));
-        }
-        
-        if (text == null || "".equals(text.trim())) {
-            sb.append(" />");
-        } else {
-            sb.append(">").append(text).append(String.format("</ %s>", tag));
-        }
-        return sb.toString();
-    }
-    
-    public <T> T evaluateObject(T obj) {
-        Class<?> clazz = obj.getClass();
-        try {
-            do {
-                Field[] fs = clazz.getDeclaredFields();
-                for (Field f : fs) {
-                    f.setAccessible(true);
-                    Object value = get(f.getName());
-                    f.set(obj, value);
-                }
-                clazz = clazz.getSuperclass();
-            } while (clazz != null && clazz != Object.class);
-            return obj;
-        } catch (Exception e) {
-            throw new CloudRuntimeException(e);
-        }
-    }
-}
+        }
+        Object old = elements.get(key);
+        if (old == null) {
+            System.out.println(String.format("no %s, add new", key));
+            elements.put(key, e);
+        } else {
+            if (old instanceof List) {
+                System.out.println(String.format("already list %s, add", key));
+                ((List)old).add(e);
+            } else {
+                System.out.println(String.format("not list list %s, add list", key));
+                List lst = new ArrayList();
+                lst.add(old);
+                lst.add(e);
+                elements.put(key, lst);
+            }
+        }
+
+        return this;
+    }
+
+    private Object recurGet(XmlObject obj, Iterator<String> it) {
+        String key = it.next();
+        Object e = obj.elements.get(key);
+        if (e == null) {
+            return null;
+        }
+
+        if (!it.hasNext()) {
+            return e;
+        } else {
+            if (!(e instanceof XmlObject)) {
+                throw new CloudRuntimeException(String.format("%s doesn't reference to a XmlObject", it.next()));
+            }
+            return recurGet((XmlObject) e, it);
+        }
+    }
+
+    public <T> T get(String elementStr) {
+        String[] strs = elementStr.split("\\.");
+        List<String> lst = new ArrayList<String>(strs.length);
+        Collections.addAll(lst, strs);
+        return (T)recurGet(this, lst.iterator());
+    }
+
+    public <T> List<T> getAsList(String elementStr) {
+        Object e = get(elementStr);
+        if (e instanceof List) {
+            return (List<T>)e;
+        }
+        List lst = new ArrayList(1);
+        lst.add(e);
+        return lst;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public XmlObject setText(String text) {
+        this.text = text;
+        return this;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public XmlObject setTag(String tag) {
+        this.tag = tag;
+        return this;
+    }
+
+    public String dump() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("<").append(tag);
+        List<XmlObject> children = new ArrayList<XmlObject>();
+        for (Map.Entry<String, Object> e : elements.entrySet()) {
+            String key = e.getKey();
+            Object val = e.getValue();
+            if (val instanceof String)  {
+                sb.append(String.format(" %s=\"%s\"", key, val.toString()));
+            } else if (val instanceof XmlObject) {
+                children.add((XmlObject) val);
+            } else if (val instanceof List) {
+                children.addAll((Collection<? extends XmlObject>) val);
+            } else {
+                throw new CloudRuntimeException(String.format("unsupported element type[tag:%s, class: %s], only allowed type of [String, List<XmlObject>, Object]", key, val.getClass().getName()));
+            }
+        }
+
+        if (!children.isEmpty() && text != null) {
+            throw new CloudRuntimeException(String.format("element %s cannot have both text[%s] and child elements", tag, text));
+        }
+
+        if (!children.isEmpty()) {
+            sb.append(">");
+            for (XmlObject x : children) {
+                sb.append(x.dump());
+            }
+            sb.append(String.format("</%s>", tag));
+        } else {
+            if (text != null) {
+                sb.append(">");
+                sb.append(text);
+                sb.append(String.format("</%s>", tag));
+            } else {
+                sb.append(" />");
+            }
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<" + tag);
+        for (Map.Entry<String, Object> e : elements.entrySet()) {
+            String key = e.getKey();
+            Object value = e.getValue();
+            if (!(value instanceof String)) {
+                continue;
+            }
+            sb.append(String.format(" %s=\"%s\"", key, value.toString()));
+        }
+
+        if (text == null || "".equals(text.trim())) {
+            sb.append(" />");
+        } else {
+            sb.append(">").append(text).append(String.format("</ %s>", tag));
+        }
+        return sb.toString();
+    }
+
+    public <T> T evaluateObject(T obj) {
+        Class<?> clazz = obj.getClass();
+        try {
+            do {
+                Field[] fs = clazz.getDeclaredFields();
+                for (Field f : fs) {
+                    f.setAccessible(true);
+                    Object value = get(f.getName());
+                    f.set(obj, value);
+                }
+                clazz = clazz.getSuperclass();
+            } while (clazz != null && clazz != Object.class);
+            return obj;
+        } catch (Exception e) {
+            throw new CloudRuntimeException(e);
+        }
+    }
+}


Mime
View raw message