Skip to content

Commit

Permalink
TIKA-3227 -- add unit test for skipping embedded documents with /rmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Jul 14, 2023
1 parent d36a214 commit 41aa0cc
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.metadata.serialization.JsonMetadataList;
import org.apache.tika.server.core.CXFTestBase;
import org.apache.tika.server.core.config.DocumentSelectorConfig;
import org.apache.tika.server.core.resource.RecursiveMetadataResource;
import org.apache.tika.server.core.writer.MetadataListMessageBodyWriter;

Expand Down Expand Up @@ -331,6 +332,24 @@ public void testEmbeddedResourceLimit() throws Exception {
}
}

// TIKA-3227
@Test
public void testSkipEmbedded() throws Exception {
Response response = WebClient.create(endPoint + META_PATH).accept("application/json")
.header(DocumentSelectorConfig.X_TIKA_SKIP_EMBEDDED_HEADER, "false")
.put(ClassLoader.getSystemResourceAsStream(TEST_RECURSIVE_DOC));
Reader reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
assertEquals(12, metadataList.size());

response = WebClient.create(endPoint + META_PATH).accept("application/json")
.header(DocumentSelectorConfig.X_TIKA_SKIP_EMBEDDED_HEADER, "true")
.put(ClassLoader.getSystemResourceAsStream(TEST_RECURSIVE_DOC));
reader = new InputStreamReader((InputStream) response.getEntity(), UTF_8);
metadataList = JsonMetadataList.fromJson(reader);
assertEquals(1, metadataList.size());
}

@Test
public void testWriteLimit() throws Exception {
int writeLimit = 10;
Expand Down

0 comments on commit 41aa0cc

Please sign in to comment.