You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/03/30 17:56:42 UTC
[29/50] [abbrv] git commit: updated refs/heads/marvin-refactor to
5ce2643
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/4fb88f0f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4fb88f0f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4fb88f0f
Branch: refs/heads/marvin-refactor
Commit: 4fb88f0f6133c012f5a9a1e970fb7de051f34849
Parents: abd11d5
Author: Kelven Yang <ke...@gmail.com>
Authored: Fri Mar 29 11:01:40 2013 -0700
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Mar 30 22:21:55 2013 +0530
----------------------------------------------------------------------
.../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 | 20 ++++++-----
server/test/resources/testContext.xml | 27 +++++---------
9 files changed, 99 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4fb88f0f/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 dba3a9c..5b236a5 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/4fb88f0f/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/4fb88f0f/server/test/resources/SecurityGroupManagerTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/SecurityGroupManagerTestContext.xml b/server/test/resources/SecurityGroupManagerTestContext.xml
index b36599e..fc4b23e 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/4fb88f0f/server/test/resources/SnapshotDaoTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/SnapshotDaoTestContext.xml b/server/test/resources/SnapshotDaoTestContext.xml
index e479e2e..ac7c8a1 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/4fb88f0f/server/test/resources/StoragePoolDaoTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/StoragePoolDaoTestContext.xml b/server/test/resources/StoragePoolDaoTestContext.xml
index 4936a83..55d9623 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/4fb88f0f/server/test/resources/VpcApiUnitTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/VpcApiUnitTestContext.xml b/server/test/resources/VpcApiUnitTestContext.xml
index d933022..c9dda1a 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/4fb88f0f/server/test/resources/VpcTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/VpcTestContext.xml b/server/test/resources/VpcTestContext.xml
index 7ed5f57..2a52ae3 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/4fb88f0f/server/test/resources/createNetworkOffering.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/createNetworkOffering.xml b/server/test/resources/createNetworkOffering.xml
index 90532b3..1f31205 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(* *(..))" />
- <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">
<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/4fb88f0f/server/test/resources/testContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/testContext.xml b/server/test/resources/testContext.xml
index b260386..c363955 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" />
<!--