Browse Source

Harmonize json format in tests

pull/28332/head
Stephane Nicoll 4 years ago
parent
commit
1cf112bfa4
  1. 58
      spring-core/src/test/java/org/springframework/aot/nativex/FileNativeConfigurationGeneratorTests.java
  2. 6
      spring-core/src/test/java/org/springframework/aot/nativex/JavaSerializationHintsSerializerTests.java
  3. 6
      spring-core/src/test/java/org/springframework/aot/nativex/ProxyHintsSerializerTests.java
  4. 48
      spring-core/src/test/java/org/springframework/aot/nativex/ReflectionHintsSerializerTests.java
  5. 30
      spring-core/src/test/java/org/springframework/aot/nativex/ResourceHintsSerializerTests.java

58
spring-core/src/test/java/org/springframework/aot/nativex/FileNativeConfigurationGeneratorTests.java

@ -72,8 +72,8 @@ public class FileNativeConfigurationGeneratorTests { @@ -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 { @@ -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 { @@ -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 { @@ -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");

6
spring-core/src/test/java/org/springframework/aot/nativex/JavaSerializationHintsSerializerTests.java

@ -45,7 +45,7 @@ public class JavaSerializationHintsSerializerTests { @@ -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 { @@ -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);
}

6
spring-core/src/test/java/org/springframework/aot/nativex/ProxyHintsSerializerTests.java

@ -47,7 +47,7 @@ public class ProxyHintsSerializerTests { @@ -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 { @@ -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);
}

48
spring-core/src/test/java/org/springframework/aot/nativex/ReflectionHintsSerializerTests.java

@ -73,30 +73,30 @@ public class ReflectionHintsSerializerTests { @@ -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 { @@ -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);
}

30
spring-core/src/test/java/org/springframework/aot/nativex/ResourceHintsSerializerTests.java

@ -16,8 +16,6 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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);
}

Loading…
Cancel
Save