cancel
Showing results for 
Search instead for 
Did you mean: 

My simple PDF2ImageConverter unit test is failing. Is it my mistake or a bug?

Steven_Huwig1
Star Contributor
Star Contributor

I expect the following to not crash, but instead it results in a stack trace when I attempt to call ConversionService.convert().

java.lang.NullPointerException
	at org.nuxeo.ecm.platform.convert.plugins.PDF2ImageConverter.getCmdStringParameters(PDF2ImageConverter.java:89)
	at org.nuxeo.ecm.platform.convert.plugins.CommandLineBasedConverter.convert(CommandLineBasedConverter.java:91)
	at org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convert(ConversionServiceImpl.java:203)
	at com.example.PDFToJPEGConverterTest.testConverter(PDFToJPEGConverterTest.java:36)

Here is the unit test code:

package com.example;

import com.google.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.nuxeo.common.utils.FileUtils;
import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
import org.nuxeo.ecm.core.api.blobholder.SimpleBlobHolder;
import org.nuxeo.ecm.core.api.impl.blob.FileBlob;
import org.nuxeo.ecm.core.convert.api.ConversionService;
import org.nuxeo.ecm.platform.test.PlatformFeature;
import org.nuxeo.runtime.test.runner.Deploy;
import org.nuxeo.runtime.test.runner.Features;
import org.nuxeo.runtime.test.runner.FeaturesRunner;

import java.io.File;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@RunWith(FeaturesRunner.class)
@Features({PlatformFeature.class})
@Deploy({"org.nuxeo.ecm.platform.convert", "org.nuxeo.ecm.platform.commandline.executor"})
public class PDFToJPEGConverterTest {

    @Inject
    ConversionService service;

    @Test
    public void testConverter() {
        String converterName = service.getConverterName(
                "application/pdf", "image/jpeg");
        File pdfInput = FileUtils.getResourceFileFromContext("Chapter 14.pdf");
        assertTrue(pdfInput.length() > 0);
        BlobHolder blobHolder = new SimpleBlobHolder(new FileBlob(pdfInput));
        Object result = service.convert(converterName, blobHolder, null);
        assertNotNull(result);
    }


}
0 REPLIES 0
Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.