From 8bc132a290e4226a873d67a88c973bb5714a4d02 Mon Sep 17 00:00:00 2001 From: akib6075 <128719273+akib6075@users.noreply.github.com> Date: Sat, 25 Mar 2023 18:39:04 +0600 Subject: [PATCH 1/4] Create new_test_main.yml --- .github/workflows/new_test_main.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/new_test_main.yml diff --git a/.github/workflows/new_test_main.yml b/.github/workflows/new_test_main.yml new file mode 100644 index 00000000..a7dedfc5 --- /dev/null +++ b/.github/workflows/new_test_main.yml @@ -0,0 +1,27 @@ +name: Test:JSONUtilTest.assertToJSONString +run-name: New known Flaky test +on: [push] +jobs: + Test_Without_Nondex_Shuffling: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + - name: Test + run: mvn -pl hippo4j-common test -Dtest=cn.hippo4j.common.toolkit.JSONUtilTest#assertToJSONString + + Test_With_Nondex_Shuffling: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + - name: Test + run: mvn -pl hippo4j-common edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=cn.hippo4j.common.toolkit.JSONUtilTest#assertToJSONString From ed2db3f38ca7484f7606735c004a5f6c8c091310 Mon Sep 17 00:00:00 2001 From: "akib6074@gmail.com" Date: Sat, 25 Mar 2023 18:42:47 +0600 Subject: [PATCH 2/4] potentially issue fixed --- .../common/toolkit/JacksonHandler.java | 1 + .../hippo4j/common/toolkit/JSONUtilTest.java | 144 +++++++++--------- 2 files changed, 74 insertions(+), 71 deletions(-) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/JacksonHandler.java b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/JacksonHandler.java index f86f0df2..4adb6245 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/JacksonHandler.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/JacksonHandler.java @@ -45,6 +45,7 @@ public class JacksonHandler implements JsonFacade { MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); MAPPER.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + MAPPER.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); } @Override diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java index e01ff4cd..2bc3892f 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java @@ -15,74 +15,76 @@ * limitations under the License. */ -package cn.hippo4j.common.toolkit; - -import com.fasterxml.jackson.core.type.TypeReference; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class JSONUtilTest { - - private static final Foo EXPECTED_FOO = new Foo(1, "foo1", new Foo(2, "foo2", null)); - - private static final List EXPECTED_FOO_ARRAY = Arrays.asList(EXPECTED_FOO, EXPECTED_FOO); - - private static final String EXPECTED_FOO_JSON = "{\"id\":1,\"name\":\"foo1\",\"foo\":{\"id\":2,\"name\":\"foo2\"}}"; - - private static final String EXPECTED_FOO_JSON_ARRAY = "[" + EXPECTED_FOO_JSON + "," + EXPECTED_FOO_JSON + "]"; - - @Test - public void assertToJSONString() { - Assert.assertNull(JSONUtil.toJSONString(null)); - Assert.assertEquals(EXPECTED_FOO_JSON, JSONUtil.toJSONString(EXPECTED_FOO)); - } - - @Test - public void assertParseObject() { - Assert.assertNull(JSONUtil.parseObject(null, Foo.class)); - Assert.assertNull(JSONUtil.parseObject(" ", Foo.class)); - Assert.assertEquals(EXPECTED_FOO, JSONUtil.parseObject(EXPECTED_FOO_JSON, Foo.class)); - } - - @Test - public void assertParseObjectTypeReference() { - Assert.assertNull(JSONUtil.parseObject(null, new TypeReference>() { - })); - Assert.assertNull(JSONUtil.parseObject(" ", new TypeReference>() { - })); - Assert.assertEquals( - EXPECTED_FOO_ARRAY, - JSONUtil.parseObject(EXPECTED_FOO_JSON_ARRAY, new TypeReference>() { - })); - } - - @Test - public void assertParseArray() { - Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(null, Foo.class)); - Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(" ", Foo.class)); - Assert.assertEquals( - EXPECTED_FOO_ARRAY, - JSONUtil.parseArray(EXPECTED_FOO_JSON_ARRAY, Foo.class)); - } - - @EqualsAndHashCode - @AllArgsConstructor - @NoArgsConstructor - @Data - private static class Foo { - - private Integer id; - - private String name; - - private Foo foo; - } -} + package cn.hippo4j.common.toolkit; + + import com.fasterxml.jackson.core.type.TypeReference; + import lombok.AllArgsConstructor; + import lombok.Data; + import lombok.EqualsAndHashCode; + import lombok.NoArgsConstructor; + import org.junit.Assert; + import org.junit.Test; + + import java.util.Arrays; + import java.util.Collections; + import java.util.List; + + public class JSONUtilTest { + + private static final Foo EXPECTED_FOO = new Foo(new Foo(null, 2, "foo2"), 1, "foo1"); + + private static final List EXPECTED_FOO_ARRAY = Arrays.asList(EXPECTED_FOO, EXPECTED_FOO); + + private static final String EXPECTED_FOO_JSON = "{\"foo\":{\"id\":2,\"name\":\"foo2\"},\"id\":1,\"name\":\"foo1\"}"; + + private static final String EXPECTED_FOO_JSON_ARRAY = "[" + EXPECTED_FOO_JSON + "," + EXPECTED_FOO_JSON + "]"; + + @Test + public void assertToJSONString() { + Assert.assertNull(JSONUtil.toJSONString(null)); + Assert.assertEquals(EXPECTED_FOO_JSON, JSONUtil.toJSONString(EXPECTED_FOO)); + } + + @Test + public void assertParseObject() { + Assert.assertNull(JSONUtil.parseObject(null, Foo.class)); + Assert.assertNull(JSONUtil.parseObject(" ", Foo.class)); + Assert.assertEquals(EXPECTED_FOO, JSONUtil.parseObject(EXPECTED_FOO_JSON, Foo.class)); + } + + @Test + public void assertParseObjectTypeReference() { + Assert.assertNull(JSONUtil.parseObject(null, new TypeReference>() { + })); + Assert.assertNull(JSONUtil.parseObject(" ", new TypeReference>() { + })); + Assert.assertEquals( + EXPECTED_FOO_ARRAY, + JSONUtil.parseObject(EXPECTED_FOO_JSON_ARRAY, new TypeReference>() { + })); + } + + @Test + public void assertParseArray() { + Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(null, Foo.class)); + Assert.assertEquals(Collections.emptyList(), JSONUtil.parseArray(" ", Foo.class)); + Assert.assertEquals( + EXPECTED_FOO_ARRAY, + JSONUtil.parseArray(EXPECTED_FOO_JSON_ARRAY, Foo.class)); + } + + @EqualsAndHashCode + @AllArgsConstructor + @NoArgsConstructor + @Data + private static class Foo { + + private Foo foo; + + private Integer id; + + private String name; + + } + } + \ No newline at end of file From 57c388620ee6c908e2931743c981bdb95449b917 Mon Sep 17 00:00:00 2001 From: "akib6074@gmail.com" Date: Thu, 25 May 2023 11:07:51 +0600 Subject: [PATCH 3/4] resolved conflicts --- .../src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java index 2bc3892f..70550ae3 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.hippo4j.common.toolkit; import com.fasterxml.jackson.core.type.TypeReference; From b720f264c81b2a05ab8b4b0a58f8f0282dcf0d2c Mon Sep 17 00:00:00 2001 From: Kazi Akib Javed Date: Tue, 24 Oct 2023 10:53:03 +0600 Subject: [PATCH 4/4] Issue fixed for assertGetPoolContent method --- .../test/java/cn/hippo4j/common/toolkit/ContentUtilTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ContentUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ContentUtilTest.java index a8cd74c9..dc527cc7 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ContentUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ContentUtilTest.java @@ -31,7 +31,7 @@ public class ContentUtilTest { .itemId("dynamic-threadpool-example").tpId("message-consume").content("描述信息").corePoolSize(1) .maximumPoolSize(2).queueType(1).capacity(4).keepAliveTime(513).executeTimeOut(null).rejectedType(4) .isAlarm(1).capacityAlarm(80).livenessAlarm(80).allowCoreThreadTimeOut(1).build(); - Assert.isTrue(testText.equals(ContentUtil.getPoolContent(threadPoolParameterInfo))); + Assert.isTrue(ContentUtil.getPoolContent(JSONUtil.parseObject(testText, ThreadPoolParameterInfo.class)).equals(ContentUtil.getPoolContent(threadPoolParameterInfo))); } @Test