當前位置: 首頁>>代碼示例>>Java>>正文


Java ApiConnectorMock類代碼示例

本文整理匯總了Java中net.juniper.contrail.api.ApiConnectorMock的典型用法代碼示例。如果您正苦於以下問題:Java ApiConnectorMock類的具體用法?Java ApiConnectorMock怎麽用?Java ApiConnectorMock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApiConnectorMock類屬於net.juniper.contrail.api包,在下文中一共展示了ApiConnectorMock類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: globalSetUp

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Before
public void globalSetUp() throws IOException {

    vrouterApi = new ContrailVRouterApi(null, 0);

    api   = new ApiConnectorMock(null, 0);

    vrouterApi.setApiConnector(api);

 // Create default-domain,default-project
    Project vProject = new Project();
    vProject.setName("default-project");
    try {
        if (!api.create(vProject)) {
            s_logger.error("Unable to create project: " + vProject.getName());
            fail("default-project creation failed");
            return;
        }
    } catch (IOException e) {
        s_logger.error("Exception : " + e);
        e.printStackTrace();
        fail("default-project creation failed");
        return;
    }
}
 
開發者ID:Juniper,項目名稱:contrail-vrouter-java-api,代碼行數:26,代碼來源:ContrailVRouterApiTest.java

示例2: globalSetUp

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Before
public void globalSetUp() throws IOException {
    _api   = new ApiConnectorMock(null, 0);
    assertNotNull(_api);

    // Create default-domain,default-project
    Project vProject = new Project();
    vProject.setName("default-project");
    try {
        if (!_api.create(vProject)) {
            s_logger.error("Unable to create project: " + vProject.getName());
            fail("default-project creation failed");
            return;
        }
    } catch (IOException e) {
        s_logger.error("Exception : " + e);
        e.printStackTrace();
        fail("default-project creation failed");
        return;
    }

    // Setup vnc object
    vncDB = new VncDB(null,0, Mode.VCENTER_ONLY);
    vncDB.setApiConnector(_api);
    assertNotNull(vncDB.getApiConnector());
    assertTrue(vncDB.isVncApiServerAlive());
    assertTrue(vncDB.Initialize());

    MainDB.vncDB = vncDB;
    VirtualNetworkInfoTest.vncDB = vncDB;
    VirtualNetworkInfoTest.api = _api;
    VirtualMachineInfoTest.vncDB = vncDB;
    VirtualMachineInfoTest.api = _api;
    VirtualMachineInterfaceInfoTest.vncDB = vncDB;
    VirtualMachineInterfaceInfoTest.api = _api;
}
 
開發者ID:Juniper,項目名稱:contrail-vcenter-plugin,代碼行數:37,代碼來源:VncDBTest.java

示例3: globalSetUp

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Before
public void globalSetUp() throws IOException {
    _api   = new ApiConnectorMock(null, 0);
    assertNotNull(_api);

    // Create default-domain,default-project
    Project vProject = new Project();
    vProject.setName("default-project");
    try {
        if (!_api.create(vProject)) {
            s_logger.error("Unable to create project: " + vProject.getName());
            fail("default-project creation failed");
            return;
        }
    } catch (IOException e) { 
        s_logger.error("Exception : " + e);
        e.printStackTrace();
        fail("default-project creation failed");
        return;
    }

    // Setup vnc object
    vncDB = new VncDB(null,0, "admin", "admin", "admin",
                      "keystone", "http://127.0.0.1:35357/v2.0", Mode.VCENTER_AS_COMPUTE);
    vncDB.setApiConnector(_api);
    assertNotNull(vncDB.getApiConnector());
    assertTrue(vncDB.isVncApiServerAlive());
    assertTrue(vncDB.Initialize());
}
 
開發者ID:Juniper,項目名稱:contrail-vcenter-plugin,代碼行數:30,代碼來源:VCenterAsComputeVncDBTest.java

示例4: globalSetUp

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Before
public void globalSetUp() throws IOException {
    api   = new ApiConnectorMock(null, 0);
    assertNotNull(api);

    // Create default-domain,default-project
    Project vProject = new Project();
    vProject.setName("default-project");
    try {
        if (!api.create(vProject)) {
            s_logger.error("Unable to create project: " + vProject.getName());
            fail("default-project creation failed");
            return;
        }
    } catch (IOException e) {
        s_logger.error("Exception : " + e);
        e.printStackTrace();
        fail("default-project creation failed");
        return;
    }

    // Setup vnc object
    vncDB = new VncDB(null,0, Mode.VCENTER_ONLY);
    vncDB.setApiConnector(api);
    assertNotNull(vncDB.getApiConnector());
    assertTrue(vncDB.isVncApiServerAlive());
    assertTrue(vncDB.Initialize());

    MainDB.vncDB = vncDB;
}
 
開發者ID:Juniper,項目名稱:contrail-vcenter-plugin,代碼行數:31,代碼來源:VirtualNetworkInfoTest.java

示例5: testCreateVirtualNetwork

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Test
public void testCreateVirtualNetwork() throws IOException {

    String uuid = UUID.randomUUID().toString();
    ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);
    ModelController controller      = mock(ModelController.class);
    ApiConnector api = new ApiConnectorMock(null, 0);
    when(controller.getManager()).thenReturn(contrailMgr);
    when(controller.getApiAccessor()).thenReturn(api);

    // Create Virtual-Network (VN)
    NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(State.Allocated);
    when(network.getGateway()).thenReturn("10.1.1.1");
    when(network.getCidr()).thenReturn("10.1.1.0/24");
    when(network.getPhysicalNetworkId()).thenReturn(42L);
    when(network.getDomainId()).thenReturn(10L);
    when(network.getAccountId()).thenReturn(42L);

    when(contrailMgr.getCanonicalName(network)).thenReturn("testnetwork");
    when(contrailMgr.getProjectId(network.getDomainId(), network.getAccountId())).thenReturn("testProjectId");

    VirtualNetworkModel vnModel = new VirtualNetworkModel(network, uuid, "testnetwork", TrafficType.Guest);

    assertEquals(vnModel.getName(), "testnetwork");
    assertEquals(vnModel.getUuid(), uuid);

    vnModel.build(controller, network);
    try {
        vnModel.update(controller);
    } catch (Exception ex) {
        fail("virtual-network update failed ");
    }
    assertTrue(vnModel.verify(controller));
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:37,代碼來源:VirtualNetworkModelTest.java

示例6: globalSetUp

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@BeforeClass
public static void globalSetUp() throws Exception {
    ApiConnectorFactory.setImplementation(ApiConnectorMock.class);
    s_logger.info("mysql server is getting launched ");
    s_mysqlSrverPort = TestDbSetup.init(null);
    s_logger.info("mysql server launched on port " + s_mysqlSrverPort);

    s_msId = ManagementServerNode.getManagementServerId();
    s_lockMaster = Merovingian2.createLockMaster(s_msId);
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:11,代碼來源:NetworkProviderTest.java

示例7: testCreateVirtualMachine

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Test
public void testCreateVirtualMachine() throws IOException {

    String uuid = UUID.randomUUID().toString();
    ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);
    ModelController controller      = mock(ModelController.class);
    ApiConnector api = new ApiConnectorMock(null, 0);
    when(controller.getManager()).thenReturn(contrailMgr);
    when(controller.getApiAccessor()).thenReturn(api);

    // Create Virtual-Network (VN)
    NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(Network.State.Allocated);
    when(network.getGateway()).thenReturn("10.1.1.1");
    when(network.getCidr()).thenReturn("10.1.1.0/24");
    when(network.getPhysicalNetworkId()).thenReturn(42L);
    when(network.getDomainId()).thenReturn(10L);
    when(network.getAccountId()).thenReturn(42L);

    when(contrailMgr.getCanonicalName(network)).thenReturn("testnetwork");
    when(contrailMgr.getProjectId(network.getDomainId(), network.getAccountId())).thenReturn("testProjectId");

    // Create Virtual-Machine (VM)
    VMInstanceVO vm = mock(VMInstanceVO.class);
    when(vm.getInstanceName()).thenReturn("testVM1");
    when(vm.getState()).thenReturn(VirtualMachine.State.Starting);
    when(vm.getDomainId()).thenReturn(10L);
    when(vm.getAccountId()).thenReturn(42L);

    UserVmDao VmDao      = mock(UserVmDao.class);
    when(VmDao.findById(anyLong())).thenReturn(null);
    when(controller.getVmDao()).thenReturn(VmDao);

    VirtualMachineModel vmModel = new VirtualMachineModel(vm, uuid);

    assertEquals(vmModel.getInstanceName(), "testVM1");
    assertEquals(vmModel.getUuid(), uuid);

    vmModel.build(controller, vm);
    try {
        vmModel.update(controller);
    } catch (Exception ex) {
        fail("virtual-network update failed ");
    }

    //verify
    assertTrue(vmModel.verify(controller));
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:50,代碼來源:VirtualMachineModelTest.java

示例8: ApiConnectorMockito

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
public ApiConnectorMockito(String hostname, int port) {
    _mock = new ApiConnectorMock(hostname, port);
    _spy = spy(_mock);
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:5,代碼來源:ApiConnectorMockito.java

示例9: testAddDeletePort

import net.juniper.contrail.api.ApiConnectorMock; //導入依賴的package包/類
@Test
public void testAddDeletePort() {
    vrouterApi = new ContrailVRouterApi(null, 0);

    api   = new ApiConnectorMock(null, 0);

    vrouterApi.setApiConnector(api);

    vrouterApi.addPort("VIF_UUID", "VM_UUID", "INTF_NAME", "INTF_IP", "MAC_ADDRESS",
            "NW_UUID", (short)1000, (short)1001, "VM-NAME", "PROJ_UUID");

    vrouterApi.deletePort("VIF_UUID");
}
 
開發者ID:Juniper,項目名稱:contrail-vrouter-java-api,代碼行數:14,代碼來源:ContrailVRouterApiTest.java


注:本文中的net.juniper.contrail.api.ApiConnectorMock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。