Skip to content

Commit b88f062

Browse files
committed
Polish "Remove assumptions about ordering when comparing JSON in tests"
See gh-30514
1 parent 5b3bc1a commit b88f062

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -151,7 +151,7 @@ void additionalGsonBuilderCustomization() {
151151
void customGsonBuilder() {
152152
this.contextRunner.withUserConfiguration(GsonBuilderConfig.class).run((context) -> {
153153
Gson gson = context.getBean(Gson.class);
154-
JSONAssert.assertEquals(gson.toJson(new DataObject()), "{\"data\":1,\"owner\":null}", false);
154+
JSONAssert.assertEquals("{\"data\":1,\"owner\":null}", gson.toJson(new DataObject()), true);
155155
});
156156
}
157157

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import org.junit.jupiter.api.AfterEach;
3131
import org.junit.jupiter.api.BeforeEach;
3232
import org.junit.jupiter.api.Test;
33+
import org.skyscreamer.jsonassert.JSONAssert;
3334

3435
import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
3536
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
@@ -101,7 +102,7 @@ void tearDown() {
101102
@Test
102103
void basicMessagingWithJsonResponse() throws Throwable {
103104
Object result = performStompSubscription("/app/json");
104-
assertThat(new String((byte[]) result)).isEqualTo(String.format("{%n \"foo\" : 5,%n \"bar\" : \"baz\"%n}"));
105+
JSONAssert.assertEquals("{\"foo\" : 5,\"bar\" : \"baz\"}", new String((byte[]) result), true);
105106
}
106107

107108
@Test

0 commit comments

Comments
 (0)