Cannot get inputStream from web url. Why?

I'm trying to create a book with an image in JUnit test using MockMultipartFile. But for unknown reasons the stream cannot be taken. Why?
    @Test
    @Order(2)
    void testCreateBookWithAnImage() {
        BookRequestDTO bookDto = new BookRequestDTO();
        bookDto.setTitle("New Book With Image");
        bookDto.setAuthor("Name Surname");
        bookDto.setSummary("Instructions how to add an image and asociate it with the Book object");
        bookDto.setIsbn("555556666");
        bookDto.setYear(2023);
        bookDto.setPages(20);
        bookDto.setCirculation(3);
        bookDto.setCategory("Novel");
        
        MultipartFile file = null;
        
        try {
            file = createMultipartFileFromURL("https://cdn.pixabay.com/photo/2014/09/05/18/32/old-books-436498_1280.jpg");
            // file = createMultipartFileFromURL("https://pngimg.com/uploads/pineapple/pineapple_PNG2755.png");
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        try {
            Book createdBook = bookService.addNewBookWithImage(bookDto, file);
            assertEquals("New Book With Image", createdBook.getTitle());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
Was this page helpful?