Search in sources :

Example 6 with FMVExecuteException

use of org.fagu.fmv.soft.exec.exception.FMVExecuteException in project fmv by f-agu.

the class GSExceptionKnowAnalyzeTestCase method testMerge.

/**
 * @throws IOException
 */
@Test
public // @Ignore
void testMerge() throws IOException {
    File folder = new File(System.getProperty("java.io.tmpdir"), "gs-merge-test");
    FileUtils.deleteDirectory(folder);
    folder.mkdirs();
    try {
        try {
            Soft gsSoft = GS.search();
            File viewJpegPSFile = new File(new File(gsSoft.getFile().getParentFile().getParentFile(), "lib"), "viewjpeg.ps");
            File srcFile = Resource.extract(folder, "cheese.zip");
            File outFile = new File(srcFile.getPath() + ".pdf");
            List<String> parameters = new ArrayList<>();
            parameters.add("-sDEVICE=pdfwrite");
            parameters.add("-dPDFSETTINGS=/prepress");
            parameters.add("-o");
            parameters.add(outFile.getAbsolutePath());
            parameters.add(viewJpegPSFile.getAbsolutePath());
            parameters.add("-c");
            parameters.add("(" + srcFile.getName() + ") viewJPEG showpage");
            gsSoft.withParameters(parameters).workingDirectory(srcFile.getParentFile()).execute();
        } catch (FMVExecuteException e) {
            if (e.isKnown()) {
                assertEquals("ddd", e.getExceptionKnown().toString());
            } else {
                throw e;
            }
        }
    } finally {
        FileUtils.deleteDirectory(folder);
    }
}
Also used : FMVExecuteException(org.fagu.fmv.soft.exec.exception.FMVExecuteException) ArrayList(java.util.ArrayList) File(java.io.File) Soft(org.fagu.fmv.soft.Soft) Test(org.junit.Test)

Example 7 with FMVExecuteException

use of org.fagu.fmv.soft.exec.exception.FMVExecuteException in project fmv by f-agu.

the class FFExceptionKnowAnalyzeTestCase method extractMetadatas.

// ****************************************************************
/**
 * @param resource
 * @param expectedMessage
 * @throws IOException
 */
private void extractMetadatas(String resource, String expectedMessage) throws IOException {
    File folder = new File(System.getProperty("java.io.tmpdir"), "ff-extractmetadatas-test");
    try {
        FileUtils.deleteDirectory(folder);
        folder.mkdirs();
        File file = resource != null ? ResourceUtils.extract(resource, folder) : folder;
        try {
            MovieMetadatas extract = MovieMetadatas.with(file).extract();
            fail(expectedMessage + ": " + extract.toJSON());
        } catch (FMVExecuteException e) {
            if (e.isKnown()) {
                assertEquals(expectedMessage, e.getExceptionKnown().toString());
            } else {
                throw e;
            }
        }
    } finally {
        FileUtils.deleteDirectory(folder);
    }
}
Also used : FMVExecuteException(org.fagu.fmv.soft.exec.exception.FMVExecuteException) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) File(java.io.File)

Aggregations

FMVExecuteException (org.fagu.fmv.soft.exec.exception.FMVExecuteException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)3 Soft (org.fagu.fmv.soft.Soft)3 ExecuteException (org.apache.commons.exec.ExecuteException)2 PIDProcessOperator (org.fagu.fmv.soft.exec.PIDProcessOperator)2 IOException (java.io.IOException)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 OptionalLong (java.util.OptionalLong)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Consumer (java.util.function.Consumer)1 CommandLine (org.apache.commons.exec.CommandLine)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1