Updated Branches:
  refs/heads/internallb 4f9c47ce5 -> 63babe4b7

InternalLb:

1) Added unittests for InternalLoadBalancerVMService
2) Added unittests for InternalLoadBalancerElementService


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

Branch: refs/heads/internallb
Commit: 63babe4b7e8baa1027ac66a7d0b505caafc36d5e
Parents: 4f9c47c
Author: Alena Prokharchyk <[email protected]>
Authored: Fri Apr 26 13:44:01 2013 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Fri Apr 26 15:22:19 2013 -0700

----------------------------------------------------------------------
 .../network-elements/internal-loadbalancer/pom.xml |   16 +
 .../element/InternalLoadBalancerElement.java       |   26 +-
 .../network/lb/InternalLoadBalancerVMManager.java  |    3 +-
 .../lb/InternalLoadBalancerVMManagerImpl.java      |    2 +-
 .../ElementChildTestConfiguration.java             |  116 ++++++
 .../internallbvm/InternalLBVMServiceTest.java      |  291 +++++++++++++++
 .../internallbvm/InternalLbElementServiceTest.java |  190 ++++++++++
 .../internallbvm/LbChildTestConfiguration.java     |  164 ++++++++
 .../test/resources/lb_element.xml                  |   46 +++
 .../test/resources/lb_svc.xml                      |   46 +++
 .../cloudstack/lb/ApplicationLoadBalancerTest.java |    4 -
 .../cloudstack/lb/ChildTestConfiguration.java      |   18 -
 12 files changed, 893 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/pom.xml 
b/plugins/network-elements/internal-loadbalancer/pom.xml
index f3c8b37..48e664e 100644
--- a/plugins/network-elements/internal-loadbalancer/pom.xml
+++ b/plugins/network-elements/internal-loadbalancer/pom.xml
@@ -30,5 +30,21 @@
     <defaultGoal>install</defaultGoal>
     <sourceDirectory>src</sourceDirectory>
     <testSourceDirectory>test</testSourceDirectory>
+    <resources>
+      <resource>
+        <directory>resources</directory>
+        <includes>
+          <include>**/*.xml</include>
+        </includes>
+      </resource>
+    </resources>
+    <testResources>
+      <testResource>
+        <directory>test/resources</directory>
+          <excludes>
+              <exclude>%regex[.*[0-9]*To[0-9]*.*Test.*]</exclude>
+          </excludes>
+      </testResource>
+    </testResources>
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
index 04bca16..8ad6af3 100644
--- 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
+++ 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
@@ -103,6 +103,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
     protected InternalLoadBalancerElement() {
     }
     
+    
     public static InternalLoadBalancerElement getInstance() {
         if ( internalLbElement == null) {
             internalLbElement = new InternalLoadBalancerElement();
@@ -110,6 +111,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return internalLbElement;
      }
     
+    
     private boolean canHandle(Network config, Scheme lbScheme) {
         //works in Advance zone only
         DataCenter dc = _configMgr.getZone(config.getDataCenterId());
@@ -141,16 +143,19 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return true;
     }
 
+    
     @Override
     public Map<Service, Map<Capability, String>> getCapabilities() {
         return capabilities;
     }
 
+    
     @Override
     public Provider getProvider() {
         return Provider.InternalLbVm;
     }
 
+    
     @Override
     public boolean implement(Network network, NetworkOffering offering, 
DeployDestination dest, ReservationContext context)
             throws ConcurrentOperationException, ResourceUnavailableException,
@@ -187,6 +192,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return true;
     }
 
+    
     @Override
     public boolean prepare(Network network, NicProfile nic, 
VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, 
ReservationContext context) throws ConcurrentOperationException,
             ResourceUnavailableException, InsufficientCapacityException {
@@ -229,6 +235,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return true;
     }
 
+    
     @Override
     public boolean shutdown(Network network, ReservationContext context, 
boolean cleanup) throws ConcurrentOperationException, 
ResourceUnavailableException {
         List<? extends VirtualRouter> internalLbVms = 
_routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM);
@@ -253,6 +260,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return result;
     }
 
+    
     @Override
     public boolean destroy(Network network, ReservationContext context) throws 
ConcurrentOperationException, ResourceUnavailableException {
         List<? extends VirtualRouter> internalLbVms = 
_routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM);
@@ -267,6 +275,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return result;
     }
 
+    
     @Override
     public boolean isReady(PhysicalNetworkServiceProvider provider) {
         VirtualRouterProviderVO element = 
_vrProviderDao.findByNspIdAndType(provider.getId(), 
@@ -277,6 +286,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return element.isEnabled();
     }
 
+    
     @Override
     public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider 
provider, ReservationContext context)
             throws ConcurrentOperationException, ResourceUnavailableException {
@@ -297,21 +307,25 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return result;
     }
 
+    
     @Override
     public boolean canEnableIndividualServices() {
         return true;
     }
 
+    
     @Override
     public boolean verifyServicesCombination(Set<Service> services) {
         return true;
     }
 
+    
     @Override
     public IpDeployer getIpDeployer(Network network) {
         return this;
     }
 
+    
     @Override
     public boolean applyLBRules(Network network, List<LoadBalancingRule> 
rules) throws ResourceUnavailableException {
         //1) Get Internal LB VMs to destroy
@@ -367,6 +381,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return true;    
     }
 
+    
     protected Map<Ip, List<LoadBalancingRule>> 
getLbRulesToApply(List<LoadBalancingRule> rules) {
         //Group rules by the source ip address as NetworkManager always passes 
the entire network lb config to the element
         Map<Ip, List<LoadBalancingRule>> rulesToApply = groupBySourceIp(rules);
@@ -399,6 +414,7 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         return vmsToDestroy;
     }
 
+    
     protected Map<Ip, List<LoadBalancingRule>> 
groupBySourceIp(List<LoadBalancingRule> rules) {
         Map<Ip, List<LoadBalancingRule>> groupedRules = new HashMap<Ip, 
List<LoadBalancingRule>>();
         for (LoadBalancingRule rule : rules) {
@@ -464,13 +480,12 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
     public VirtualRouterProvider configureInternalLoadBalancerElement(long id, 
boolean enable) {
         VirtualRouterProviderVO element = _vrProviderDao.findById(id);
         if (element == null || element.getType() != 
VirtualRouterProviderType.InternalLbVm) {
-            s_logger.debug("Can't find " + this.getName() + " element with 
network service provider id " + id +
+            throw new InvalidParameterValueException("Can't find " + 
this.getName() + " element with network service provider id " + id +
                     " to be used as a provider for " + this.getName());
-            return null;
         }
 
         element.setEnabled(enable);
-        _vrProviderDao.persist(element);
+        element = _vrProviderDao.persist(element);
 
         return element;
     }
@@ -489,14 +504,15 @@ public class InternalLoadBalancerElement extends 
AdapterBase implements LoadBala
         }
         
         element = new VirtualRouterProviderVO(ntwkSvcProviderId, 
VirtualRouterProviderType.InternalLbVm);
-        _vrProviderDao.persist(element);
+        element = _vrProviderDao.persist(element);
         return element;
     }
 
+    
     @Override
     public VirtualRouterProvider getInternalLoadBalancerElement(long id) {
         VirtualRouterProvider provider = _vrProviderDao.findById(id);
-        if (provider.getType() != VirtualRouterProviderType.InternalLbVm) {
+        if (provider == null || provider.getType() != 
VirtualRouterProviderType.InternalLbVm) {
             throw new InvalidParameterValueException("Unable to find " + 
this.getName() + " by id");
         }
         return provider;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java
 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java
index 4706019..9faca56 100644
--- 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java
+++ 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java
@@ -32,6 +32,7 @@ import com.cloud.utils.net.Ip;
 import com.cloud.vm.VirtualMachineProfile.Param;
 
 public interface InternalLoadBalancerVMManager extends Manager, 
InternalLoadBalancerVMService{
+    //RAM/CPU for the system offering used by Internal LB VMs
     public static final int DEFAULT_INTERNALLB_VM_RAMSIZE = 128;            // 
128 MB
     public static final int DEFAULT_INTERNALLB_VM_CPU_MHZ = 256;            // 
256 MHz
     
@@ -79,7 +80,7 @@ public interface InternalLoadBalancerVMManager extends 
Manager, InternalLoadBala
 
 
     /**
-     * Returns existing Internal Load Balancer elements based on 
guestNetworkId (requried) and requestedIp (optional)
+     * Returns existing Internal Load Balancer elements based on 
guestNetworkId (required) and requestedIp (optional)
      * @param guestNetworkId
      * @param requestedGuestIp
      * @return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index e9c4afb..1456ecb 100644
--- 
a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ 
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -550,7 +550,7 @@ InternalLoadBalancerVMManager, 
VirtualMachineGuru<DomainRouterVO> {
     ResourceUnavailableException {
         DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId);
         if (internalLbVm == null || internalLbVm.getRole() != 
Role.INTERNAL_LB_VM) {
-            throw new InvalidParameterValueException("Can't find internal lb 
vm by id");
+            throw new InvalidParameterValueException("Can't find internal lb 
vm by id specified");
         }
         
         return stopInternalLbVm(internalLbVm, forced, caller, callerUserId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/ElementChildTestConfiguration.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/ElementChildTestConfiguration.java
 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/ElementChildTestConfiguration.java
new file mode 100644
index 0000000..6d55060
--- /dev/null
+++ 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/ElementChildTestConfiguration.java
@@ -0,0 +1,116 @@
+// 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.internallbvm;
+
+import java.io.IOException;
+
+import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
+import org.apache.cloudstack.network.lb.dao.ApplicationLoadBalancerRuleDao;
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.configuration.ConfigurationManager;
+import com.cloud.dc.dao.AccountVlanMapDaoImpl;
+import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.VirtualRouterProviderDao;
+import com.cloud.user.AccountManager;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.dao.DomainRouterDao;
+
+@Configuration
+@ComponentScan(
+    basePackageClasses={
+        AccountVlanMapDaoImpl.class
+    },
+    includeFilters={@Filter(value=ElementChildTestConfiguration.Library.class, 
type=FilterType.CUSTOM)},
+    useDefaultFilters=false
+    )
+
+public class ElementChildTestConfiguration {
+    public static class Library implements TypeFilter { 
+        @Bean
+        public AccountManager accountManager() {
+            return Mockito.mock(AccountManager.class);
+        }
+        
+       
+        @Bean
+        public DomainRouterDao domainRouterDao() {
+            return Mockito.mock(DomainRouterDao.class);
+        }
+        
+        @Bean
+        public VirtualRouterProviderDao virtualRouterProviderDao() {
+            return Mockito.mock(VirtualRouterProviderDao.class);
+        }
+        
+        @Bean
+        public NetworkModel networkModel() {
+            return Mockito.mock(NetworkModel.class);
+        }
+        
+        
+        @Bean
+        public NetworkManager networkManager() {
+            return Mockito.mock(NetworkManager.class);
+        }
+
+        
+        @Bean
+        public PhysicalNetworkServiceProviderDao 
physicalNetworkServiceProviderDao() {
+            return Mockito.mock(PhysicalNetworkServiceProviderDao.class);
+        }
+        
+        @Bean
+        public NetworkServiceMapDao networkServiceMapDao() {
+            return Mockito.mock(NetworkServiceMapDao.class);
+        }
+        
+        @Bean
+        public InternalLoadBalancerVMManager internalLoadBalancerVMManager() {
+            return Mockito.mock(InternalLoadBalancerVMManager.class);
+        }
+        
+        @Bean
+        public ConfigurationManager confugurationManager() {
+            return Mockito.mock(ConfigurationManager.class);
+        }
+        
+        
+        @Bean
+        public ApplicationLoadBalancerRuleDao applicationLoadBalancerRuleDao() 
{
+            return Mockito.mock(ApplicationLoadBalancerRuleDao.class);
+        }
+        
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) 
throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = 
ElementChildTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return 
SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(),
 cs);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLBVMServiceTest.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLBVMServiceTest.java
 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLBVMServiceTest.java
new file mode 100644
index 0000000..f271311
--- /dev/null
+++ 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLBVMServiceTest.java
@@ -0,0 +1,291 @@
+// 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.internallbvm;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import junit.framework.TestCase;
+
+import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.OperationTimedoutException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.vm.DomainRouterVO;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.DomainRouterDao;
+
+/**
+ * Set of unittests for InternalLoadBalancerVMService
+ *
+ */
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations="classpath:/lb_svc.xml")
+@SuppressWarnings("unchecked")
+public class InternalLBVMServiceTest extends TestCase {
+    //The interface to test
+    @Inject InternalLoadBalancerVMService _lbVmSvc;
+    
+    //Mocked interfaces
+    @Inject AccountManager _accountMgr;
+    @Inject ServiceOfferingDao _svcOffDao;
+    @Inject DomainRouterDao _domainRouterDao;
+    @Inject VirtualMachineManager _itMgr;
+    
+    long validVmId = 1L;
+    long nonExistingVmId = 2L;
+    long nonInternalLbVmId = 3L;
+    
+    @Before
+    public void setUp() {
+        //mock system offering creation as it's used by configure() method 
called by initComponentsLifeCycle
+        Mockito.when(_accountMgr.getAccount(1L)).thenReturn(new AccountVO());
+        ServiceOfferingVO off = new ServiceOfferingVO("alena", 1, 1,
+                1, 1, 1, false, "alena", false, false, null, false, 
VirtualMachine.Type.InternalLoadBalancerVm, false);
+        off = setId(off, 1);
+        
Mockito.when(_svcOffDao.persistSystemServiceOffering(Mockito.any(ServiceOfferingVO.class))).thenReturn(off);
+        
+        ComponentContext.initComponentsLifeCycle();
+        
+        DomainRouterVO validVm = new 
DomainRouterVO(validVmId,off.getId(),1,"alena",1,HypervisorType.XenServer,1,1,1,
+                false, 0,false,null,false,false,
+                VirtualMachine.Type.InternalLoadBalancerVm, null);
+        validVm.setRole(Role.INTERNAL_LB_VM);
+        DomainRouterVO nonInternalLbVm = new 
DomainRouterVO(validVmId,off.getId(),1,"alena",1,HypervisorType.XenServer,1,1,1,
+                false, 0,false,null,false,false,
+                VirtualMachine.Type.DomainRouter, null);
+        nonInternalLbVm.setRole(Role.VIRTUAL_ROUTER);
+        
+        Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm);
+        
Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null);
+        
Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm);
+        
+        try {
+            Mockito.when(_itMgr.start(Mockito.any(DomainRouterVO.class),
+                    Mockito.any(Map.class), Mockito.any(User.class), 
Mockito.any(Account.class), 
Mockito.any(DeploymentPlan.class))).thenReturn(validVm);
+        } catch (InsufficientCapacityException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        try {
+            Mockito.when(_itMgr.advanceStop(Mockito.any(DomainRouterVO.class), 
Mockito.any(Boolean.class), Mockito.any(User.class), 
Mockito.any(Account.class))).thenReturn(true);
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (OperationTimedoutException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+    }
+    
+    //TESTS FOR START COMMAND
+    
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void startNonExistingVm() {
+        String expectedExcText = null;
+        try {
+            _lbVmSvc.startInternalLbVm(nonExistingVmId, 
_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InsufficientCapacityException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The non-existing internal lb vm was 
attempted to start"
+        + expectedExcText, expectedExcText, "Can't find internal lb vm by id 
specified");
+        }
+    }
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void startNonInternalLbVmVm() {
+        String expectedExcText = null;
+        try {
+            _lbVmSvc.startInternalLbVm(nonInternalLbVmId, 
_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InsufficientCapacityException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The existing vm of not Internal lb vm 
type was attempted to start"
+        + expectedExcText, expectedExcText, "Can't find internal lb vm by id 
specified");
+        }
+    }
+    
+    @Test
+    public void startValidLbVmVm() {
+        VirtualRouter vr = null;
+        try {
+            vr = _lbVmSvc.startInternalLbVm(validVmId, 
_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InsufficientCapacityException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            assertNotNull("Internal LB vm is null which means it failed to 
start " + vr, vr);
+        }
+    }
+    
+    
+    //TEST FOR STOP COMMAND
+    @Test (expected = InvalidParameterValueException.class)
+    public void stopNonExistingVm() {
+        String expectedExcText = null;
+        try {
+            _lbVmSvc.stopInternalLbVm(nonExistingVmId, 
false,_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The non-existing internal lb vm was 
attempted to stop"
+        + expectedExcText, expectedExcText, "Can't find internal lb vm by id 
specified");
+        }
+    }
+    
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void stopNonInternalLbVmVm() {
+        String expectedExcText = null;
+        try {
+            _lbVmSvc.stopInternalLbVm(nonInternalLbVmId, false, 
_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The existing vm of not Internal lb vm 
type was attempted to stop"
+        + expectedExcText, expectedExcText, "Can't find internal lb vm by id 
specified");
+        }
+    }
+    
+    
+    @Test
+    public void stopValidLbVmVm() {
+        VirtualRouter vr = null;
+        try {
+            vr = _lbVmSvc.stopInternalLbVm(validVmId, false, 
_accountMgr.getAccount(1L), 1L);
+        } catch (StorageUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ConcurrentOperationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ResourceUnavailableException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            assertNotNull("Internal LB vm is null which means it failed to 
stop " + vr, vr);
+        }
+    }
+    
+    
+    
+    private static ServiceOfferingVO setId(ServiceOfferingVO vo, long id) {
+        ServiceOfferingVO voToReturn = vo;
+        Class<?> c = voToReturn.getClass();
+        try {
+            Field f = c.getSuperclass().getDeclaredField("id");
+            f.setAccessible(true);
+            f.setLong(voToReturn, id);
+        } catch (NoSuchFieldException ex) {
+           return null;
+        } catch (IllegalAccessException ex) {
+            return null;
+        }
+        
+        return voToReturn;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLbElementServiceTest.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLbElementServiceTest.java
 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLbElementServiceTest.java
new file mode 100644
index 0000000..c2d311d
--- /dev/null
+++ 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/InternalLbElementServiceTest.java
@@ -0,0 +1,190 @@
+// 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.internallbvm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.inject.Inject;
+
+import 
org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
+import com.cloud.network.dao.VirtualRouterProviderDao;
+import com.cloud.network.element.VirtualRouterProviderVO;
+import com.cloud.user.AccountManager;
+import com.cloud.utils.component.ComponentContext;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations="classpath:/lb_element.xml")
+public class InternalLbElementServiceTest {
+    //The interface to test
+    @Inject InternalLoadBalancerElementService _lbElSvc;
+    
+    //Mocked interfaces
+    @Inject AccountManager _accountMgr;
+    @Inject VirtualRouterProviderDao _vrProviderDao;
+    @Inject PhysicalNetworkServiceProviderDao _pNtwkProviderDao;
+    
+    long validElId = 1L;
+    long nonExistingElId = 2L;
+    long invalidElId = 3L; //not of VirtualRouterProviderType
+    
+    long validProviderId = 1L;
+    long nonExistingProviderId = 2L;
+    long invalidProviderId = 3L;
+        
+
+    @Before
+    public void setUp() {
+        
+        ComponentContext.initComponentsLifeCycle();
+        VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, 
VirtualRouterProviderType.InternalLbVm);
+        VirtualRouterProviderVO invalidElement = new 
VirtualRouterProviderVO(1, VirtualRouterProviderType.VirtualRouter);
+        
+        
Mockito.when(_vrProviderDao.findById(validElId)).thenReturn(validElement);
+        
Mockito.when(_vrProviderDao.findById(invalidElId)).thenReturn(invalidElement);
+        
+        
Mockito.when(_vrProviderDao.persist(validElement)).thenReturn(validElement);
+        
+        Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, 
VirtualRouterProviderType.InternalLbVm)).thenReturn(validElement);
+        
+        PhysicalNetworkServiceProviderVO validProvider = new 
PhysicalNetworkServiceProviderVO(1, "InternalLoadBalancerElement");
+        PhysicalNetworkServiceProviderVO invalidProvider = new 
PhysicalNetworkServiceProviderVO(1, "Invalid name!");
+
+        
Mockito.when(_pNtwkProviderDao.findById(validProviderId)).thenReturn(validProvider);
+        
Mockito.when(_pNtwkProviderDao.findById(invalidProviderId)).thenReturn(invalidProvider);
+        
+        
Mockito.when(_vrProviderDao.persist(Mockito.any(VirtualRouterProviderVO.class))).thenReturn(validElement);
 
+    }
+    
+    //TESTS FOR getInternalLoadBalancerElement METHOD
+    
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void findNonExistingVm() {
+        String expectedExcText = null;
+        try {
+            _lbElSvc.getInternalLoadBalancerElement(nonExistingElId); 
+        } catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The non-existing intenral lb provider 
was found"
+        + expectedExcText, expectedExcText, "Unable to find 
InternalLoadBalancerElementService by id");
+        }
+    }
+    
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void findInvalidVm() {
+        String expectedExcText = null;
+        try {
+            _lbElSvc.getInternalLoadBalancerElement(invalidElId); 
+        } catch (InvalidParameterValueException e) {
+            expectedExcText = e.getMessage();
+            throw e;
+        } finally {
+            assertEquals("Test failed. The non-existing intenral lb provider 
was found"
+                    + expectedExcText, expectedExcText, "Unable to find 
InternalLoadBalancerElementService by id");
+        }
+    }
+    
+    
+    @Test
+    public void findValidVm() {
+        VirtualRouterProvider provider = null;
+        try {
+            provider = _lbElSvc.getInternalLoadBalancerElement(validElId); 
+        } finally {
+            assertNotNull("Test failed. Couldn't find the VR provider by the 
valid id",provider); 
+        }
+    }
+    
+    
+    //TESTS FOR configureInternalLoadBalancerElement METHOD
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void configureNonExistingVm() {
+        
+        _lbElSvc.configureInternalLoadBalancerElement(nonExistingElId, true); 
+        
+    }
+    
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void ConfigureInvalidVm() {
+        _lbElSvc.configureInternalLoadBalancerElement(invalidElId, true);    
+    }
+    
+    
+    @Test
+    public void enableProvider() {
+        VirtualRouterProvider provider = null;
+        try {
+            provider = 
_lbElSvc.configureInternalLoadBalancerElement(validElId, true); 
+        } finally {
+            assertNotNull("Test failed. Couldn't find the VR provider by the 
valid id ",provider);
+            assertTrue("Test failed. The provider wasn't eanbled ", 
provider.isEnabled()); 
+        }
+    }
+    
+    @Test
+    public void disableProvider() {
+        VirtualRouterProvider provider = null;
+        try {
+            provider = 
_lbElSvc.configureInternalLoadBalancerElement(validElId, false); 
+        } finally {
+            assertNotNull("Test failed. Couldn't find the VR provider by the 
valid id ",provider);
+            assertFalse("Test failed. The provider wasn't disabled ", 
provider.isEnabled()); 
+        }
+    } 
+    
+    //TESTS FOR addInternalLoadBalancerElement METHOD
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void addToNonExistingProvider() {
+        
+        _lbElSvc.addInternalLoadBalancerElement(nonExistingProviderId); 
+        
+    }
+    
+    @Test (expected = InvalidParameterValueException.class)
+    public void addToInvalidProvider() {
+        _lbElSvc.addInternalLoadBalancerElement(invalidProviderId);   
+    }
+    
+    @Test
+    public void addToExistingProvider() {
+        _lbElSvc.addInternalLoadBalancerElement(validProviderId);
+    }
+
+}
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/LbChildTestConfiguration.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/LbChildTestConfiguration.java
 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/LbChildTestConfiguration.java
new file mode 100644
index 0000000..bdad5f4
--- /dev/null
+++ 
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvm/LbChildTestConfiguration.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.internallbvm;
+
+import java.io.IOException;
+
+import org.apache.cloudstack.network.lb.dao.ApplicationLoadBalancerRuleDao;
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.dc.dao.AccountVlanMapDaoImpl;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.dao.VirtualRouterProviderDao;
+import com.cloud.network.lb.LoadBalancingRulesManager;
+import com.cloud.offerings.dao.NetworkOfferingDao;
+import com.cloud.resource.ResourceManager;
+import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.user.AccountManager;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.DomainRouterDao;
+import com.cloud.vm.dao.NicDao;
+
+@Configuration
+@ComponentScan(
+    basePackageClasses={
+        AccountVlanMapDaoImpl.class
+    },
+    includeFilters={@Filter(value=LbChildTestConfiguration.Library.class, 
type=FilterType.CUSTOM)},
+    useDefaultFilters=false
+    )
+
+    public class LbChildTestConfiguration {
+        
+        public static class Library implements TypeFilter {
+            
+          
+            @Bean
+            public AccountManager accountManager() {
+                return Mockito.mock(AccountManager.class);
+            }
+            
+            @Bean
+            public VirtualMachineManager virtualMachineManager() {
+                return Mockito.mock(VirtualMachineManager.class);
+            }
+            
+            @Bean
+            public DomainRouterDao domainRouterDao() {
+                return Mockito.mock(DomainRouterDao.class);
+            }
+            
+            @Bean
+            public ConfigurationDao configurationDao() {
+                return Mockito.mock(ConfigurationDao.class);
+            }
+            
+            @Bean
+            public VirtualRouterProviderDao virtualRouterProviderDao() {
+                return Mockito.mock(VirtualRouterProviderDao.class);
+            }
+            
+            @Bean
+            public ApplicationLoadBalancerRuleDao 
applicationLoadBalancerRuleDao() {
+                return Mockito.mock(ApplicationLoadBalancerRuleDao.class);
+            }
+            
+            @Bean
+            public NetworkModel networkModel() {
+                return Mockito.mock(NetworkModel.class);
+            }
+            
+            @Bean
+            public LoadBalancingRulesManager loadBalancingRulesManager() {
+                return Mockito.mock(LoadBalancingRulesManager.class);
+            }
+            
+            @Bean
+            public NicDao nicDao() {
+                return Mockito.mock(NicDao.class);
+            }
+            
+            @Bean
+            public NetworkDao networkDao() {
+                return Mockito.mock(NetworkDao.class);
+            }
+            
+            @Bean
+            public NetworkManager networkManager() {
+                return Mockito.mock(NetworkManager.class);
+            }
+            
+            @Bean
+            public ServiceOfferingDao serviceOfferingDao() {
+                return Mockito.mock(ServiceOfferingDao.class);
+            }
+            
+            @Bean
+            public PhysicalNetworkServiceProviderDao 
physicalNetworkServiceProviderDao() {
+                return Mockito.mock(PhysicalNetworkServiceProviderDao.class);
+            }
+            
+            @Bean
+            public NetworkOfferingDao networkOfferingDao() {
+                return Mockito.mock(NetworkOfferingDao.class);
+            }
+            
+            @Bean
+            public VMTemplateDao vmTemplateDao() {
+                return Mockito.mock(VMTemplateDao.class);
+            }
+            
+            @Bean
+            public ResourceManager resourceManager() {
+                return Mockito.mock(ResourceManager.class);
+            }
+            
+            @Bean
+            public AgentManager agentManager() {
+                return Mockito.mock(AgentManager.class);
+            }
+            
+            @Bean
+            public DataCenterDao dataCenterDao() {
+                return Mockito.mock(DataCenterDao.class);
+            }
+            
+            @Override
+            public boolean match(MetadataReader mdr, MetadataReaderFactory 
arg1) throws IOException {
+                mdr.getClassMetadata().getClassName();
+                ComponentScan cs = 
LbChildTestConfiguration.class.getAnnotation(ComponentScan.class);
+                return 
SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(),
 cs);
+            }
+    
+        }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/resources/lb_element.xml
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/resources/lb_element.xml 
b/plugins/network-elements/internal-loadbalancer/test/resources/lb_element.xml
new file mode 100644
index 0000000..362bce1
--- /dev/null
+++ 
b/plugins/network-elements/internal-loadbalancer/test/resources/lb_element.xml
@@ -0,0 +1,46 @@
+<!-- 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 -->
+      
+  <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="InternalLoadBalancerElementService" 
class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
+        <property name="name" value="InternalLoadBalancerElementService"/>
+    </bean>
+  
+    <bean 
class="org.apache.cloudstack.internallbvm.ElementChildTestConfiguration" />
+    
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/plugins/network-elements/internal-loadbalancer/test/resources/lb_svc.xml
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/internal-loadbalancer/test/resources/lb_svc.xml 
b/plugins/network-elements/internal-loadbalancer/test/resources/lb_svc.xml
new file mode 100644
index 0000000..40aef57
--- /dev/null
+++ b/plugins/network-elements/internal-loadbalancer/test/resources/lb_svc.xml
@@ -0,0 +1,46 @@
+<!-- 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 -->
+      
+  <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="InternalLoadBalancerVMService" 
class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl">
+        <property name="name" value="InternalLoadBalancerVMService"/>
+    </bean>
+  
+    <bean class="org.apache.cloudstack.internallbvm.LbChildTestConfiguration" 
/>
+    
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/server/test/org/apache/cloudstack/lb/ApplicationLoadBalancerTest.java
----------------------------------------------------------------------
diff --git 
a/server/test/org/apache/cloudstack/lb/ApplicationLoadBalancerTest.java 
b/server/test/org/apache/cloudstack/lb/ApplicationLoadBalancerTest.java
index e18a461..730cb99 100644
--- a/server/test/org/apache/cloudstack/lb/ApplicationLoadBalancerTest.java
+++ b/server/test/org/apache/cloudstack/lb/ApplicationLoadBalancerTest.java
@@ -17,9 +17,7 @@
 package org.apache.cloudstack.lb;
 
 import java.lang.reflect.Field;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import javax.inject.Inject;
@@ -31,7 +29,6 @@ import 
org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRuleVO;
 import org.apache.cloudstack.network.lb.dao.ApplicationLoadBalancerRuleDao;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
@@ -55,7 +52,6 @@ import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.LoadBalancerContainer.Scheme;
-import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.UserContext;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63babe4b/server/test/org/apache/cloudstack/lb/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/lb/ChildTestConfiguration.java 
b/server/test/org/apache/cloudstack/lb/ChildTestConfiguration.java
index 34eb477..60dfb6e 100644
--- a/server/test/org/apache/cloudstack/lb/ChildTestConfiguration.java
+++ b/server/test/org/apache/cloudstack/lb/ChildTestConfiguration.java
@@ -30,8 +30,6 @@ import 
org.springframework.core.type.classreading.MetadataReaderFactory;
 import org.springframework.core.type.filter.TypeFilter;
 
 import com.cloud.dc.dao.AccountVlanMapDaoImpl;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.event.UsageEventUtils;
 import com.cloud.event.dao.UsageEventDao;
 import com.cloud.network.NetworkManager;
 import com.cloud.network.NetworkModel;
@@ -39,7 +37,6 @@ import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.user.AccountManager;
-import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.component.SpringComponentScanUtils;
 
 @Configuration
@@ -90,26 +87,11 @@ import com.cloud.utils.component.SpringComponentScanUtils;
                 return Mockito.mock(NetworkManager.class);
             }
             
-//            @Bean
-//            public UsageEventUtils UsageEventUtils() {
-//                return Mockito.mock(UsageEventUtils.class);
-//            }
-            
             @Bean
             public UsageEventDao UsageEventDao() {
                 return Mockito.mock(UsageEventDao.class);
             }
             
-//            @Bean
-//            public AccountDao accountDao() {
-//                return Mockito.mock(AccountDao.class);
-//            }
-//            
-//            @Bean
-//            public DataCenterDao dataCenterDao() {
-//                return Mockito.mock(DataCenterDao.class);
-//            }
-    
             @Override
             public boolean match(MetadataReader mdr, MetadataReaderFactory 
arg1) throws IOException {
                 mdr.getClassMetadata().getClassName();

Reply via email to