|
|
@ -41,6 +41,7 @@ import org.mockito.InjectMocks; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.Mockito; |
|
|
|
import org.mockito.Mockito; |
|
|
|
import org.powermock.api.mockito.PowerMockito; |
|
|
|
import org.powermock.api.mockito.PowerMockito; |
|
|
|
|
|
|
|
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
|
|
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
|
|
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -53,6 +54,7 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
|
|
|
|
@PowerMockIgnore({"sun.security.*", "javax.net.*"}) |
|
|
|
@PrepareForTest({HadoopUtils.class,PropertyUtils.class, FileUtils.class,org.apache.dolphinscheduler.api.utils.FileUtils.class}) |
|
|
|
@PrepareForTest({HadoopUtils.class,PropertyUtils.class, FileUtils.class,org.apache.dolphinscheduler.api.utils.FileUtils.class}) |
|
|
|
public class ResourcesServiceTest { |
|
|
|
public class ResourcesServiceTest { |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class); |
|
|
@ -115,6 +117,7 @@ public class ResourcesServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
//UDF_RESOURCE_SUFFIX_NOT_JAR
|
|
|
|
//UDF_RESOURCE_SUFFIX_NOT_JAR
|
|
|
|
mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf","ResourcesServiceTest.pdf","pdf",new String("test").getBytes()); |
|
|
|
mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf","ResourcesServiceTest.pdf","pdf",new String("test").getBytes()); |
|
|
|
|
|
|
|
PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.pdf")).thenReturn("pdf"); |
|
|
|
result = resourcesService.createResource(user,"ResourcesServiceTest.pdf","ResourcesServiceTest",ResourceType.UDF,mockMultipartFile); |
|
|
|
result = resourcesService.createResource(user,"ResourcesServiceTest.pdf","ResourcesServiceTest",ResourceType.UDF,mockMultipartFile); |
|
|
|
logger.info(result.toString()); |
|
|
|
logger.info(result.toString()); |
|
|
|
Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(),result.getMsg()); |
|
|
|
Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(),result.getMsg()); |
|
|
|