package org.zstack.test.kvm; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.zstack.core.cloudbus.CloudBus; import org.zstack.core.componentloader.ComponentLoader; import org.zstack.core.db.DatabaseFacade; import org.zstack.header.cluster.ClusterInventory; import org.zstack.header.identity.SessionInventory; import org.zstack.header.network.l2.L2NetworkInventory; import org.zstack.kvm.KVMHostFactory; import org.zstack.simulator.kvm.KVMSimulatorConfig; import org.zstack.test.Api; import org.zstack.test.ApiSenderException; import org.zstack.test.DBUtil; import org.zstack.test.WebBeanConstructor; import org.zstack.test.deployer.Deployer; import org.zstack.utils.Utils; import org.zstack.utils.logging.CLogger; public class TestKvmAttachL2Network { static CLogger logger = Utils.getLogger(TestKvmAttachL2Network.class); static Deployer deployer; static Api api; static ComponentLoader loader; static CloudBus bus; static DatabaseFacade dbf; static KVMHostFactory kvmFactory; static SessionInventory session; static KVMSimulatorConfig config; @BeforeClass public static void setUp() throws Exception { DBUtil.reDeployDB(); WebBeanConstructor con = new WebBeanConstructor(); deployer = new Deployer("deployerXml/kvm/TestKvmAttachL2Network.xml", con); deployer.addSpringConfig("Kvm.xml"); deployer.addSpringConfig("KVMSimulator.xml"); deployer.build(); api = deployer.getApi(); loader = deployer.getComponentLoader(); kvmFactory = loader.getComponent(KVMHostFactory.class); bus = loader.getComponent(CloudBus.class); dbf = loader.getComponent(DatabaseFacade.class); config = loader.getComponent(KVMSimulatorConfig.class); session = api.loginAsAdmin(); } @Test public void test() throws ApiSenderException { L2NetworkInventory l2 = deployer.l2Networks.get("TestL2Network"); ClusterInventory cluster = deployer.clusters.get("Cluster1"); api.attachL2NetworkToCluster(l2.getUuid(), cluster.getUuid()); Assert.assertEquals(2, config.createBridgeCmds.size()); } }