dschmidt commented on code in PR #3096: URL: https://github.com/apache/tika/pull/3096#discussion_r3916008252
########## tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerThumbnailTest.java: ########## @@ -0,0 +1,208 @@ +/* + * 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.tika.server.standard; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.imageio.ImageIO; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.ws.rs.core.Response; +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; +import org.junit.jupiter.api.Test; + +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.serialization.config.JsonConfigHelper; +import org.apache.tika.server.core.CXFTestBase; +import org.apache.tika.server.core.TikaServerParseExceptionMapper; +import org.apache.tika.server.core.resource.RecursiveMetadataResource; +import org.apache.tika.server.core.resource.UnpackerResource; +import org.apache.tika.server.core.writer.MetadataListMessageBodyWriter; + +/** + * {@code /unpack/thumbnail} end to end: the document thumbnail comes back as + * JSON with its metadata and the image as base64. + */ +public class UnpackerThumbnailTest extends CXFTestBase { + + private static final String THUMBNAIL_PATH = "/unpack/thumbnail"; + private static final String UNPACK_CONFIG_TEMPLATE = "/configs/cxf-unpack-test-template.json"; + private static final ObjectMapper MAPPER = new ObjectMapper(); + + private Path unpackTempDir; + + @Override + protected void setUpResources(JAXRSServerFactoryBean sf) { + sf.setResourceClasses(UnpackerResource.class, RecursiveMetadataResource.class); + sf.setResourceProvider(UnpackerResource.class, + new SingletonResourceProvider(new UnpackerResource(tikaResource))); + sf.setResourceProvider(RecursiveMetadataResource.class, + new SingletonResourceProvider(new RecursiveMetadataResource(tikaResource))); + } + + @Override + protected void setUpProviders(JAXRSServerFactoryBean sf) { + List<Object> providers = new ArrayList<>(); + providers.add(new TikaServerParseExceptionMapper()); + providers.add(new MetadataListMessageBodyWriter()); + sf.setProviders(providers); + } + + @Override + protected InputStream getPipesConfigInputStream() throws IOException { + unpackTempDir = Files.createTempDirectory("tika-unpack-thumbnail-test-"); + Path pluginsDir = Paths.get("target/plugins").toAbsolutePath(); + Map<String, Object> replacements = new HashMap<>(); + replacements.put("UNPACK_EMITTER_BASE_PATH", unpackTempDir.toAbsolutePath().toString()); Review Comment: Fixed in 02d86467e1, with the same AfterAll UnpackerResourceTest uses. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
