cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [17/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 30e2971
Date Fri, 12 Apr 2013 11:58:50 GMT
Adding a unit test for the new affinity groups API


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

Branch: refs/heads/marvin_refactor
Commit: b633dde744057d8fbeb8bfa2b05b04ca8159793a
Parents: ee45437
Author: Prachi Damle <prachi@cloud.com>
Authored: Mon Apr 1 11:08:16 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 13:23:11 2013 -0700

----------------------------------------------------------------------
 .../affinity/AffinityGroupServiceImpl.java         |    5 +-
 .../affinity/AffinityApiTestConfiguration.java     |  318 +++++++++++++++
 .../cloudstack/affinity/AffinityApiUnitTest.java   |  164 ++++++++
 server/test/resources/affinityContext.xml          |   44 ++
 4 files changed, 529 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b633dde7/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 b22ed83..e143db4 100644
--- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
@@ -308,8 +308,9 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro
                 throw new InvalidParameterValueException("Unable to find affinity group by
id " + affinityGroupId);
             }
         }
-        _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds);
-
+        if (affinityGroupIds != null && !affinityGroupIds.isEmpty()) {
+            _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds);
+        }
         // APIResponseHelper will pull out the updated affinitygroups.
         return vmInstance;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b633dde7/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
new file mode 100644
index 0000000..d778ed4
--- /dev/null
+++ b/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java
@@ -0,0 +1,318 @@
+// 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 org.apache.cloudstack.affinity;
+
+import java.io.IOException;
+
+import org.apache.cloudstack.acl.SecurityChecker;
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
+import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.ComponentScan.Filter;
+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.ComponentContext;
+import com.cloud.agent.AgentManager;
+import com.cloud.alert.AlertManager;
+import com.cloud.api.query.dao.UserAccountJoinDaoImpl;
+import com.cloud.capacity.dao.CapacityDaoImpl;
+import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
+import com.cloud.configuration.dao.ConfigurationDao;
+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.dc.dao.VlanDaoImpl;
+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.Ipv6AddressManager;
+import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.NetworkService;
+import com.cloud.network.StorageNetworkManager;
+import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
+import com.cloud.network.dao.FirewallRulesDaoImpl;
+import com.cloud.network.dao.IPAddressDaoImpl;
+import com.cloud.network.dao.LoadBalancerDaoImpl;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkDomainDaoImpl;
+import com.cloud.network.dao.NetworkServiceMapDaoImpl;
+import com.cloud.network.dao.PhysicalNetworkDaoImpl;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
+import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
+import com.cloud.network.dao.UserIpv6AddressDaoImpl;
+import com.cloud.network.element.DhcpServiceProvider;
+import com.cloud.network.element.IpDeployer;
+import com.cloud.network.element.NetworkElement;
+import com.cloud.network.guru.NetworkGuru;
+import com.cloud.network.lb.LoadBalancingRulesManager;
+import com.cloud.network.rules.FirewallManager;
+import com.cloud.network.rules.RulesManager;
+import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl;
+import com.cloud.network.vpc.NetworkACLManager;
+import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
+import com.cloud.network.vpn.RemoteAccessVpnService;
+import com.cloud.offerings.dao.NetworkOfferingDao;
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
+import com.cloud.projects.ProjectManager;
+import com.cloud.service.dao.ServiceOfferingDaoImpl;
+import com.cloud.storage.dao.DiskOfferingDaoImpl;
+import com.cloud.storage.dao.S3DaoImpl;
+import com.cloud.storage.dao.SnapshotDaoImpl;
+import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
+import com.cloud.storage.dao.SwiftDaoImpl;
+import com.cloud.storage.dao.VolumeDaoImpl;
+import com.cloud.storage.s3.S3Manager;
+import com.cloud.storage.secondary.SecondaryStorageVmManager;
+import com.cloud.storage.swift.SwiftManager;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+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.AccountDaoImpl;
+import com.cloud.user.dao.UserDaoImpl;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.vm.UserVmVO;
+import com.cloud.vm.dao.InstanceGroupDaoImpl;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.NicSecondaryIpDaoImpl;
+import com.cloud.vm.dao.UserVmDao;
+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,
+        UserAccountJoinDaoImpl.class, CapacityDaoImpl.class, SnapshotDaoImpl.class, HostDaoImpl.class,
+        VMInstanceDaoImpl.class, HostTransferMapDaoImpl.class, PortForwardingRulesDaoImpl.class,
+        PrivateIpDaoImpl.class, UsageEventDaoImpl.class, PodVlanMapDaoImpl.class, DiskOfferingDaoImpl.class,
+        DataCenterDaoImpl.class, DataCenterIpAddressDaoImpl.class, DataCenterLinkLocalIpAddressDaoImpl.class,
+        DataCenterVnetDaoImpl.class, PodVlanDaoImpl.class, DcDetailsDaoImpl.class, NicSecondaryIpDaoImpl.class,
+        UserIpv6AddressDaoImpl.class, S3DaoImpl.class, UserDaoImpl.class, NicDaoImpl.class,
NetworkDomainDaoImpl.class,
+        HostDetailsDaoImpl.class, HostTagsDaoImpl.class, ClusterDaoImpl.class, FirewallRulesDaoImpl.class,
+        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)
+public class AffinityApiTestConfiguration {
+
+    @Bean
+    public AffinityGroupProcessor affinityGroupProcessor() {
+        return Mockito.mock(AffinityGroupProcessor.class);
+    }
+
+    @Bean
+    public ComponentContext componentContext() {
+        return Mockito.mock(ComponentContext.class);
+    }
+
+
+    @Bean
+    public UserContextInitializer userContextInitializer() {
+        return Mockito.mock(UserContextInitializer.class);
+    }
+
+    @Bean
+    public UserVmVO userVmVO() {
+        return Mockito.mock(UserVmVO.class);
+    }
+
+    @Bean
+    public AffinityGroupDao affinityGroupDao() {
+        return Mockito.mock(AffinityGroupDao.class);
+    }
+
+    @Bean
+    public AffinityGroupVMMapDao affinityGroupVMMapDao() {
+        return Mockito.mock(AffinityGroupVMMapDao.class);
+    }
+
+    @Bean
+    public AccountManager acctMgr() {
+        return Mockito.mock(AccountManager.class);
+    }
+
+    @Bean
+    public NetworkService ntwkSvc() {
+        return Mockito.mock(NetworkService.class);
+    }
+
+    @Bean
+    public NetworkModel ntwkMdl() {
+        return Mockito.mock(NetworkModel.class);
+    }
+
+    @Bean
+    public AlertManager alertMgr() {
+        return Mockito.mock(AlertManager.class);
+    }
+
+    @Bean
+    public SecurityChecker securityChkr() {
+        return Mockito.mock(SecurityChecker.class);
+    }
+
+    @Bean
+    public ResourceLimitService resourceSvc() {
+        return Mockito.mock(ResourceLimitService.class);
+    }
+
+    @Bean
+    public ProjectManager projectMgr() {
+        return Mockito.mock(ProjectManager.class);
+    }
+
+    @Bean
+    public SecondaryStorageVmManager ssvmMgr() {
+        return Mockito.mock(SecondaryStorageVmManager.class);
+    }
+
+    @Bean
+    public SwiftManager swiftMgr() {
+        return Mockito.mock(SwiftManager.class);
+    }
+
+    @Bean
+    public S3Manager s3Mgr() {
+        return Mockito.mock(S3Manager.class);
+    }
+
+    @Bean
+    public VpcManager vpcMgr() {
+        return Mockito.mock(VpcManager.class);
+    }
+
+    @Bean
+    public UserVmDao userVMDao() {
+        return Mockito.mock(UserVmDao.class);
+    }
+
+    @Bean
+    public RulesManager rulesMgr() {
+        return Mockito.mock(RulesManager.class);
+    }
+
+    @Bean
+    public LoadBalancingRulesManager lbRulesMgr() {
+        return Mockito.mock(LoadBalancingRulesManager.class);
+    }
+
+    @Bean
+    public RemoteAccessVpnService vpnMgr() {
+        return Mockito.mock(RemoteAccessVpnService.class);
+    }
+
+    @Bean
+    public NetworkGuru ntwkGuru() {
+        return Mockito.mock(NetworkGuru.class);
+    }
+
+    @Bean
+    public NetworkElement ntwkElement() {
+        return Mockito.mock(NetworkElement.class);
+    }
+
+    @Bean
+    public IpDeployer ipDeployer() {
+        return Mockito.mock(IpDeployer.class);
+    }
+
+    @Bean
+    public DhcpServiceProvider dhcpProvider() {
+        return Mockito.mock(DhcpServiceProvider.class);
+    }
+
+    @Bean
+    public FirewallManager firewallMgr() {
+        return Mockito.mock(FirewallManager.class);
+    }
+
+    @Bean
+    public AgentManager agentMgr() {
+        return Mockito.mock(AgentManager.class);
+    }
+
+    @Bean
+    public StorageNetworkManager storageNtwkMgr() {
+        return Mockito.mock(StorageNetworkManager.class);
+    }
+
+    @Bean
+    public NetworkACLManager ntwkAclMgr() {
+        return Mockito.mock(NetworkACLManager.class);
+    }
+
+    @Bean
+    public Ipv6AddressManager ipv6Mgr() {
+        return Mockito.mock(Ipv6AddressManager.class);
+    }
+
+    @Bean
+    public ConfigurationDao configDao() {
+        return Mockito.mock(ConfigurationDao.class);
+    }
+
+    @Bean
+    public NetworkManager networkManager() {
+        return Mockito.mock(NetworkManager.class);
+    }
+
+    @Bean
+    public NetworkOfferingDao networkOfferingDao() {
+        return Mockito.mock(NetworkOfferingDao.class);
+    }
+
+    @Bean
+    public NetworkDao networkDao() {
+        return Mockito.mock(NetworkDao.class);
+    }
+
+    @Bean
+    public NetworkOfferingServiceMapDao networkOfferingServiceMapDao() {
+        return Mockito.mock(NetworkOfferingServiceMapDao.class);
+    }
+
+    public static class Library implements TypeFilter {
+
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException
{
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = AffinityApiTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(),
cs);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b633dde7/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
new file mode 100644
index 0000000..17f165d
--- /dev/null
+++ b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
@@ -0,0 +1,164 @@
+// 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 org.apache.cloudstack.affinity;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
+import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountManagerImpl;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserContext;
+import com.cloud.user.UserContextInitializer;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.vm.UserVmVO;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.dao.UserVmDao;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = "classpath:/affinityContext.xml")
+public class AffinityApiUnitTest {
+
+    @Inject
+    AffinityGroupServiceImpl _affinityService;
+
+    @Inject
+    AccountManager _acctMgr;
+
+    @Inject
+    AffinityGroupProcessor _processor;
+
+    @Inject
+    AffinityGroupDao _groupDao;
+
+    @Inject
+    UserVmDao _vmDao;
+
+    @Inject
+    AffinityGroupVMMapDao _affinityGroupVMMapDao;
+
+    private static long domainId = 5L;
+
+
+    @BeforeClass
+    public static void setUp() throws ConfigurationException {
+
+    }
+
+    @Before
+    public void testSetUp() {
+        AccountVO acct = new AccountVO(200L);
+        acct.setType(Account.ACCOUNT_TYPE_NORMAL);
+        acct.setAccountName("user");
+        acct.setDomainId(domainId);
+
+        UserContext.registerContext(1, acct, null, true);
+
+        when(_acctMgr.finalizeOwner((Account) anyObject(), anyString(), anyLong(), anyLong())).thenReturn(acct);
+        when(_processor.getType()).thenReturn("mock");
+    }
+
+    @Test
+    public void createAffinityGroupTest() {
+        AffinityGroup group = _affinityService.createAffinityGroup("user", domainId, "group1",
"mock",
+                "affinity group one");
+        assertNotNull("Affinity group 'group1' of type 'mock' failed to create ", group);
+
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void invalidAffinityTypeTest() {
+        AffinityGroup group = _affinityService.createAffinityGroup("user", domainId, "group1",
"invalid",
+                "affinity group one");
+
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void uniqueAffinityNameTest() {
+        when(_groupDao.isNameInUse(anyLong(), anyLong(), eq("group1"))).thenReturn(true);
+        AffinityGroup group2 = _affinityService.createAffinityGroup("user", domainId, "group1",
"mock",
+                "affinity group two");
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void deleteAffinityGroupInvalidIdTest() throws ResourceInUseException {
+        when(_groupDao.findById(20L)).thenReturn(null);
+        _affinityService.deleteAffinityGroup(20L, "user", domainId, "group1");
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void deleteAffinityGroupInvalidIdName() throws ResourceInUseException {
+        when(_groupDao.findByAccountAndName(200L, "group1")).thenReturn(null);
+        _affinityService.deleteAffinityGroup(null, "user", domainId, "group1");
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void deleteAffinityGroupNullIdName() throws ResourceInUseException {
+        _affinityService.deleteAffinityGroup(null, "user", domainId, null);
+    }
+
+    @Test(expected = ResourceInUseException.class)
+    public void deleteAffinityGroupInUse() throws ResourceInUseException {
+        List<AffinityGroupVMMapVO> affinityGroupVmMap = new ArrayList<AffinityGroupVMMapVO>();
+        AffinityGroupVMMapVO mapVO = new AffinityGroupVMMapVO(20L, 10L);
+        affinityGroupVmMap.add(mapVO);
+        when(_affinityGroupVMMapDao.listByAffinityGroup(20L)).thenReturn(affinityGroupVmMap);
+
+        AffinityGroupVO groupVO = new AffinityGroupVO();
+        when(_groupDao.findById(20L)).thenReturn(groupVO);
+        when(_groupDao.lockRow(20L, true)).thenReturn(groupVO);
+
+        _affinityService.deleteAffinityGroup(20L, "user", domainId, null);
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void updateAffinityGroupVMRunning() throws ResourceInUseException {
+
+        UserVmVO vm = new UserVmVO(10L, "test", "test", 101L, HypervisorType.Any, 21L, false,
false, domainId, 200L,
+                5L, "", "test", 1L);
+        vm.setState(VirtualMachine.State.Running);
+        when(_vmDao.findById(10L)).thenReturn(vm);
+
+        List<Long> affinityGroupIds = new ArrayList<Long>();
+        affinityGroupIds.add(20L);
+
+        _affinityService.updateVMAffinityGroups(10L, affinityGroupIds);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b633dde7/server/test/resources/affinityContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/affinityContext.xml b/server/test/resources/affinityContext.xml
new file mode 100644
index 0000000..652905c
--- /dev/null
+++ b/server/test/resources/affinityContext.xml
@@ -0,0 +1,44 @@
+<!-- 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/tx 
+                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+                      http://www.springframework.org/schema/aop
+                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      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>
+    </aop:config>
+    
+
+    <bean id="ConfigurationManager" class="com.cloud.configuration.ConfigurationManagerImpl">
+        <property name="name" value="ConfigurationManager"/>
+    </bean>
+  
+    <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