cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [09/10] git commit: updated refs/heads/master to 5782abf
Date Fri, 29 Mar 2013 18:36:44 GMT
Update unit test configuraitons to new custom Spring AOP


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

Branch: refs/heads/master
Commit: 5782abf8f80fce929e3d6e20068bc165f2360426
Parents: 2654e64
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri Mar 29 11:01:40 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri Mar 29 11:12:36 2013 -0700

----------------------------------------------------------------------
 .../networkoffering/CreateNetworkOfferingTest.java |   15 +++++++-
 .../test/resources/CloneSettingDaoTestContext.xml  |   20 ++++++-----
 .../resources/SecurityGroupManagerTestContext.xml  |   19 +++++-----
 server/test/resources/SnapshotDaoTestContext.xml   |   20 ++++++-----
 .../test/resources/StoragePoolDaoTestContext.xml   |   20 ++++++-----
 server/test/resources/VpcApiUnitTestContext.xml    |   20 ++++++-----
 server/test/resources/VpcTestContext.xml           |   21 ++++++-----
 server/test/resources/createNetworkOffering.xml    |   22 ++++++-----
 server/test/resources/testContext.xml              |   27 +++++---------
 9 files changed, 100 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
index 1353959..67fae33 100644
--- a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
+++ b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
@@ -46,7 +46,12 @@ import com.cloud.offerings.NetworkOfferingServiceMapVO;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserContext;
 import com.cloud.user.UserContextInitializer;
+import com.cloud.user.UserVO;
+import com.cloud.utils.component.ComponentContext;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations="classpath:/createNetworkOffering.xml")
@@ -63,18 +68,24 @@ public class CreateNetworkOfferingTest extends TestCase{
     NetworkOfferingDao offDao;
     
     @Inject
-    UserContextInitializer usrCtxInit;
+    NetworkOfferingServiceMapDao mapDao;
     
     @Inject
-    NetworkOfferingServiceMapDao mapDao;
+    AccountManager accountMgr;
     
     @Before
     public void setUp() {
+    	ComponentContext.initComponentsLifeCycle();
+    	
         ConfigurationVO configVO = new ConfigurationVO("200", "200","200","200","200","200");
         Mockito.when(configDao.findByName(Mockito.anyString())).thenReturn(configVO);
         
         Mockito.when(offDao.persist(Mockito.any(NetworkOfferingVO.class))).thenReturn(new
NetworkOfferingVO());
         Mockito.when(mapDao.persist(Mockito.any(NetworkOfferingServiceMapVO.class))).thenReturn(new
NetworkOfferingServiceMapVO());
+        Mockito.when(accountMgr.getSystemUser()).thenReturn(new UserVO(1));
+        Mockito.when(accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
+
+        UserContext.registerContext(accountMgr.getSystemUser().getId(), accountMgr.getSystemAccount(),
null, false);
     }
 
     //Test Shared network offerings

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/CloneSettingDaoTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/CloneSettingDaoTestContext.xml b/server/test/resources/CloneSettingDaoTestContext.xml
index 1d13500..cb35004 100644
--- a/server/test/resources/CloneSettingDaoTestContext.xml
+++ b/server/test/resources/CloneSettingDaoTestContext.xml
@@ -23,17 +23,19 @@
   <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="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+  <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="CSTestConfiguration"
     class="com.cloud.vm.dao.UserVmCloneSettingDaoTestConfiguration" />
   <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"
>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/SecurityGroupManagerTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/SecurityGroupManagerTestContext.xml b/server/test/resources/SecurityGroupManagerTestContext.xml
index b36599e..7ff2976 100644
--- a/server/test/resources/SecurityGroupManagerTestContext.xml
+++ b/server/test/resources/SecurityGroupManagerTestContext.xml
@@ -23,17 +23,16 @@
   <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="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+  <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
+    <property name="Interceptors">
+        <list>
+            <ref bean="transactionContextBuilder" />
+        </list>
+    </property>
+  </bean>
+
   <bean id="TestConfiguration"
     class="com.cloud.network.security.SecurityGroupManagerTestConfiguration" />
   <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/SnapshotDaoTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/SnapshotDaoTestContext.xml b/server/test/resources/SnapshotDaoTestContext.xml
index e479e2e..3b87888 100644
--- a/server/test/resources/SnapshotDaoTestContext.xml
+++ b/server/test/resources/SnapshotDaoTestContext.xml
@@ -23,17 +23,19 @@
   <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="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+  <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="TestConfiguration" 
     class="com.cloud.snapshot.SnapshotDaoTestConfiguration" />
   <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"
>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/StoragePoolDaoTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/StoragePoolDaoTestContext.xml b/server/test/resources/StoragePoolDaoTestContext.xml
index 4936a83..345827e 100644
--- a/server/test/resources/StoragePoolDaoTestContext.xml
+++ b/server/test/resources/StoragePoolDaoTestContext.xml
@@ -23,17 +23,19 @@
   <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="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+  <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="TestConfiguration" 
     class="com.cloud.storage.dao.StoragePoolDaoTestConfiguration" />
   <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"
>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/VpcApiUnitTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/VpcApiUnitTestContext.xml b/server/test/resources/VpcApiUnitTestContext.xml
index d933022..1dc1122 100644
--- a/server/test/resources/VpcApiUnitTestContext.xml
+++ b/server/test/resources/VpcApiUnitTestContext.xml
@@ -24,17 +24,19 @@
   <context:component-scan base-package="org.apache.cloudstack, com.cloud" />
 
   <!-- @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="componentContext" class="com.cloud.utils.component.ComponentContext"/>
+  <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 class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor">
     <property name="requiredParameterValue" value="false" />
   </bean>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/VpcTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/VpcTestContext.xml b/server/test/resources/VpcTestContext.xml
index 7ed5f57..5303736 100644
--- a/server/test/resources/VpcTestContext.xml
+++ b/server/test/resources/VpcTestContext.xml
@@ -21,15 +21,20 @@
                       http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
   <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>
+    <!-- @DB support -->
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
 
-  </aop:config>
+  <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>
 
   <!--
       Network Elements
@@ -66,8 +71,6 @@
     <property name="name" value="PrivateNetworkGuru"/>
   </bean>
   
-  <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
-  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
   <bean id="TestConfiguration"
     class="com.cloud.vpc.VpcTestConfiguration" />
   <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/createNetworkOffering.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/createNetworkOffering.xml b/server/test/resources/createNetworkOffering.xml
index f3faaa8..90342c5 100644
--- a/server/test/resources/createNetworkOffering.xml
+++ b/server/test/resources/createNetworkOffering.xml
@@ -23,14 +23,19 @@
      <context:annotation-config />
 
     <!-- @DB support -->
-    <aop:config proxy-target-class="true">
-    <aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
-    <aop:pointcut id="captureAnyMethod" expression="execution(* *(..))" />
+      
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
 
-    <aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod" />
-    </aop:aspect>
-    </aop:config>
-    
+  <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">
         <property name="name" value="ConfigurationManager"/>
@@ -38,7 +43,4 @@
   
     <bean class="org.apache.cloudstack.networkoffering.ChildTestConfiguration" />
     
-    <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
-    
-
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5782abf8/server/test/resources/testContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/testContext.xml b/server/test/resources/testContext.xml
index b260386..6a21198 100644
--- a/server/test/resources/testContext.xml
+++ b/server/test/resources/testContext.xml
@@ -37,26 +37,19 @@
   <!--
     @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>
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
 
-    <aop:aspect id="actionEventInterceptorAspect" ref="actionEventInterceptor">
-        <aop:pointcut id="captureEventMethod"
-            expression="execution(* *(..)) and @annotation(com.cloud.event.ActionEvent)"

-        />
-        <aop:around pointcut-ref="captureEventMethod" method="AroundAnyMethod"/> 
-    </aop:aspect>
-
-  </aop:config>
-  
   <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 class="com.cloud.network.security.SecurityGroupManagerTestConfiguration" />
 
   <!--


Mime
View raw message