Skip to content

Commit 94fd03d

Browse files
fix flaky tests (apache#6905)
Co-authored-by: Yanni <[email protected]>
1 parent adec811 commit 94fd03d

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎plugins/network-elements/opendaylight/src/test/java/org/apache/cloudstack/network/opendaylight/api/test/NeutronNetworkAdapterTest.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.commons.httpclient.methods.StringRequestEntity;
2828
import org.junit.Test;
2929

30+
import com.google.gson.JsonParser;
3031
import com.google.gson.FieldNamingPolicy;
3132
import com.google.gson.Gson;
3233
import com.google.gson.GsonBuilder;
@@ -58,7 +59,8 @@ public void gsonNeutronNetworkMarshalingTest() throws NeutronRestApiException {
5859
entity = new StringRequestEntity(gsonNeutronNetwork.toJson(networkWrapper), "application/json", null);
5960

6061
String actual = entity.getContent();
61-
Assert.assertEquals(jsonString, actual);
62+
JsonParser parser = new JsonParser();
63+
Assert.assertEquals(parser.parse(jsonString), parser.parse(actual));
6264
} catch (UnsupportedEncodingException e) {
6365
Assert.fail(e.getMessage());
6466
}

‎plugins/network-elements/opendaylight/src/test/java/org/apache/cloudstack/network/opendaylight/api/test/NeutronNodeAdapterTest.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.commons.httpclient.methods.StringRequestEntity;
3030
import org.junit.Test;
3131

32+
import com.google.gson.JsonParser;
3233
import com.google.gson.FieldNamingPolicy;
3334
import com.google.gson.Gson;
3435
import com.google.gson.GsonBuilder;
@@ -48,7 +49,8 @@ public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
4849
entity = new StringRequestEntity(gsonNeutronNode.toJson(nodeWrapper), "application/json", null);
4950

5051
String actual = entity.getContent();
51-
Assert.assertEquals(jsonString, actual);
52+
JsonParser parser = new JsonParser();
53+
Assert.assertEquals(parser.parse(jsonString), parser.parse(actual));
5254
} catch (UnsupportedEncodingException e) {
5355
Assert.fail(e.getMessage());
5456
}

‎plugins/network-elements/opendaylight/src/test/java/org/apache/cloudstack/network/opendaylight/api/test/NeutronPortAdapterTest.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.commons.httpclient.methods.StringRequestEntity;
3131
import org.junit.Test;
3232

33+
import com.google.gson.JsonParser;
3334
import com.google.gson.FieldNamingPolicy;
3435
import com.google.gson.Gson;
3536
import com.google.gson.GsonBuilder;
@@ -61,7 +62,8 @@ public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
6162

6263
String actual = entity.getContent();
6364

64-
Assert.assertEquals(jsonString, actual);
65+
JsonParser parser = new JsonParser();
66+
Assert.assertEquals(parser.parse(jsonString), parser.parse(actual));
6567
} catch (UnsupportedEncodingException e) {
6668
Assert.fail(e.getMessage());
6769
}

0 commit comments

Comments
 (0)