cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [1/16] git commit: Network-refactor: verify that s2s provider gets injected as expected
Date Wed, 09 Jan 2013 23:50:01 GMT
Network-refactor: verify that s2s provider gets injected as expected

Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>


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

Branch: refs/heads/network-refactor
Commit: a34ce77b77954213e3fc67ead808322e42a21517
Parents: 0c30015
Author: Chiradeep Vittal <chiradeep@apache.org>
Authored: Tue Jan 8 17:11:59 2013 -0800
Committer: Chiradeep Vittal <chiradeep@apache.org>
Committed: Wed Jan 9 15:49:01 2013 -0800

----------------------------------------------------------------------
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |    1 +
 .../cloud/vpc/MockSite2SiteVpnServiceProvider.java |   86 +++++++++++++++
 server/test/com/cloud/vpc/Site2SiteVpnTest.java    |   82 ++++++++++++++
 3 files changed, 169 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a34ce77b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index 9d0f89f..8c1ebe5 100644
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@ -108,6 +108,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager
{
         Map<String, String> configs = configDao.getConfiguration(params);
         _connLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnConnectionPerVpnGatewayLimit.key()),
4);
         _subnetsLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnSubnetsPerCustomerGatewayLimit.key()),
10);
+        assert (_s2sProviders.enumeration().hasMoreElements()): "Did not get injected with
a list of S2S providers!";
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a34ce77b/server/test/com/cloud/vpc/MockSite2SiteVpnServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockSite2SiteVpnServiceProvider.java b/server/test/com/cloud/vpc/MockSite2SiteVpnServiceProvider.java
new file mode 100644
index 0000000..8f5c0c1
--- /dev/null
+++ b/server/test/com/cloud/vpc/MockSite2SiteVpnServiceProvider.java
@@ -0,0 +1,86 @@
+// 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 com.cloud.vpc;
+
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.Site2SiteVpnConnection;
+import com.cloud.network.element.Site2SiteVpnServiceProvider;
+
+@Local({Site2SiteVpnServiceProvider.class})
+public class MockSite2SiteVpnServiceProvider implements Site2SiteVpnServiceProvider {
+
+    /* (non-Javadoc)
+     * @see com.cloud.utils.component.Adapter#configure(java.lang.String, java.util.Map)
+     */
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.utils.component.Adapter#getName()
+     */
+    @Override
+    public String getName() {
+        // TODO Auto-generated method stub
+        return "Site2SiteVpnServiceProvider";
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.utils.component.Adapter#start()
+     */
+    @Override
+    public boolean start() {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.utils.component.Adapter#stop()
+     */
+    @Override
+    public boolean stop() {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.network.element.Site2SiteVpnServiceProvider#startSite2SiteVpn(com.cloud.network.Site2SiteVpnConnection)
+     */
+    @Override
+    public boolean startSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException
{
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.network.element.Site2SiteVpnServiceProvider#stopSite2SiteVpn(com.cloud.network.Site2SiteVpnConnection)
+     */
+    @Override
+    public boolean stopSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException
{
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a34ce77b/server/test/com/cloud/vpc/Site2SiteVpnTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/Site2SiteVpnTest.java b/server/test/com/cloud/vpc/Site2SiteVpnTest.java
new file mode 100644
index 0000000..57117b1
--- /dev/null
+++ b/server/test/com/cloud/vpc/Site2SiteVpnTest.java
@@ -0,0 +1,82 @@
+package com.cloud.vpc;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.cloud.configuration.DefaultInterceptorLibrary;
+import com.cloud.network.dao.IPAddressDaoImpl;
+import com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl;
+import com.cloud.network.dao.Site2SiteVpnConnectionDao;
+import com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl;
+import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
+import com.cloud.network.element.Site2SiteVpnServiceProvider;
+import com.cloud.network.vpc.dao.VpcDaoImpl;
+import com.cloud.network.vpn.Site2SiteVpnManagerImpl;
+import com.cloud.user.MockAccountManagerImpl;
+import com.cloud.user.dao.AccountDaoImpl;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.component.Inject;
+import com.cloud.utils.component.MockComponentLocator;
+import com.cloud.vpc.dao.MockConfigurationDaoImpl;
+
+public class Site2SiteVpnTest {
+	private MockComponentLocator locator;
+    private final static Logger s_logger = Logger.getLogger(Site2SiteVpnTest.class);
+
+	private static void addDaos(MockComponentLocator locator) {
+		locator.addDao("AccountDao", AccountDaoImpl.class);
+		locator.addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class);
+		locator.addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class);
+        locator.addDao("Site2SiteVpnConnectionDao", Site2SiteVpnConnectionDaoImpl.class);
+
+		locator.addDao("IPAddressDao", IPAddressDaoImpl.class);
+		locator.addDao("VpcDao", VpcDaoImpl.class);
+		locator.addDao("ConfiguratioDao", MockConfigurationDaoImpl.class);
+
+	}
+	
+	private static void addManagers(MockComponentLocator locator) {
+		locator.addManager("AccountManager", MockAccountManagerImpl.class);
+		locator.addManager("VpcManager", MockVpcManagerImpl.class);
+	}
+	
+	@Before
+	public void setUp() {
+		locator = new MockComponentLocator("management-server");
+		addDaos(locator);
+		addManagers(locator);
+		s_logger.info("Finished setUp");
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	
+	@Test
+	public void testInjected() throws Exception  {
+		List<Pair<String, Class<? extends Site2SiteVpnServiceProvider>>> list
= 
+				new ArrayList<Pair<String, Class<? extends Site2SiteVpnServiceProvider>>>();
+		list.add(new Pair<String, Class<? extends Site2SiteVpnServiceProvider>>("Site2SiteVpnServiceProvider",
MockSite2SiteVpnServiceProvider.class));
+		locator.addAdapterChain(Site2SiteVpnServiceProvider.class, list);
+		s_logger.info("Finished add adapter");
+		locator.makeActive(new DefaultInterceptorLibrary());
+		s_logger.info("Finished make active");
+		Site2SiteVpnManagerImpl vpnMgr = ComponentLocator.inject(Site2SiteVpnManagerImpl.class);
+		s_logger.info("Finished inject");
+		Assert.assertTrue(vpnMgr.configure("Site2SiteVpnMgr",new HashMap<String, Object>())
);
+		Assert.assertTrue(vpnMgr.start());
+		
+	}
+	
+
+}


Mime
View raw message