rafaelweingartner commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164820107
########## File path: plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessorTest.java ########## @@ -0,0 +1,459 @@ +/* + * 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.hypervisor.xenserver.resource; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.times; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.apache.commons.lang.StringUtils; +import org.apache.xmlrpc.XmlRpcException; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InOrder; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.cloud.utils.exception.CloudRuntimeException; +import com.xensource.xenapi.Connection; +import com.xensource.xenapi.Host; +import com.xensource.xenapi.PBD; +import com.xensource.xenapi.PBD.Record; +import com.xensource.xenapi.SR; +import com.xensource.xenapi.Types.InternalError; +import com.xensource.xenapi.Types.XenAPIException; + +@RunWith(PowerMockRunner.class) +public class Xenserver625StorageProcessorTest { + + @InjectMocks + private Xenserver625StorageProcessor xenserver625StorageProcessor; + + @Mock + private CitrixResourceBase citrixResourceBase; + + @Mock + private Connection connectionMock; + + private String pathMock = "pathMock"; + + @Before + public void before() { + xenserver625StorageProcessor = Mockito.spy(new Xenserver625StorageProcessor(citrixResourceBase)); + citrixResourceBase._host = Mockito.mock(XsHost.class); + Mockito.when(citrixResourceBase.getHost()).thenReturn(citrixResourceBase._host); + } + + @Test + public void makeDirectoryTestCallHostPlugingReturningEmpty() { + boolean makeDirectoryReturn = configureAndExecuteMakeDirectoryMethodForTest(pathMock, StringUtils.EMPTY); + + assertFalse(makeDirectoryReturn); + } + + @Test + public void makeDirectoryTestCallHostPlugingReturningNull() { + boolean makeDirectoryReturn = configureAndExecuteMakeDirectoryMethodForTest(pathMock, null); + + assertFalse(makeDirectoryReturn); + } + + @Test + public void makeDirectoryTestCallHostPlugingReturningSomething() { + boolean makeDirectoryReturn = configureAndExecuteMakeDirectoryMethodForTest(pathMock, "Soemthing"); Review comment: Ah this one. It can actually be any string. instead of writing a fictitious directory, which though it would be misleading. Therefore, I decided to write anything... I will try to change this... ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
