Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
package org.apache.servicecomb.registry.lightweight;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

import org.junit.jupiter.api.Test;

import io.vertx.core.json.Json;
import org.skyscreamer.jsonassert.JSONAssert;

class MessageTest {
private String toLinuxPrettyJson(Object value) {
Expand All @@ -33,7 +35,8 @@ private String toLinuxPrettyJson(Object value) {
void should_encode_register_type() {
Message<RegisterRequest> msg = Message.of(MessageType.REGISTER, new RegisterRequest());

assertThat(toLinuxPrettyJson(msg)).isEqualTo(""
try {
JSONAssert.assertEquals(toLinuxPrettyJson(msg), ""
+ "{\n"
+ " \"type\" : \"REGISTER\",\n"
+ " \"body\" : {\n"
Expand All @@ -45,7 +48,11 @@ void should_encode_register_type() {
+ " \"status\" : null,\n"
+ " \"endpoints\" : null\n"
+ " }\n"
+ "}");
+ "}", false);
} catch (Exception e) {
fail("Failed to compare JSONs: " + e.getMessage(), e);
}

}

@Test
Expand All @@ -60,14 +67,18 @@ void should_decode_register_type() {
void should_encode_unregister_type() {
Message<UnregisterRequest> msg = Message.of(MessageType.UNREGISTER, new UnregisterRequest());

assertThat(toLinuxPrettyJson(msg)).isEqualTo(""
try {
JSONAssert.assertEquals(toLinuxPrettyJson(msg), ""
+ "{\n"
+ " \"type\" : \"UNREGISTER\",\n"
+ " \"body\" : {\n"
+ " \"serviceId\" : null,\n"
+ " \"instanceId\" : null\n"
+ " }\n"
+ "}");
+ "}", false);
} catch (Exception e) {
fail("Failed to compare JSONs: " + e.getMessage(), e);
}
}

@Test
Expand Down
Loading