Harmonize json format in tests

This commit is contained in:
Stephane Nicoll 2022-04-11 15:42:35 +02:00
parent c9e7816762
commit 1cf112bfa4
5 changed files with 73 additions and 75 deletions

View File

@ -72,8 +72,8 @@ public class FileNativeConfigurationGeneratorTests {
generator.generate(hints);
assertEquals("""
[
{ "name" : "java.lang.Integer" },
{ "name" : "java.lang.Long" }
{ "name": "java.lang.Integer" },
{ "name": "java.lang.Long" }
]""", "serialization-config.json");
}
@ -87,8 +87,8 @@ public class FileNativeConfigurationGeneratorTests {
generator.generate(hints);
assertEquals("""
[
{ "interfaces" : [ "java.util.function.Function" ] },
{ "interfaces" : [ "java.util.function.Function", "java.util.function.Consumer" ] }
{ "interfaces": [ "java.util.function.Function" ] },
{ "interfaces": [ "java.util.function.Function", "java.util.function.Consumer" ] }
]""", "proxy-config.json");
}
@ -121,30 +121,30 @@ public class FileNativeConfigurationGeneratorTests {
assertEquals("""
[
{
"name" : "org.springframework.core.codec.StringDecoder",
"condition" : { "typeReachable" : "java.lang.String" },
"allPublicFields" : true,
"allDeclaredFields" : true,
"queryAllPublicConstructors" : true,
"queryAllDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredConstructors" : true,
"queryAllPublicMethods" : true,
"queryAllDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredMethods" : true,
"allPublicClasses" : true,
"allDeclaredClasses" : true,
"fields" : [
{ "name" : "DEFAULT_CHARSET" },
{ "name" : "defaultCharset", "allowWrite" = true, "allowUnsafeAccess" = true }
"name": "org.springframework.core.codec.StringDecoder",
"condition": { "typeReachable": "java.lang.String" },
"allPublicFields": true,
"allDeclaredFields": true,
"queryAllPublicConstructors": true,
"queryAllDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredConstructors": true,
"queryAllPublicMethods": true,
"queryAllDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allPublicClasses": true,
"allDeclaredClasses": true,
"fields": [
{ "name": "DEFAULT_CHARSET" },
{ "name": "defaultCharset", "allowWrite": true, "allowUnsafeAccess": true }
],
"methods" : [
{ "name" : "setDefaultCharset", "parameterTypes": [ "java.nio.charset.Charset" ] }
"methods": [
{ "name": "setDefaultCharset", "parameterTypes": [ "java.nio.charset.Charset" ] }
],
"queriedMethods" : [
{ "name" : "<init>", "parameterTypes": [ "java.util.List", "boolean", "org.springframework.util.MimeType" ] },
{ "name" : "getDefaultCharset" }
"queriedMethods": [
{ "name": "<init>", "parameterTypes": [ "java.util.List", "boolean", "org.springframework.util.MimeType" ] },
{ "name": "getDefaultCharset" }
]
}
]""", "reflect-config.json");
@ -161,9 +161,9 @@ public class FileNativeConfigurationGeneratorTests {
assertEquals("""
{
"resources": {
"includes" : [
{"pattern" : "\\\\Qcom/example/test.properties\\\\E"},
{"pattern" : "\\\\Qcom/example/another.properties\\\\E"}
"includes": [
{"pattern": "\\\\Qcom/example/test.properties\\\\E"},
{"pattern": "\\\\Qcom/example/another.properties\\\\E"}
]
}
}""", "resource-config.json");

View File

@ -45,7 +45,7 @@ public class JavaSerializationHintsSerializerTests {
JavaSerializationHints hints = new JavaSerializationHints().registerType(TypeReference.of(String.class));
assertEquals("""
[
{ "name" : "java.lang.String" }
{ "name": "java.lang.String" }
]""", hints);
}
@ -56,8 +56,8 @@ public class JavaSerializationHintsSerializerTests {
.registerType(TypeReference.of(Environment.class));
assertEquals("""
[
{ "name" : "java.lang.String" },
{ "name" : "org.springframework.core.env.Environment" }
{ "name": "java.lang.String" },
{ "name": "org.springframework.core.env.Environment" }
]""", hints);
}

View File

@ -47,7 +47,7 @@ public class ProxyHintsSerializerTests {
hints.registerJdkProxy(Function.class);
assertEquals("""
[
{ "interfaces" : [ "java.util.function.Function" ] }
{ "interfaces": [ "java.util.function.Function" ] }
]""", hints);
}
@ -58,8 +58,8 @@ public class ProxyHintsSerializerTests {
hints.registerJdkProxy(Function.class, Consumer.class);
assertEquals("""
[
{ "interfaces" : [ "java.util.function.Function" ] },
{ "interfaces" : [ "java.util.function.Function", "java.util.function.Consumer" ] }
{ "interfaces": [ "java.util.function.Function" ] },
{ "interfaces": [ "java.util.function.Function", "java.util.function.Consumer" ] }
]""", hints);
}

View File

@ -73,30 +73,30 @@ public class ReflectionHintsSerializerTests {
assertEquals("""
[
{
"name" : "org.springframework.core.codec.StringDecoder",
"condition" : { "typeReachable" : "java.lang.String" },
"allPublicFields" : true,
"allDeclaredFields" : true,
"queryAllPublicConstructors" : true,
"queryAllDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredConstructors" : true,
"queryAllPublicMethods" : true,
"queryAllDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredMethods" : true,
"allPublicClasses" : true,
"allDeclaredClasses" : true,
"fields" : [
{ "name" : "DEFAULT_CHARSET" },
{ "name" : "defaultCharset", "allowWrite" = true, "allowUnsafeAccess" = true }
"name": "org.springframework.core.codec.StringDecoder",
"condition": { "typeReachable": "java.lang.String" },
"allPublicFields": true,
"allDeclaredFields": true,
"queryAllPublicConstructors": true,
"queryAllDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredConstructors": true,
"queryAllPublicMethods": true,
"queryAllDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allPublicClasses": true,
"allDeclaredClasses": true,
"fields": [
{ "name": "DEFAULT_CHARSET" },
{ "name": "defaultCharset", "allowWrite": true, "allowUnsafeAccess": true }
],
"methods" : [
{ "name" : "setDefaultCharset", "parameterTypes": [ "java.nio.charset.Charset" ] }
"methods": [
{ "name": "setDefaultCharset", "parameterTypes": [ "java.nio.charset.Charset" ] }
],
"queriedMethods" : [
{ "name" : "<init>", "parameterTypes": [ "java.util.List", "boolean", "org.springframework.util.MimeType" ] },
{ "name" : "getDefaultCharset" }
"queriedMethods": [
{ "name": "<init>", "parameterTypes": [ "java.util.List", "boolean", "org.springframework.util.MimeType" ] },
{ "name": "getDefaultCharset" }
]
}
]""", hints);
@ -112,8 +112,8 @@ public class ReflectionHintsSerializerTests {
assertEquals("""
[
{ "name" : "java.lang.Integer" },
{ "name" : "java.lang.Long" }
{ "name": "java.lang.Integer" },
{ "name": "java.lang.Long" }
]""", hints);
}

View File

@ -16,8 +16,6 @@
package org.springframework.aot.nativex;
import java.io.IOException;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
@ -35,13 +33,13 @@ public class ResourceHintsSerializerTests {
private final ResourceHintsSerializer serializer = new ResourceHintsSerializer();
@Test
void empty() throws IOException, JSONException {
void empty() throws JSONException {
ResourceHints hints = new ResourceHints();
assertEquals("{}", hints);
}
@Test
void registerExactMatch() throws JSONException {
void registerExactMatch() throws JSONException {
ResourceHints hints = new ResourceHints();
hints.registerPattern("com/example/test.properties");
hints.registerPattern("com/example/another.properties");
@ -49,8 +47,8 @@ public class ResourceHintsSerializerTests {
{
"resources": {
"includes": [
{ "pattern" : "\\\\Qcom/example/test.properties\\\\E"},
{ "pattern" : "\\\\Qcom/example/another.properties\\\\E"}
{ "pattern": "\\\\Qcom/example/test.properties\\\\E"},
{ "pattern": "\\\\Qcom/example/another.properties\\\\E"}
]
}
}""", hints);
@ -63,8 +61,8 @@ public class ResourceHintsSerializerTests {
assertEquals("""
{
"resources": {
"includes" : [
{ "pattern" : "\\\\Qcom/example/\\\\E.*\\\\Q.properties\\\\E"}
"includes": [
{ "pattern": "\\\\Qcom/example/\\\\E.*\\\\Q.properties\\\\E"}
]
}
}""", hints);
@ -79,12 +77,12 @@ public class ResourceHintsSerializerTests {
{
"resources": {
"includes": [
{ "pattern" : "\\\\Qcom/example/\\\\E.*\\\\Q.properties\\\\E"},
{ "pattern" : "\\\\Qorg/example/\\\\E.*\\\\Q.properties\\\\E"}
{ "pattern": "\\\\Qcom/example/\\\\E.*\\\\Q.properties\\\\E"},
{ "pattern": "\\\\Qorg/example/\\\\E.*\\\\Q.properties\\\\E"}
],
"excludes": [
{ "pattern" : "\\\\Qcom/example/to-ignore.properties\\\\E"},
{ "pattern" : "\\\\Qorg/example/to-ignore.properties\\\\E"}
{ "pattern": "\\\\Qcom/example/to-ignore.properties\\\\E"},
{ "pattern": "\\\\Qorg/example/to-ignore.properties\\\\E"}
]
}
}""", hints);
@ -97,8 +95,8 @@ public class ResourceHintsSerializerTests {
assertEquals("""
{
"resources": {
"includes" : [
{ "pattern" : "\\\\Qjava/lang/String.class\\\\E"}
"includes": [
{ "pattern": "\\\\Qjava/lang/String.class\\\\E"}
]
}
}""", hints);
@ -112,8 +110,8 @@ public class ResourceHintsSerializerTests {
assertEquals("""
{
"bundles": [
{ "name" : "com.example.message"},
{ "name" : "com.example.message2"}
{ "name": "com.example.message"},
{ "name": "com.example.message2"}
]
}""", hints);
}