mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Apply proper license header and formatting to the new contrail tests #2
This commit is contained in:
parent
4e88197459
commit
50be9a447a
@ -1,48 +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.
|
||||
|
||||
package org.apache.cloudstack.network.contrail.model;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cloudstack.network.contrail.management.*;
|
||||
import org.apache.cloudstack.network.contrail.model.*;
|
||||
import junit.framework.TestCase;
|
||||
import net.juniper.contrail.api.ApiConnector;
|
||||
import net.juniper.contrail.api.ApiConnectorMock;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.apache.cloudstack.network.contrail.management.ContrailManagerImpl;
|
||||
import org.apache.cloudstack.network.contrail.management.ModelDatabase;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
import net.juniper.contrail.api.ApiConnectorMock;
|
||||
import net.juniper.contrail.api.ApiConnectorFactory;
|
||||
import net.juniper.contrail.api.ApiObjectBase;
|
||||
import net.juniper.contrail.api.types.Domain;
|
||||
import net.juniper.contrail.api.types.InstanceIp;
|
||||
import net.juniper.contrail.api.types.NetworkIpam;
|
||||
import net.juniper.contrail.api.types.SubnetType;
|
||||
import net.juniper.contrail.api.types.VirtualMachineInterface;
|
||||
import net.juniper.contrail.api.types.VirtualNetwork;
|
||||
import net.juniper.contrail.api.types.VnSubnetsType;
|
||||
import net.juniper.contrail.api.types.NetworkPolicy;
|
||||
import net.juniper.contrail.api.types.Project;
|
||||
import net.juniper.contrail.api.types.FloatingIp;
|
||||
import net.juniper.contrail.api.types.VnSubnetsType;
|
||||
import net.juniper.contrail.api.types.ServiceInstance;
|
||||
import net.juniper.contrail.api.ApiConnector;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class VirtualMachineModelTest extends TestCase {
|
||||
private static final Logger s_logger =
|
||||
@ -78,35 +74,35 @@ public class VirtualMachineModelTest extends TestCase {
|
||||
public void testCreateVirtualMachine() throws IOException {
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);
|
||||
ModelController controller = mock(ModelController.class);
|
||||
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);
|
||||
when(controller.getManager()).thenReturn(contrailMgr);
|
||||
when(controller.getApiAccessor()).thenReturn(api);
|
||||
|
||||
// Create Virtual-Network (VN)
|
||||
// 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(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");
|
||||
when(contrailMgr.getCanonicalName(network)).thenReturn("testnetwork");
|
||||
when(contrailMgr.getProjectId(network.getDomainId(), network.getAccountId())).thenReturn("testProjectId");
|
||||
|
||||
// Create Virtual-Machine (VM)
|
||||
// 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);
|
||||
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);
|
||||
UserVmDao VmDao = mock(UserVmDao.class);
|
||||
when(VmDao.findById(anyLong())).thenReturn(null);
|
||||
when(controller.getVmDao()).thenReturn(VmDao);
|
||||
|
||||
VirtualMachineModel vmModel = new VirtualMachineModel(vm, uuid);
|
||||
|
||||
@ -114,13 +110,13 @@ public class VirtualMachineModelTest extends TestCase {
|
||||
assertEquals(vmModel.getUuid(), uuid);
|
||||
|
||||
vmModel.build(controller, vm);
|
||||
try {
|
||||
try {
|
||||
vmModel.update(controller);
|
||||
} catch (Exception ex) {
|
||||
fail("virtual-network update failed ");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
fail("virtual-network update failed ");
|
||||
}
|
||||
|
||||
//verify
|
||||
//verify
|
||||
assertTrue(vmModel.verify(controller));
|
||||
|
||||
}
|
||||
|
||||
@ -17,47 +17,26 @@
|
||||
|
||||
package org.apache.cloudstack.network.contrail.model;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.cloudstack.network.contrail.management.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import net.juniper.contrail.api.ApiConnectorMock;
|
||||
import net.juniper.contrail.api.ApiConnectorFactory;
|
||||
import net.juniper.contrail.api.ApiObjectBase;
|
||||
import net.juniper.contrail.api.types.Domain;
|
||||
import net.juniper.contrail.api.types.InstanceIp;
|
||||
import net.juniper.contrail.api.types.NetworkIpam;
|
||||
import net.juniper.contrail.api.types.SubnetType;
|
||||
import net.juniper.contrail.api.types.VirtualMachine;
|
||||
import net.juniper.contrail.api.types.VirtualMachineInterface;
|
||||
import net.juniper.contrail.api.types.VirtualNetwork;
|
||||
import net.juniper.contrail.api.types.VnSubnetsType;
|
||||
import net.juniper.contrail.api.types.NetworkPolicy;
|
||||
import net.juniper.contrail.api.types.Project;
|
||||
import net.juniper.contrail.api.types.FloatingIp;
|
||||
import net.juniper.contrail.api.types.VnSubnetsType;
|
||||
import net.juniper.contrail.api.types.ServiceInstance;
|
||||
import net.juniper.contrail.api.ApiConnector;
|
||||
import net.juniper.contrail.api.ApiConnectorMock;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import org.apache.cloudstack.network.contrail.management.ContrailManager;
|
||||
import org.apache.cloudstack.network.contrail.management.ContrailManagerImpl;
|
||||
import org.apache.cloudstack.network.contrail.management.ModelDatabase;
|
||||
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
public class VirtualNetworkModelTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualNetworkModelTest.class);
|
||||
@ -89,7 +68,7 @@ public class VirtualNetworkModelTest extends TestCase {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);
|
||||
ModelController controller = mock(ModelController.class);
|
||||
ApiConnector api = new ApiConnectorMock(null, 0);
|
||||
ApiConnector api = new ApiConnectorMock(null, 0);
|
||||
when(controller.getManager()).thenReturn(contrailMgr);
|
||||
when(controller.getApiAccessor()).thenReturn(api);
|
||||
|
||||
@ -118,6 +97,6 @@ public class VirtualNetworkModelTest extends TestCase {
|
||||
fail("virtual-network update failed ");
|
||||
}
|
||||
assertTrue(vnModel.verify(controller));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user