Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved a flaky error #1476

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions tika-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
<version>1.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
20 changes: 15 additions & 5 deletions tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.TreeMap;

import com.google.gson.Gson;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -248,16 +251,23 @@ public void testMetadataOutput() throws Exception {
public void testJsonMetadataOutput() throws Exception {
String json = getParamOutContent("--json", "--digest=MD2",
resourcePrefix + "testJsonMultipleInts.html");

Map<String, Object> jsonMap = new Gson().fromJson(json, Map.class);
// Sort properties alphabetically
Map<String, Object> sortedJsonMap = new TreeMap<>(jsonMap);
// Convert back to JSON string
String newJson = new Gson().toJson(sortedJsonMap);

//TIKA-1310
assertTrue(json.contains("\"fb:admins\":\"1,2,3,4\","));
assertTrue(newJson.contains("\"fb:admins\":\"1,2,3,4\","));

//test legacy alphabetic sort of keys
int enc = json.indexOf("\"Content-Encoding\"");
int fb = json.indexOf("fb:admins");
int title = json.indexOf("\"dc:title\"");
int enc = newJson.indexOf("\"Content-Encoding\"");
int fb = newJson.indexOf("fb:admins");
int title = newJson.indexOf("\"dc:title\"");
assertTrue(enc > -1 && fb > -1 && enc < fb);
assertTrue(fb > -1 && title > -1 && fb > title);
assertTrue(json.contains("\"X-TIKA:digest:MD2\":"));
assertTrue(newJson.contains("\"X-TIKA:digest:MD2\":"));
}

/**
Expand Down