From 97bad4f9b39702a780d8f1ab757817f23b0cf0b8 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 14 Feb 2014 16:54:36 +0100 Subject: [PATCH] Fix checkstyle and license issues --- .../cloud/vm/VirtualMachineManagerImpl.java | 7 +++-- .../test/com/cloud/utils/db/GroupByTest.java | 21 +++++++++++++- .../xen/resource/CitrixResourceBase.java | 28 ++++++++----------- .../xen/resource/CitrixResourceBaseTest.java | 26 ++++++++--------- .../template/TemplateManagerImplTest.java | 18 ++++++++++++ .../test/java/streamer/ByteBufferTest.java | 2 ++ .../ConsoleProxyRdpClientTest.java | 17 +++++++++++ utils/test/com/cloud/utils/UuidUtilsTest.java | 17 +++++++++++ 8 files changed, 102 insertions(+), 34 deletions(-) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 9513bd7c291..888c7508984 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -40,6 +40,8 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; + import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; @@ -67,7 +69,6 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.identity.ManagementServerNode; -import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -938,8 +939,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac //storing the value of overcommit in the vm_details table for doing a capacity check in case the cluster overcommit ratio is changed. if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") == null && ((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) { - _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue()); - _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue()); + _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true); + _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true); } else if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") != null) { _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true); _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true); diff --git a/framework/db/test/com/cloud/utils/db/GroupByTest.java b/framework/db/test/com/cloud/utils/db/GroupByTest.java index e0087ea5fbf..d394c73c3fa 100644 --- a/framework/db/test/com/cloud/utils/db/GroupByTest.java +++ b/framework/db/test/com/cloud/utils/db/GroupByTest.java @@ -1,9 +1,28 @@ +// 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.utils.db; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import org.junit.Test; -import static org.junit.Assert.assertTrue; import com.cloud.utils.Pair; import com.cloud.utils.db.SearchCriteria.Func; diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 788e70d0438..2cabc588dbb 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -1956,7 +1956,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { Connection conn = getConnection(); - int i = 0; String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); @@ -2029,8 +2028,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { Connection conn = getConnection(); - String[] results = new String[cmd.getIpAddresses().length]; - int i = 0; String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); try { @@ -7307,19 +7304,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe return new ExecutionResult(true, null); } - protected void setNicDevIdIfCorrectVifIsNotNull(Connection conn, - IpAddressTO ip, VIF correctVif) throws InternalErrorException, - BadServerResponse, XenAPIException, XmlRpcException { - if (correctVif == null) { - if (ip.isAdd()) { - throw new InternalErrorException("Failed to find DomR VIF to associate IP with."); - } else { - s_logger.debug("VIF to deassociate IP with does not exist, return success"); - } - } else { - ip.setNicDevId(Integer.valueOf(correctVif.getDevice(conn))); - } - } + protected void setNicDevIdIfCorrectVifIsNotNull(Connection conn, IpAddressTO ip, VIF correctVif) throws InternalErrorException, BadServerResponse, XenAPIException, + XmlRpcException { + if (correctVif == null) { + if (ip.isAdd()) { + throw new InternalErrorException("Failed to find DomR VIF to associate IP with."); + } else { + s_logger.debug("VIF to deassociate IP with does not exist, return success"); + } + } else { + ip.setNicDevId(Integer.valueOf(correctVif.getDevice(conn))); + } + } protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) { Connection conn = getConnection(); diff --git a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java index b54a21cf99c..0920c7f1173 100644 --- a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java +++ b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java @@ -26,7 +26,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Matchers.any; import java.util.HashMap; import java.util.Iterator; @@ -46,6 +45,7 @@ import com.xensource.xenapi.Types; import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; import com.xensource.xenapi.XenAPIObject; + import com.cloud.agent.api.ScaleVmAnswer; import com.cloud.agent.api.ScaleVmCommand; import com.cloud.agent.api.to.IpAddressTO; @@ -176,17 +176,15 @@ public class CitrixResourceBaseTest { } - @Test - public void testSetNicDevIdIfCorrectVifIsNotNull() throws Exception { - IpAddressTO ip = mock (IpAddressTO.class); - when (ip.isAdd()).thenReturn(false); - VIF correctVif = null; - try { - _resource.setNicDevIdIfCorrectVifIsNotNull(conn, ip, correctVif); - } - catch (NullPointerException e) - { - fail("this test is meant to show that null pointer is not thrown"); - } - } + @Test + public void testSetNicDevIdIfCorrectVifIsNotNull() throws Exception { + IpAddressTO ip = mock(IpAddressTO.class); + when(ip.isAdd()).thenReturn(false); + VIF correctVif = null; + try { + _resource.setNicDevIdIfCorrectVifIsNotNull(conn, ip, correctVif); + } catch (NullPointerException e) { + fail("this test is meant to show that null pointer is not thrown"); + } + } } \ No newline at end of file diff --git a/server/test/com/cloud/template/TemplateManagerImplTest.java b/server/test/com/cloud/template/TemplateManagerImplTest.java index 3788393dd4d..bcbc3234746 100644 --- a/server/test/com/cloud/template/TemplateManagerImplTest.java +++ b/server/test/com/cloud/template/TemplateManagerImplTest.java @@ -1,3 +1,21 @@ +// 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.template; import org.junit.Test; diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java index 8dbeba2d13c..6bcfed91317 100644 --- a/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java +++ b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java @@ -17,6 +17,8 @@ package streamer; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.util.ArrayList; import java.util.Collection; diff --git a/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java index 038f438400e..80bf5bcc44f 100644 --- a/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java +++ b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java @@ -1,3 +1,20 @@ +// 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.consoleproxy; import junit.framework.Assert; diff --git a/utils/test/com/cloud/utils/UuidUtilsTest.java b/utils/test/com/cloud/utils/UuidUtilsTest.java index 299e247e7c1..a39eae70da6 100644 --- a/utils/test/com/cloud/utils/UuidUtilsTest.java +++ b/utils/test/com/cloud/utils/UuidUtilsTest.java @@ -1,3 +1,20 @@ +// 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.utils; import static org.junit.Assert.assertFalse;