cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [33/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 30e2971
Date Fri, 12 Apr 2013 11:59:06 GMT
Fixes to unit-test dues to changes in master


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6137d327
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6137d327
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6137d327

Branch: refs/heads/marvin_refactor
Commit: 6137d327a8969e403c4fe0ae05c2bd1d7a12033e
Parents: eea0ed5
Author: Prachi Damle <prachi@cloud.com>
Authored: Thu Apr 11 13:09:49 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 13:23:48 2013 -0700

----------------------------------------------------------------------
 .../affinity/AffinityGroupServiceImpl.java         |    3 +-
 .../affinity/AffinityApiTestConfiguration.java     |   18 +++++++++++-
 .../cloudstack/affinity/AffinityApiUnitTest.java   |   10 +++++++
 server/test/resources/affinityContext.xml          |   21 ++++++++------
 4 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6137d327/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
index 613c095..2ea887c 100644
--- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
@@ -64,6 +64,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
     private UserVmDao _userVmDao;
 
     @Override
+    @ActionEvent(eventType = EventTypes.EVENT_AFFINITY_GROUP_CREATE, eventDescription = "Creating
Affinity Group", create = true)
     public AffinityGroup createAffinityGroup(String account, Long domainId, String affinityGroupName,
             String affinityGroupType, String description) {
 
@@ -106,7 +107,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
 
     @DB
     @Override
-    @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_DELETE, eventDescription = "deleting
affinity group")
+    @ActionEvent(eventType = EventTypes.EVENT_AFFINITY_GROUP_DELETE, eventDescription = "Deleting
affinity group")
     public boolean deleteAffinityGroup(Long affinityGroupId, String account, Long domainId,
String affinityGroupName)
             throws ResourceInUseException {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6137d327/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
b/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
index d778ed4..c6a0755 100644
--- a/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
+++ b/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
@@ -50,6 +50,8 @@ import com.cloud.dc.dao.PodVlanDaoImpl;
 import com.cloud.dc.dao.PodVlanMapDaoImpl;
 import com.cloud.dc.dao.VlanDaoImpl;
 import com.cloud.domain.dao.DomainDaoImpl;
+import com.cloud.event.EventUtils;
+import com.cloud.event.dao.EventDaoImpl;
 import com.cloud.event.dao.UsageEventDaoImpl;
 import com.cloud.host.dao.HostDaoImpl;
 import com.cloud.host.dao.HostDetailsDaoImpl;
@@ -100,6 +102,7 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.ResourceLimitService;
 import com.cloud.user.UserContext;
 import com.cloud.user.UserContextInitializer;
+import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.AccountDaoImpl;
 import com.cloud.user.dao.UserDaoImpl;
 import com.cloud.utils.component.SpringComponentScanUtils;
@@ -115,7 +118,7 @@ import com.cloud.vm.dao.VMInstanceDaoImpl;
 @Configuration
 @ComponentScan(basePackageClasses = { AccountVlanMapDaoImpl.class, VolumeDaoImpl.class, HostPodDaoImpl.class,
         DomainDaoImpl.class, SwiftDaoImpl.class, ServiceOfferingDaoImpl.class, VlanDaoImpl.class,
-        IPAddressDaoImpl.class, ResourceTagsDaoImpl.class, AccountDaoImpl.class, InstanceGroupDaoImpl.class,
+        IPAddressDaoImpl.class, ResourceTagsDaoImpl.class, InstanceGroupDaoImpl.class,
         UserAccountJoinDaoImpl.class, CapacityDaoImpl.class, SnapshotDaoImpl.class, HostDaoImpl.class,
         VMInstanceDaoImpl.class, HostTransferMapDaoImpl.class, PortForwardingRulesDaoImpl.class,
         PrivateIpDaoImpl.class, UsageEventDaoImpl.class, PodVlanMapDaoImpl.class, DiskOfferingDaoImpl.class,
@@ -126,10 +129,21 @@ import com.cloud.vm.dao.VMInstanceDaoImpl;
         FirewallRulesCidrsDaoImpl.class, PhysicalNetworkDaoImpl.class, PhysicalNetworkTrafficTypeDaoImpl.class,
         PhysicalNetworkServiceProviderDaoImpl.class, LoadBalancerDaoImpl.class, NetworkServiceMapDaoImpl.class,
         PrimaryDataStoreDaoImpl.class, StoragePoolDetailsDaoImpl.class, AffinityGroupServiceImpl.class,
-        ComponentContext.class, AffinityGroupProcessor.class, UserVmVO.class }, includeFilters
= { @Filter(value = AffinityApiTestConfiguration.Library.class, type = FilterType.CUSTOM)
}, useDefaultFilters = false)
+        ComponentContext.class, AffinityGroupProcessor.class, UserVmVO.class, EventUtils.class,
UserVmVO.class,
+        EventDaoImpl.class }, includeFilters = { @Filter(value = AffinityApiTestConfiguration.Library.class,
type = FilterType.CUSTOM) }, useDefaultFilters = false)
 public class AffinityApiTestConfiguration {
 
     @Bean
+    public AccountDao accountDao() {
+        return Mockito.mock(AccountDao.class);
+    }
+
+    @Bean
+    public EventUtils eventUtils() {
+        return Mockito.mock(EventUtils.class);
+    }
+
+    @Bean
     public AffinityGroupProcessor affinityGroupProcessor() {
         return Mockito.mock(AffinityGroupProcessor.class);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6137d327/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
index 17f165d..86cf017 100644
--- a/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
+++ b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
@@ -34,6 +34,7 @@ import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
+import com.cloud.event.EventUtils;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -43,6 +44,7 @@ import com.cloud.user.AccountManagerImpl;
 import com.cloud.user.AccountVO;
 import com.cloud.user.UserContext;
 import com.cloud.user.UserContextInitializer;
+import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachine;
@@ -73,6 +75,12 @@ public class AffinityApiUnitTest {
     @Inject
     AffinityGroupVMMapDao _affinityGroupVMMapDao;
 
+    @Inject
+    EventUtils _eventUtils;
+
+    @Inject
+    AccountDao _accountDao;
+
     private static long domainId = 5L;
 
 
@@ -83,6 +91,7 @@ public class AffinityApiUnitTest {
 
     @Before
     public void testSetUp() {
+        ComponentContext.initComponentsLifeCycle();
         AccountVO acct = new AccountVO(200L);
         acct.setType(Account.ACCOUNT_TYPE_NORMAL);
         acct.setAccountName("user");
@@ -92,6 +101,7 @@ public class AffinityApiUnitTest {
 
         when(_acctMgr.finalizeOwner((Account) anyObject(), anyString(), anyLong(), anyLong())).thenReturn(acct);
         when(_processor.getType()).thenReturn("mock");
+        when(_accountDao.findByIdIncludingRemoved(0L)).thenReturn(acct);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6137d327/server/test/resources/affinityContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/affinityContext.xml b/server/test/resources/affinityContext.xml
index 652905c..15476c1 100644
--- a/server/test/resources/affinityContext.xml
+++ b/server/test/resources/affinityContext.xml
@@ -23,13 +23,18 @@
      <context:annotation-config />
 
     <!-- @DB support -->
-    <aop:config proxy-target-class="true">
-    <aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
-    <aop:pointcut id="captureAnyMethod" expression="execution(* *(..))" />
-
-    <aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod" />
-    </aop:aspect>
-    </aop:config>
+	<bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
+	
+	  <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
+	  <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
+	  <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
+	    <property name="Interceptors">
+	        <list>
+	            <ref bean="transactionContextBuilder" />
+	            <ref bean="actionEventInterceptor" />
+	        </list>
+	    </property>
+	  </bean>
     
 
     <bean id="ConfigurationManager" class="com.cloud.configuration.ConfigurationManagerImpl">
@@ -38,7 +43,5 @@
   
     <bean class="org.apache.cloudstack.affinity.AffinityApiTestConfiguration" />
     
-    <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
-    
 
 </beans>
\ No newline at end of file


Mime
View raw message