@Test public void testTransform() throws Exception { File reference = findAndCopy("outputs/" + fInput + "_" + fTransform + "." + fFormat); Response response = doRequest(fInput, fTransform, fFormat, mapContentType(fFormat)); File output = EngineTestUtils.outputFile(); try (FileOutputStream oStream = new FileOutputStream(output)) { IOUtils.copy(response.asInputStream(), oStream); } assertEquals(reference, output, mapContentType(fFormat)); }
@Override public Entity transform(HttpRequestEntity entity) throws IOException { logMessage(entity.getRequest()); final HttpRequestEntity request = cast(entity); final ImmutablePair<MimeType, Properties> options = exporterOptions(request); options.right.putAll(transformerConfig); final File input = downloadInput(entity); final File output = File.createTempFile("reply", "tmp"); final ITransformEngine engine = getEngine(); return new WritingEntity() { @Override public void writeData(OutputStream out) throws IOException { try { synchronized (SynchronousTransformer.this) { engine.transform(input.toURI(), fetchTransform(request), output.toURI(), options.right); } try (FileInputStream stream = new FileInputStream(output)) { IOUtils.copy(stream, out); } } finally { input.delete(); output.delete(); } } @Override public MimeType getType() { return options.left; } }; }
SynchronousTransformer extends BatchRefineTransformer implements
        SyncTransformer { @Override public Entity transform(HttpRequestEntity entity) throws IOException { logMessage(entity.getRequest()); final HttpRequestEntity request = cast(entity); final ImmutablePair<MimeType, Properties> options = exporterOptions(request); options.right.putAll(transformerConfig); final File input = downloadInput(entity); final File output = File.createTempFile("reply", "tmp"); final ITransformEngine engine = getEngine(); return new WritingEntity() { @Override public void writeData(OutputStream out) throws IOException { try { synchronized (SynchronousTransformer.this) { engine.transform(input.toURI(), fetchTransform(request), output.toURI(), options.right); } try (FileInputStream stream = new FileInputStream(output)) { IOUtils.copy(stream, out); } } finally { input.delete(); output.delete(); } } @Override public MimeType getType() { return options.left; } }; } }
SynchronousTransformer extends BatchRefineTransformer implements
        SyncTransformer { @Override public Entity transform(HttpRequestEntity entity) throws IOException { logMessage(entity.getRequest()); final HttpRequestEntity request = cast(entity); final ImmutablePair<MimeType, Properties> options = exporterOptions(request); options.right.putAll(transformerConfig); final File input = downloadInput(entity); final File output = File.createTempFile("reply", "tmp"); final ITransformEngine engine = getEngine(); return new WritingEntity() { @Override public void writeData(OutputStream out) throws IOException { try { synchronized (SynchronousTransformer.this) { engine.transform(input.toURI(), fetchTransform(request), output.toURI(), options.right); } try (FileInputStream stream = new FileInputStream(output)) { IOUtils.copy(stream, out); } } finally { input.delete(); output.delete(); } } @Override public MimeType getType() { return options.left; } }; } SynchronousTransformer(ITransformEngine engine, Properties config); }
SynchronousTransformer extends BatchRefineTransformer implements
        SyncTransformer { @Override public Entity transform(HttpRequestEntity entity) throws IOException { logMessage(entity.getRequest()); final HttpRequestEntity request = cast(entity); final ImmutablePair<MimeType, Properties> options = exporterOptions(request); options.right.putAll(transformerConfig); final File input = downloadInput(entity); final File output = File.createTempFile("reply", "tmp"); final ITransformEngine engine = getEngine(); return new WritingEntity() { @Override public void writeData(OutputStream out) throws IOException { try { synchronized (SynchronousTransformer.this) { engine.transform(input.toURI(), fetchTransform(request), output.toURI(), options.right); } try (FileInputStream stream = new FileInputStream(output)) { IOUtils.copy(stream, out); } } finally { input.delete(); output.delete(); } } @Override public MimeType getType() { return options.left; } }; } SynchronousTransformer(ITransformEngine engine, Properties config); @Override boolean isLongRunning(); @Override Entity transform(HttpRequestEntity entity); }
SynchronousTransformer extends BatchRefineTransformer implements
        SyncTransformer { @Override public Entity transform(HttpRequestEntity entity) throws IOException { logMessage(entity.getRequest()); final HttpRequestEntity request = cast(entity); final ImmutablePair<MimeType, Properties> options = exporterOptions(request); options.right.putAll(transformerConfig); final File input = downloadInput(entity); final File output = File.createTempFile("reply", "tmp"); final ITransformEngine engine = getEngine(); return new WritingEntity() { @Override public void writeData(OutputStream out) throws IOException { try { synchronized (SynchronousTransformer.this) { engine.transform(input.toURI(), fetchTransform(request), output.toURI(), options.right); } try (FileInputStream stream = new FileInputStream(output)) { IOUtils.copy(stream, out); } } finally { input.delete(); output.delete(); } } @Override public MimeType getType() { return options.left; } }; } SynchronousTransformer(ITransformEngine engine, Properties config); @Override boolean isLongRunning(); @Override Entity transform(HttpRequestEntity entity);  }