Fix building on JDK 9

This commit is contained in:
Graham Triggs 2017-10-23 19:24:32 +01:00
parent f7a7aa5060
commit 41be1c22f4
4 changed files with 23 additions and 4 deletions

View file

@ -6,14 +6,19 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -470,6 +475,8 @@ public class SparqlQueryApiExecutorTest extends AbstractTestClass {
assertEquivalentTurtle(message, expected, out.toString()); assertEquivalentTurtle(message, expected, out.toString());
} else if (ACCEPT_N3.equals(acceptHeader)) { } else if (ACCEPT_N3.equals(acceptHeader)) {
assertEquivalentN3(message, expected, out.toString()); assertEquivalentN3(message, expected, out.toString());
} else if (ACCEPT_JSON.equals(acceptHeader)) {
assertEquivalentJSON(message, expected, out.toString());
} else { } else {
assertEqualsIgnoreWhiteSpace(message, expected, out.toString()); assertEqualsIgnoreWhiteSpace(message, expected, out.toString());
} }
@ -541,6 +548,18 @@ public class SparqlQueryApiExecutorTest extends AbstractTestClass {
return StringUtils.join(remainder, "\n"); return StringUtils.join(remainder, "\n");
} }
private void assertEquivalentJSON(String message, String expected,
String actual) {
ObjectMapper om = new ObjectMapper();
try {
Map<String, Object> expMap = (Map<String, Object>)(om.readValue(expected, Map.class));
Map<String, Object> actMap = (Map<String, Object>)(om.readValue(actual, Map.class));
assertEquals(message, expMap, actMap);
} catch (IOException e) {
assertEquals(message, expected.replaceAll("\\s+", " "),
actual.replaceAll("\\s+", " "));
}
}
private void assertEqualsIgnoreWhiteSpace(String message, String expected, private void assertEqualsIgnoreWhiteSpace(String message, String expected,
String actual) { String actual) {
assertEquals(message, expected.replaceAll("\\s+", " "), assertEquals(message, expected.replaceAll("\\s+", " "),

View file

@ -219,7 +219,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
// Throws an exception because we don't test for a null path from the // Throws an exception because we don't test for a null path from the
// ServletContext. // ServletContext.
assertLogMessagesContains("no real path", "at java.io.File.<init>"); assertLogMessagesContains("no real path", "java.io.File.<init>");
} }
@Test @Test

View file

@ -96,7 +96,7 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>2.6</version> <version>3.2.0</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>

View file

@ -271,7 +271,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.6</version> <version>3.0.2</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -290,7 +290,7 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>2.6</version> <version>3.2.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>