/*
 * 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.pdfbox.rendering;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.ParallelParameterized;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Functional test for PDF rendering. This test simply tries to render
 * a series of PDFs using PDFBox to make sure that no exceptions are thrown.
 *
 * It does not attempt to detect if rendering is correct, see {@link org.apache.pdfbox.rendering.TestPDFToImage}.
 *
 * @author John Hewson
 */
@RunWith(ParallelParameterized.class)
public class TestRendering
{
    private static final String INPUT_DIR = "src/test/resources/input/rendering";

    @Parameters(name = "{0}")
    public static Collection<Object[]> data()
    {
        File[] testFiles = new File(INPUT_DIR).listFiles(
                (dir, name) -> (name.endsWith(".pdf") || name.endsWith(".ai")));
        return Stream.of(testFiles).map(file -> new Object[] { file.getName() }).collect(Collectors.toList());
    }

    private final String fileName;

    public TestRendering(String fileName)
    {
        this.fileName = fileName;
    }

    @Test
    public void render() throws IOException
    {
        File file = new File(INPUT_DIR, fileName);
        PDDocument document = Loader.loadPDF(file);
        PDFRenderer renderer = new PDFRenderer(document);
        renderer.renderImage(0);

        // We don't actually do anything with the image for the same reason that
        // TestPDFToImage is disabled - different JVMs produce different results
        // but at least we can make sure that PDFBox did not throw any exceptions
        // during the rendering process.

        document.close();
    }
}

@@ -897,181 +897,184 @@
 box.
-ParallelParameterized;%0Aimport org.apache.pdfbox.pdmodel.PDDocument;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized.Parameters
+pdmodel.PDDocument;%0Aimport org.junit.jupiter.params.ParameterizedTest;%0Aimport org.junit.jupiter.params.provider.Arguments;%0Aimport org.junit.jupiter.params.provider.MethodSource
 ;%0A%0Ai
@@ -1522,46 +1522,8 @@
  */%0A
-@RunWith(ParallelParameterized.class)%0A
 publ
@@ -1634,38 +1634,8 @@
 %22;%0A%0A
-    @Parameters(name = %22%7B0%7D%22)%0A
     
@@ -1659,24 +1659,25 @@
 lection%3C
-Object%5B%5D
+Arguments
 %3E data()
@@ -1874,23 +1874,21 @@
  -%3E 
-new Object%5B%5D %7B 
+Arguments.of(
 file
@@ -1897,18 +1897,17 @@
 etName()
- %7D
+)
 ).collec
@@ -1945,138 +1945,49 @@
     
-private final String fileName;%0A%0A    public TestRendering(String fileName)%0A    %7B%0A        this.fileName = fileName;%0A    %7D%0A%0A    @Test
+@ParameterizedTest%0A%09@MethodSource(%22data%22)
 %0A   
@@ -2006,16 +2006,31 @@
  render(
+String fileName
 ) throws

switch to JUnit5