Update unit test configuraitons to new custom Spring AOP

This commit is contained in:
Kelven Yang 2013-03-29 11:01:40 -07:00
parent 2654e645c7
commit 5782abf8f8
9 changed files with 100 additions and 84 deletions

View File

@ -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

View File

@ -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" >

View File

@ -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">

View File

@ -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" >

View File

@ -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" >

View File

@ -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>

View File

@ -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(* *(..))" />
<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>
<!--
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">

View File

@ -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>

View File

@ -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" />
<!--